| 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 <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 : public net::URLFetcherDelegate, | 39 : public net::URLFetcherDelegate, |
| 40 public net::NetworkChangeNotifier::IPAddressObserver { | 40 public net::NetworkChangeNotifier::IPAddressObserver { |
| 41 public: | 41 public: |
| 42 // Only the main browser process loop should call this, when setting up | 42 // Only the main browser process loop should call this, when setting up |
| 43 // g_browser_process->intranet_redirect_detector_. No code other than the | 43 // g_browser_process->intranet_redirect_detector_. No code other than the |
| 44 // IntranetRedirectDetector itself should actually use | 44 // IntranetRedirectDetector itself should actually use |
| 45 // g_browser_process->intranet_redirect_detector() (which shouldn't be hard, | 45 // g_browser_process->intranet_redirect_detector() (which shouldn't be hard, |
| 46 // since there aren't useful public functions on this object for consumers to | 46 // since there aren't useful public functions on this object for consumers to |
| 47 // access anyway). | 47 // access anyway). |
| 48 IntranetRedirectDetector(); | 48 IntranetRedirectDetector(); |
| 49 virtual ~IntranetRedirectDetector(); | 49 ~IntranetRedirectDetector() override; |
| 50 | 50 |
| 51 // Returns the current redirect origin. This will be empty if no redirection | 51 // Returns the current redirect origin. This will be empty if no redirection |
| 52 // is in place. | 52 // is in place. |
| 53 static GURL RedirectOrigin(); | 53 static GURL RedirectOrigin(); |
| 54 | 54 |
| 55 static void RegisterPrefs(PrefRegistrySimple* registry); | 55 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 typedef std::set<net::URLFetcher*> Fetchers; | 58 typedef std::set<net::URLFetcher*> Fetchers; |
| 59 | 59 |
| 60 // 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 |
| 61 // switch sleep has finished. Runs any pending fetch. | 61 // switch sleep has finished. Runs any pending fetch. |
| 62 void FinishSleep(); | 62 void FinishSleep(); |
| 63 | 63 |
| 64 // net::URLFetcherDelegate | 64 // net::URLFetcherDelegate |
| 65 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 65 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 66 | 66 |
| 67 // NetworkChangeNotifier::IPAddressObserver | 67 // NetworkChangeNotifier::IPAddressObserver |
| 68 virtual void OnIPAddressChanged() override; | 68 void OnIPAddressChanged() override; |
| 69 | 69 |
| 70 GURL redirect_origin_; | 70 GURL redirect_origin_; |
| 71 Fetchers fetchers_; | 71 Fetchers fetchers_; |
| 72 std::vector<GURL> resulting_origins_; | 72 std::vector<GURL> resulting_origins_; |
| 73 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 |
| 74 // that begins at browser start, or the one-second "no | 74 // that begins at browser start, or the one-second "no |
| 75 // fetching" period that begins after network switches. | 75 // fetching" period that begins after network switches. |
| 76 base::WeakPtrFactory<IntranetRedirectDetector> weak_ptr_factory_; | 76 base::WeakPtrFactory<IntranetRedirectDetector> weak_ptr_factory_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); | 78 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 81 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| OLD | NEW |