| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 static const size_t kNumCharsInHostnames; | 59 static const size_t kNumCharsInHostnames; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 typedef std::set<content::URLFetcher*> Fetchers; | 62 typedef std::set<content::URLFetcher*> Fetchers; |
| 63 | 63 |
| 64 // Called when the seven second startup sleep or the one second network | 64 // Called when the seven second startup sleep or the one second network |
| 65 // switch sleep has finished. Runs any pending fetch. | 65 // switch sleep has finished. Runs any pending fetch. |
| 66 void FinishSleep(); | 66 void FinishSleep(); |
| 67 | 67 |
| 68 // content::URLFetcherDelegate | 68 // content::URLFetcherDelegate |
| 69 virtual void OnURLFetchComplete(const content::URLFetcher* source); | 69 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| 70 | 70 |
| 71 // NetworkChangeNotifier::IPAddressObserver | 71 // NetworkChangeNotifier::IPAddressObserver |
| 72 virtual void OnIPAddressChanged(); | 72 virtual void OnIPAddressChanged() OVERRIDE; |
| 73 | 73 |
| 74 GURL redirect_origin_; | 74 GURL redirect_origin_; |
| 75 ScopedRunnableMethodFactory<IntranetRedirectDetector> fetcher_factory_; | 75 ScopedRunnableMethodFactory<IntranetRedirectDetector> fetcher_factory_; |
| 76 Fetchers fetchers_; | 76 Fetchers fetchers_; |
| 77 std::vector<GURL> resulting_origins_; | 77 std::vector<GURL> resulting_origins_; |
| 78 bool in_sleep_; // True if we're in the seven-second "no fetching" period | 78 bool in_sleep_; // True if we're in the seven-second "no fetching" period |
| 79 // that begins at browser start, or the one-second "no | 79 // that begins at browser start, or the one-second "no |
| 80 // fetching" period that begins after network switches. | 80 // fetching" period that begins after network switches. |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); | 82 DISALLOW_COPY_AND_ASSIGN(IntranetRedirectDetector); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // This is for use in testing, where we don't want our fetches to actually go | 85 // This is for use in testing, where we don't want our fetches to actually go |
| 86 // over the network. It captures the requests and causes them to fail. | 86 // over the network. It captures the requests and causes them to fail. |
| 87 class IntranetRedirectHostResolverProc : public net::HostResolverProc { | 87 class IntranetRedirectHostResolverProc : public net::HostResolverProc { |
| 88 public: | 88 public: |
| 89 explicit IntranetRedirectHostResolverProc(net::HostResolverProc* previous); | 89 explicit IntranetRedirectHostResolverProc(net::HostResolverProc* previous); |
| 90 | 90 |
| 91 virtual int Resolve(const std::string& host, | 91 virtual int Resolve(const std::string& host, |
| 92 net::AddressFamily address_family, | 92 net::AddressFamily address_family, |
| 93 net::HostResolverFlags host_resolver_flags, | 93 net::HostResolverFlags host_resolver_flags, |
| 94 net::AddressList* addrlist, | 94 net::AddressList* addrlist, |
| 95 int* os_error); | 95 int* os_error) OVERRIDE; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 98 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| OLD | NEW |