Chromium Code Reviews| 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 NET_PROXY_PROXY_SCRIPT_DECIDER_H_ | 5 #ifndef NET_PROXY_PROXY_SCRIPT_DECIDER_H_ |
| 6 #define NET_PROXY_PROXY_SCRIPT_DECIDER_H_ | 6 #define NET_PROXY_PROXY_SCRIPT_DECIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "net/base/address_list.h" | |
| 15 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 16 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 17 #include "net/base/net_log.h" | 18 #include "net/base/net_log.h" |
| 19 #include "net/dns/host_resolver.h" | |
| 18 #include "net/proxy/proxy_config.h" | 20 #include "net/proxy/proxy_config.h" |
| 19 #include "net/proxy/proxy_resolver.h" | 21 #include "net/proxy/proxy_resolver.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 namespace net { | 24 namespace net { |
| 23 | 25 |
| 24 class DhcpProxyScriptFetcher; | 26 class DhcpProxyScriptFetcher; |
| 25 class NetLogParameter; | 27 class NetLogParameter; |
| 26 class ProxyResolver; | 28 class ProxyResolver; |
| 27 class ProxyScriptFetcher; | 29 class ProxyScriptFetcher; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 NetLog::LogLevel log_level) const; | 98 NetLog::LogLevel log_level) const; |
| 97 | 99 |
| 98 Type type; | 100 Type type; |
| 99 GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|. | 101 GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|. |
| 100 }; | 102 }; |
| 101 | 103 |
| 102 typedef std::vector<PacSource> PacSourceList; | 104 typedef std::vector<PacSource> PacSourceList; |
| 103 | 105 |
| 104 enum State { | 106 enum State { |
| 105 STATE_NONE, | 107 STATE_NONE, |
| 108 STATE_QUICK_CHECK, | |
| 109 STATE_QUICK_CHECK_COMPLETE, | |
| 106 STATE_WAIT, | 110 STATE_WAIT, |
| 107 STATE_WAIT_COMPLETE, | 111 STATE_WAIT_COMPLETE, |
| 108 STATE_FETCH_PAC_SCRIPT, | 112 STATE_FETCH_PAC_SCRIPT, |
| 109 STATE_FETCH_PAC_SCRIPT_COMPLETE, | 113 STATE_FETCH_PAC_SCRIPT_COMPLETE, |
| 110 STATE_VERIFY_PAC_SCRIPT, | 114 STATE_VERIFY_PAC_SCRIPT, |
| 111 STATE_VERIFY_PAC_SCRIPT_COMPLETE, | 115 STATE_VERIFY_PAC_SCRIPT_COMPLETE, |
| 116 STATE_FAILED, | |
| 112 }; | 117 }; |
| 113 | 118 |
| 114 // Returns ordered list of PAC urls to try for |config|. | 119 // Returns ordered list of PAC urls to try for |config|. |
| 115 PacSourceList BuildPacSourcesFallbackList(const ProxyConfig& config) const; | 120 PacSourceList BuildPacSourcesFallbackList(const ProxyConfig& config) const; |
| 116 | 121 |
| 117 void OnIOCompletion(int result); | 122 void OnIOCompletion(int result); |
| 118 int DoLoop(int result); | 123 int DoLoop(int result); |
| 119 void DoCallback(int result); | 124 void DoCallback(int result); |
| 120 | 125 |
| 126 int DoQuickCheck(); | |
| 127 int DoQuickCheckComplete(); | |
| 128 void OnQuickCheckComplete(int result); | |
| 129 | |
| 121 int DoWait(); | 130 int DoWait(); |
| 122 int DoWaitComplete(int result); | 131 int DoWaitComplete(int result); |
| 123 | 132 |
| 124 int DoFetchPacScript(); | 133 int DoFetchPacScript(); |
| 125 int DoFetchPacScriptComplete(int result); | 134 int DoFetchPacScriptComplete(int result); |
| 126 | 135 |
| 127 int DoVerifyPacScript(); | 136 int DoVerifyPacScript(); |
| 128 int DoVerifyPacScriptComplete(int result); | 137 int DoVerifyPacScriptComplete(int result); |
| 129 | 138 |
| 130 // Tries restarting using the next fallback PAC URL: | 139 // Tries restarting using the next fallback PAC URL: |
| 131 // |pac_sources_[++current_pac_source_index]|. | 140 // |pac_sources_[++current_pac_source_index]|. |
| 132 // Returns OK and rewinds the state machine when there | 141 // Returns OK and rewinds the state machine when there |
| 133 // is something to try, otherwise returns |error|. | 142 // is something to try, otherwise returns |error|. |
| 134 int TryToFallbackPacSource(int error); | 143 int TryToFallbackPacSource(int error); |
| 135 | 144 |
| 136 // Gets the initial state (we skip fetching when the | 145 // Gets the initial state (we skip fetching when the |
| 137 // ProxyResolver doesn't |expect_pac_bytes()|. | 146 // ProxyResolver doesn't |expect_pac_bytes()|. |
| 138 State GetStartState() const; | 147 State GetStartState() const; |
| 139 | 148 |
| 140 void DetermineURL(const PacSource& pac_source, GURL* effective_pac_url); | 149 void DetermineURL(const PacSource& pac_source, GURL* effective_pac_url); |
| 141 | 150 |
| 142 // Returns the current PAC URL we are fetching/testing. | 151 // Returns the current PAC URL we are fetching/testing. |
| 143 const PacSource& current_pac_source() const; | 152 const PacSource& current_pac_source() const; |
| 144 | 153 |
| 154 void OnQuickCheckTimerFired(); | |
| 145 void OnWaitTimerFired(); | 155 void OnWaitTimerFired(); |
| 146 void DidComplete(); | 156 void DidComplete(); |
| 147 void Cancel(); | 157 void Cancel(); |
| 148 | 158 |
| 149 ProxyResolver* resolver_; | 159 ProxyResolver* resolver_; |
| 150 ProxyScriptFetcher* proxy_script_fetcher_; | 160 ProxyScriptFetcher* proxy_script_fetcher_; |
| 151 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_; | 161 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_; |
| 152 | 162 |
| 153 net::CompletionCallback callback_; | 163 net::CompletionCallback callback_; |
| 154 | 164 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 168 | 178 |
| 169 bool fetch_pac_bytes_; | 179 bool fetch_pac_bytes_; |
| 170 | 180 |
| 171 base::TimeDelta wait_delay_; | 181 base::TimeDelta wait_delay_; |
| 172 base::OneShotTimer<ProxyScriptDecider> wait_timer_; | 182 base::OneShotTimer<ProxyScriptDecider> wait_timer_; |
| 173 | 183 |
| 174 // Results. | 184 // Results. |
| 175 ProxyConfig effective_config_; | 185 ProxyConfig effective_config_; |
| 176 scoped_refptr<ProxyResolverScriptData> script_data_; | 186 scoped_refptr<ProxyResolverScriptData> script_data_; |
| 177 | 187 |
| 188 scoped_ptr<HostResolver> host_resolver_; | |
| 189 AddressList wpad_addrs_; | |
| 190 HostResolver::RequestHandle wpad_req_; | |
| 191 base::TimeDelta quick_check_delay_; | |
|
szym
2013/08/21 19:11:21
Do you anticipate changing this value? If not, dec
| |
| 192 base::OneShotTimer<ProxyScriptDecider> quick_check_timer_; | |
| 193 base::Time quick_check_started_; | |
|
szym
2013/08/21 19:11:21
Instead of storing it here, bind it into the Callb
szym
2013/08/21 19:21:09
Both the timer and HostResolver::Request.
Complet
| |
| 178 | 194 |
| 179 DISALLOW_COPY_AND_ASSIGN(ProxyScriptDecider); | 195 DISALLOW_COPY_AND_ASSIGN(ProxyScriptDecider); |
| 180 }; | 196 }; |
| 181 | 197 |
| 182 } // namespace net | 198 } // namespace net |
| 183 | 199 |
| 184 #endif // NET_PROXY_PROXY_SCRIPT_DECIDER_H_ | 200 #endif // NET_PROXY_PROXY_SCRIPT_DECIDER_H_ |
| OLD | NEW |