| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // net::URLFetcherDelegate | 68 // net::URLFetcherDelegate |
| 69 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 69 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 70 | 70 |
| 71 // NetworkChangeNotifier::IPAddressObserver | 71 // NetworkChangeNotifier::IPAddressObserver |
| 72 virtual void OnIPAddressChanged() OVERRIDE; | 72 virtual void OnIPAddressChanged() OVERRIDE; |
| 73 | 73 |
| 74 GURL redirect_origin_; | 74 GURL redirect_origin_; |
| 75 base::WeakPtrFactory<IntranetRedirectDetector> weak_factory_; | |
| 76 Fetchers fetchers_; | 75 Fetchers fetchers_; |
| 77 std::vector<GURL> resulting_origins_; | 76 std::vector<GURL> resulting_origins_; |
| 78 bool in_sleep_; // True if we're in the seven-second "no fetching" period | 77 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 | 78 // that begins at browser start, or the one-second "no |
| 80 // fetching" period that begins after network switches. | 79 // fetching" period that begins after network switches. |
| 80 base::WeakPtrFactory<IntranetRedirectDetector> weak_ptr_factory_; |
| 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) OVERRIDE; | 95 int* os_error) OVERRIDE; |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 virtual ~IntranetRedirectHostResolverProc() {} | 98 virtual ~IntranetRedirectHostResolverProc() {} |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ | 101 #endif // CHROME_BROWSER_INTRANET_REDIRECT_DETECTOR_H_ |
| OLD | NEW |