| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| 6 #define CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 6 #define CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
| 17 #include "net/dns/host_resolver_proc.h" | 18 #include "net/dns/host_resolver_proc.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 49 IntranetRedirectDetector(); | 50 IntranetRedirectDetector(); |
| 50 ~IntranetRedirectDetector() override; | 51 ~IntranetRedirectDetector() override; |
| 51 | 52 |
| 52 // Returns the current redirect origin. This will be empty if no redirection | 53 // Returns the current redirect origin. This will be empty if no redirection |
| 53 // is in place. | 54 // is in place. |
| 54 static GURL RedirectOrigin(); | 55 static GURL RedirectOrigin(); |
| 55 | 56 |
| 56 static void RegisterPrefs(PrefRegistrySimple* registry); | 57 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 typedef std::set<net::URLFetcher*> Fetchers; | |
| 60 | |
| 61 // Called when the seven second startup sleep or the one second network | 60 // Called when the seven second startup sleep or the one second network |
| 62 // switch sleep has finished. Runs any pending fetch. | 61 // switch sleep has finished. Runs any pending fetch. |
| 63 void FinishSleep(); | 62 void FinishSleep(); |
| 64 | 63 |
| 65 // net::URLFetcherDelegate | 64 // net::URLFetcherDelegate |
| 66 void OnURLFetchComplete(const net::URLFetcher* source) override; | 65 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 67 | 66 |
| 68 // NetworkChangeNotifier::IPAddressObserver | 67 // NetworkChangeNotifier::IPAddressObserver |
| 69 void OnIPAddressChanged() override; | 68 void OnIPAddressChanged() override; |
| 70 | 69 |
| 71 GURL redirect_origin_; | 70 GURL redirect_origin_; |
| 72 Fetchers fetchers_; | 71 std::map<net::URLFetcher*, std::unique_ptr<net::URLFetcher>> fetchers_; |
| 73 std::vector<GURL> resulting_origins_; | 72 std::vector<GURL> resulting_origins_; |
| 74 bool in_sleep_; // True if we're in the seven-second "no fetching" period | 73 bool in_sleep_; // True if we're in the seven-second "no fetching" period |
| 75 // that begins at browser start, or the one-second "no | 74 // that begins at browser start, or the one-second "no |
| 76 // fetching" period that begins after network switches. | 75 // fetching" period that begins after network switches. |
| 77 base::WeakPtrFactory<IntranetRedirectDetector> weak_ptr_factory_; | 76 base::WeakPtrFactory<IntranetRedirectDetector> weak_ptr_factory_; |
| 78 | 77 |
| 79 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); | 78 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 81 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| OLD | NEW |