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

Side by Side Diff: net/proxy/proxy_service.cc

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/proxy/proxy_service.h ('k') | net/proxy/proxy_service_unittest.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 #include "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // In Firefox the PAC URL is re-tried on failures according to 112 // In Firefox the PAC URL is re-tried on failures according to
113 // network.proxy.autoconfig_retry_interval_min and 113 // network.proxy.autoconfig_retry_interval_min and
114 // network.proxy.autoconfig_retry_interval_max. The defaults are 5 seconds and 114 // network.proxy.autoconfig_retry_interval_max. The defaults are 5 seconds and
115 // 5 minutes respectively. It doubles the interval at each attempt. 115 // 5 minutes respectively. It doubles the interval at each attempt.
116 // 116 //
117 // TODO(eroman): Figure out what Internet Explorer does. 117 // TODO(eroman): Figure out what Internet Explorer does.
118 class DefaultPollPolicy : public ProxyService::PacPollPolicy { 118 class DefaultPollPolicy : public ProxyService::PacPollPolicy {
119 public: 119 public:
120 DefaultPollPolicy() {} 120 DefaultPollPolicy() {}
121 121
122 virtual Mode GetNextDelay(int initial_error, 122 Mode GetNextDelay(int initial_error,
123 TimeDelta current_delay, 123 TimeDelta current_delay,
124 TimeDelta* next_delay) const override { 124 TimeDelta* next_delay) const override {
125 if (initial_error != OK) { 125 if (initial_error != OK) {
126 // Re-try policy for failures. 126 // Re-try policy for failures.
127 const int kDelay1Seconds = 8; 127 const int kDelay1Seconds = 8;
128 const int kDelay2Seconds = 32; 128 const int kDelay2Seconds = 32;
129 const int kDelay3Seconds = 2 * 60; // 2 minutes 129 const int kDelay3Seconds = 2 * 60; // 2 minutes
130 const int kDelay4Seconds = 4 * 60 * 60; // 4 Hours 130 const int kDelay4Seconds = 4 * 60 * 60; // 4 Hours
131 131
132 // Initial poll. 132 // Initial poll.
133 if (current_delay < TimeDelta()) { 133 if (current_delay < TimeDelta()) {
134 *next_delay = TimeDelta::FromSeconds(kDelay1Seconds); 134 *next_delay = TimeDelta::FromSeconds(kDelay1Seconds);
(...skipping 18 matching lines...) Expand all
153 } 153 }
154 154
155 private: 155 private:
156 DISALLOW_COPY_AND_ASSIGN(DefaultPollPolicy); 156 DISALLOW_COPY_AND_ASSIGN(DefaultPollPolicy);
157 }; 157 };
158 158
159 // Config getter that always returns direct settings. 159 // Config getter that always returns direct settings.
160 class ProxyConfigServiceDirect : public ProxyConfigService { 160 class ProxyConfigServiceDirect : public ProxyConfigService {
161 public: 161 public:
162 // ProxyConfigService implementation: 162 // ProxyConfigService implementation:
163 virtual void AddObserver(Observer* observer) override {} 163 void AddObserver(Observer* observer) override {}
164 virtual void RemoveObserver(Observer* observer) override {} 164 void RemoveObserver(Observer* observer) override {}
165 virtual ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) 165 ConfigAvailability GetLatestProxyConfig(ProxyConfig* config) override {
166 override {
167 *config = ProxyConfig::CreateDirect(); 166 *config = ProxyConfig::CreateDirect();
168 config->set_source(PROXY_CONFIG_SOURCE_UNKNOWN); 167 config->set_source(PROXY_CONFIG_SOURCE_UNKNOWN);
169 return CONFIG_VALID; 168 return CONFIG_VALID;
170 } 169 }
171 }; 170 };
172 171
173 // Proxy resolver that fails every time. 172 // Proxy resolver that fails every time.
174 class ProxyResolverNull : public ProxyResolver { 173 class ProxyResolverNull : public ProxyResolver {
175 public: 174 public:
176 ProxyResolverNull() : ProxyResolver(false /*expects_pac_bytes*/) {} 175 ProxyResolverNull() : ProxyResolver(false /*expects_pac_bytes*/) {}
177 176
178 // ProxyResolver implementation. 177 // ProxyResolver implementation.
179 virtual int GetProxyForURL(const GURL& url, 178 int GetProxyForURL(const GURL& url,
180 ProxyInfo* results, 179 ProxyInfo* results,
181 const CompletionCallback& callback, 180 const CompletionCallback& callback,
182 RequestHandle* request, 181 RequestHandle* request,
183 const BoundNetLog& net_log) override { 182 const BoundNetLog& net_log) override {
184 return ERR_NOT_IMPLEMENTED; 183 return ERR_NOT_IMPLEMENTED;
185 } 184 }
186 185
187 virtual void CancelRequest(RequestHandle request) override { 186 void CancelRequest(RequestHandle request) override { NOTREACHED(); }
188 NOTREACHED();
189 }
190 187
191 virtual LoadState GetLoadState(RequestHandle request) const override { 188 LoadState GetLoadState(RequestHandle request) const override {
192 NOTREACHED(); 189 NOTREACHED();
193 return LOAD_STATE_IDLE; 190 return LOAD_STATE_IDLE;
194 } 191 }
195 192
196 virtual void CancelSetPacScript() override { 193 void CancelSetPacScript() override { NOTREACHED(); }
197 NOTREACHED();
198 }
199 194
200 virtual int SetPacScript( 195 int SetPacScript(
201 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/, 196 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/,
202 const CompletionCallback& /*callback*/) override { 197 const CompletionCallback& /*callback*/) override {
203 return ERR_NOT_IMPLEMENTED; 198 return ERR_NOT_IMPLEMENTED;
204 } 199 }
205 }; 200 };
206 201
207 // ProxyResolver that simulates a PAC script which returns 202 // ProxyResolver that simulates a PAC script which returns
208 // |pac_string| for every single URL. 203 // |pac_string| for every single URL.
209 class ProxyResolverFromPacString : public ProxyResolver { 204 class ProxyResolverFromPacString : public ProxyResolver {
210 public: 205 public:
211 explicit ProxyResolverFromPacString(const std::string& pac_string) 206 explicit ProxyResolverFromPacString(const std::string& pac_string)
212 : ProxyResolver(false /*expects_pac_bytes*/), 207 : ProxyResolver(false /*expects_pac_bytes*/),
213 pac_string_(pac_string) {} 208 pac_string_(pac_string) {}
214 209
215 virtual int GetProxyForURL(const GURL& url, 210 int GetProxyForURL(const GURL& url,
216 ProxyInfo* results, 211 ProxyInfo* results,
217 const CompletionCallback& callback, 212 const CompletionCallback& callback,
218 RequestHandle* request, 213 RequestHandle* request,
219 const BoundNetLog& net_log) override { 214 const BoundNetLog& net_log) override {
220 results->UsePacString(pac_string_); 215 results->UsePacString(pac_string_);
221 return OK; 216 return OK;
222 } 217 }
223 218
224 virtual void CancelRequest(RequestHandle request) override { 219 void CancelRequest(RequestHandle request) override { NOTREACHED(); }
225 NOTREACHED();
226 }
227 220
228 virtual LoadState GetLoadState(RequestHandle request) const override { 221 LoadState GetLoadState(RequestHandle request) const override {
229 NOTREACHED(); 222 NOTREACHED();
230 return LOAD_STATE_IDLE; 223 return LOAD_STATE_IDLE;
231 } 224 }
232 225
233 virtual void CancelSetPacScript() override { 226 void CancelSetPacScript() override { NOTREACHED(); }
234 NOTREACHED();
235 }
236 227
237 virtual int SetPacScript( 228 int SetPacScript(const scoped_refptr<ProxyResolverScriptData>& pac_script,
238 const scoped_refptr<ProxyResolverScriptData>& pac_script, 229 const CompletionCallback& callback) override {
239 const CompletionCallback& callback) override {
240 return OK; 230 return OK;
241 } 231 }
242 232
243 private: 233 private:
244 const std::string pac_string_; 234 const std::string pac_string_;
245 }; 235 };
246 236
247 // Creates ProxyResolvers using a platform-specific implementation. 237 // Creates ProxyResolvers using a platform-specific implementation.
248 class ProxyResolverFactoryForSystem : public ProxyResolverFactory { 238 class ProxyResolverFactoryForSystem : public ProxyResolverFactory {
249 public: 239 public:
250 ProxyResolverFactoryForSystem() 240 ProxyResolverFactoryForSystem()
251 : ProxyResolverFactory(false /*expects_pac_bytes*/) {} 241 : ProxyResolverFactory(false /*expects_pac_bytes*/) {}
252 242
253 virtual ProxyResolver* CreateProxyResolver() override { 243 ProxyResolver* CreateProxyResolver() override {
254 DCHECK(IsSupported()); 244 DCHECK(IsSupported());
255 #if defined(OS_WIN) 245 #if defined(OS_WIN)
256 return new ProxyResolverWinHttp(); 246 return new ProxyResolverWinHttp();
257 #elif defined(OS_MACOSX) 247 #elif defined(OS_MACOSX)
258 return new ProxyResolverMac(); 248 return new ProxyResolverMac();
259 #else 249 #else
260 NOTREACHED(); 250 NOTREACHED();
261 return NULL; 251 return NULL;
262 #endif 252 #endif
263 } 253 }
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 State previous_state = ResetProxyConfig(false); 1581 State previous_state = ResetProxyConfig(false);
1592 if (previous_state != STATE_NONE) 1582 if (previous_state != STATE_NONE)
1593 ApplyProxyConfigIfAvailable(); 1583 ApplyProxyConfigIfAvailable();
1594 } 1584 }
1595 1585
1596 void ProxyService::OnDNSChanged() { 1586 void ProxyService::OnDNSChanged() {
1597 OnIPAddressChanged(); 1587 OnIPAddressChanged();
1598 } 1588 }
1599 1589
1600 } // namespace net 1590 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698