Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: net/proxy/proxy_script_decider.h

Issue 23181010: Fast-fail WPAD detection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Re-fix MockHostResolver Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/mock_host_resolver.cc ('k') | net/proxy/proxy_script_decider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
20 #include "net/dns/single_request_host_resolver.h"
18 #include "net/proxy/proxy_config.h" 21 #include "net/proxy/proxy_config.h"
19 #include "net/proxy/proxy_resolver.h" 22 #include "net/proxy/proxy_resolver.h"
20 #include "url/gurl.h" 23 #include "url/gurl.h"
21 24
22 namespace net { 25 namespace net {
23 26
24 class DhcpProxyScriptFetcher; 27 class DhcpProxyScriptFetcher;
25 class NetLogParameter; 28 class NetLogParameter;
26 class ProxyResolver; 29 class ProxyResolver;
27 class ProxyScriptFetcher; 30 class ProxyScriptFetcher;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Type type; 101 Type type;
99 GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|. 102 GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|.
100 }; 103 };
101 104
102 typedef std::vector<PacSource> PacSourceList; 105 typedef std::vector<PacSource> PacSourceList;
103 106
104 enum State { 107 enum State {
105 STATE_NONE, 108 STATE_NONE,
106 STATE_WAIT, 109 STATE_WAIT,
107 STATE_WAIT_COMPLETE, 110 STATE_WAIT_COMPLETE,
111 STATE_QUICK_CHECK,
112 STATE_QUICK_CHECK_COMPLETE,
108 STATE_FETCH_PAC_SCRIPT, 113 STATE_FETCH_PAC_SCRIPT,
109 STATE_FETCH_PAC_SCRIPT_COMPLETE, 114 STATE_FETCH_PAC_SCRIPT_COMPLETE,
110 STATE_VERIFY_PAC_SCRIPT, 115 STATE_VERIFY_PAC_SCRIPT,
111 STATE_VERIFY_PAC_SCRIPT_COMPLETE, 116 STATE_VERIFY_PAC_SCRIPT_COMPLETE,
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
121 int DoWait(); 126 int DoWait();
122 int DoWaitComplete(int result); 127 int DoWaitComplete(int result);
123 128
129 int DoQuickCheck();
130 int DoQuickCheckComplete(int result);
131
124 int DoFetchPacScript(); 132 int DoFetchPacScript();
125 int DoFetchPacScriptComplete(int result); 133 int DoFetchPacScriptComplete(int result);
126 134
127 int DoVerifyPacScript(); 135 int DoVerifyPacScript();
128 int DoVerifyPacScriptComplete(int result); 136 int DoVerifyPacScriptComplete(int result);
129 137
130 // Tries restarting using the next fallback PAC URL: 138 // Tries restarting using the next fallback PAC URL:
131 // |pac_sources_[++current_pac_source_index]|. 139 // |pac_sources_[++current_pac_source_index]|.
132 // Returns OK and rewinds the state machine when there 140 // Returns OK and rewinds the state machine when there
133 // is something to try, otherwise returns |error|. 141 // is something to try, otherwise returns |error|.
(...skipping 20 matching lines...) Expand all
154 162
155 size_t current_pac_source_index_; 163 size_t current_pac_source_index_;
156 164
157 // Filled when the PAC script fetch completes. 165 // Filled when the PAC script fetch completes.
158 base::string16 pac_script_; 166 base::string16 pac_script_;
159 167
160 // Flag indicating whether the caller requested a mandatory pac script 168 // Flag indicating whether the caller requested a mandatory pac script
161 // (i.e. fallback to direct connections are prohibited). 169 // (i.e. fallback to direct connections are prohibited).
162 bool pac_mandatory_; 170 bool pac_mandatory_;
163 171
172 // Whether we have an existing custom PAC URL.
173 bool have_custom_pac_url_;
174
164 PacSourceList pac_sources_; 175 PacSourceList pac_sources_;
165 State next_state_; 176 State next_state_;
166 177
167 BoundNetLog net_log_; 178 BoundNetLog net_log_;
168 179
169 bool fetch_pac_bytes_; 180 bool fetch_pac_bytes_;
170 181
171 base::TimeDelta wait_delay_; 182 base::TimeDelta wait_delay_;
172 base::OneShotTimer<ProxyScriptDecider> wait_timer_; 183 base::OneShotTimer<ProxyScriptDecider> wait_timer_;
173 184
174 // Results. 185 // Results.
175 ProxyConfig effective_config_; 186 ProxyConfig effective_config_;
176 scoped_refptr<ProxyResolverScriptData> script_data_; 187 scoped_refptr<ProxyResolverScriptData> script_data_;
177 188
189 AddressList wpad_addresses_;
190 base::OneShotTimer<ProxyScriptDecider> quick_check_timer_;
191 scoped_ptr<SingleRequestHostResolver> host_resolver_;
192 base::Time quick_check_start_time_;
178 193
179 DISALLOW_COPY_AND_ASSIGN(ProxyScriptDecider); 194 DISALLOW_COPY_AND_ASSIGN(ProxyScriptDecider);
180 }; 195 };
181 196
182 } // namespace net 197 } // namespace net
183 198
184 #endif // NET_PROXY_PROXY_SCRIPT_DECIDER_H_ 199 #endif // NET_PROXY_PROXY_SCRIPT_DECIDER_H_
OLDNEW
« no previous file with comments | « net/dns/mock_host_resolver.cc ('k') | net/proxy/proxy_script_decider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698