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

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

Issue 9078003: Poll PAC scripts for content changes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix dcheck reached on bot Created 8 years, 11 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_resolver_script_data.cc ('k') | net/proxy/proxy_service.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) 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 NET_PROXY_PROXY_SERVICE_H_ 5 #ifndef NET_PROXY_PROXY_SERVICE_H_
6 #define NET_PROXY_PROXY_SERVICE_H_ 6 #define NET_PROXY_PROXY_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 14 matching lines...) Expand all
25 25
26 class GURL; 26 class GURL;
27 class MessageLoop; 27 class MessageLoop;
28 28
29 namespace net { 29 namespace net {
30 30
31 class DhcpProxyScriptFetcher; 31 class DhcpProxyScriptFetcher;
32 class HostResolver; 32 class HostResolver;
33 class NetworkDelegate; 33 class NetworkDelegate;
34 class ProxyResolver; 34 class ProxyResolver;
35 class ProxyResolverScriptData;
35 class ProxyScriptDecider; 36 class ProxyScriptDecider;
36 class ProxyScriptFetcher; 37 class ProxyScriptFetcher;
37 38
38 // This class can be used to resolve the proxy server to use when loading a 39 // This class can be used to resolve the proxy server to use when loading a
39 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy 40 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy
40 // resolution. See ProxyResolverV8 for example. 41 // resolution. See ProxyResolverV8 for example.
41 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, 42 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
42 public ProxyConfigService::Observer, 43 public ProxyConfigService::Observer,
43 NON_EXPORTED_BASE(public base::NonThreadSafe) { 44 NON_EXPORTED_BASE(public base::NonThreadSafe) {
44 public: 45 public:
46 // Only used by unit-tests.
47 enum PollPolicy {
48 POLL_POLICY_REGULAR, // Normal PAC poll policy (retry periodically).
49 POLL_POLICY_NEVER, // Don't re-fetch PAC scripts for changes.
50 POLL_POLICY_IMMEDIATE, // Check every 1 ms.
51 };
52
45 // The instance takes ownership of |config_service| and |resolver|. 53 // The instance takes ownership of |config_service| and |resolver|.
46 // |net_log| is a possibly NULL destination to send log events to. It must 54 // |net_log| is a possibly NULL destination to send log events to. It must
47 // remain alive for the lifetime of this ProxyService. 55 // remain alive for the lifetime of this ProxyService.
48 ProxyService(ProxyConfigService* config_service, 56 ProxyService(ProxyConfigService* config_service,
49 ProxyResolver* resolver, 57 ProxyResolver* resolver,
50 NetLog* net_log); 58 NetLog* net_log);
51 59
52 virtual ~ProxyService(); 60 virtual ~ProxyService();
53 61
54 // Used internally to handle PAC queries. 62 // Used internally to handle PAC queries.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // Creates a config service appropriate for this platform that fetches the 237 // Creates a config service appropriate for this platform that fetches the
230 // system proxy settings. 238 // system proxy settings.
231 static ProxyConfigService* CreateSystemProxyConfigService( 239 static ProxyConfigService* CreateSystemProxyConfigService(
232 MessageLoop* io_loop, MessageLoop* file_loop); 240 MessageLoop* io_loop, MessageLoop* file_loop);
233 241
234 // This method should only be used by unit tests. 242 // This method should only be used by unit tests.
235 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { 243 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) {
236 stall_proxy_auto_config_delay_ = delay; 244 stall_proxy_auto_config_delay_ = delay;
237 } 245 }
238 246
247 // This method should only be used by unit tests. Returns the previously
248 // active policy.
249 static PollPolicy set_pac_script_poll_policy(PollPolicy policy);
250
239 private: 251 private:
240 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); 252 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect);
241 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); 253 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect);
242 friend class PacRequest; 254 friend class PacRequest;
243 class InitProxyResolver; 255 class InitProxyResolver;
256 class ProxyScriptDeciderPoller;
244 257
245 // TODO(eroman): change this to a std::set. Note that this requires updating 258 // TODO(eroman): change this to a std::set. Note that this requires updating
246 // some tests in proxy_service_unittest.cc such as: 259 // some tests in proxy_service_unittest.cc such as:
247 // ProxyServiceTest.InitialPACScriptDownload 260 // ProxyServiceTest.InitialPACScriptDownload
248 // which expects requests to finish in the order they were added. 261 // which expects requests to finish in the order they were added.
249 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; 262 typedef std::vector<scoped_refptr<PacRequest> > PendingRequests;
250 263
251 enum State { 264 enum State {
252 STATE_NONE, 265 STATE_NONE,
253 STATE_WAITING_FOR_PROXY_CONFIG, 266 STATE_WAITING_FOR_PROXY_CONFIG,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // Called when proxy resolution has completed (either synchronously or 306 // Called when proxy resolution has completed (either synchronously or
294 // asynchronously). Handles logging the result, and cleaning out 307 // asynchronously). Handles logging the result, and cleaning out
295 // bad entries from the results list. 308 // bad entries from the results list.
296 int DidFinishResolvingProxy(ProxyInfo* result, 309 int DidFinishResolvingProxy(ProxyInfo* result,
297 int result_code, 310 int result_code,
298 const BoundNetLog& net_log); 311 const BoundNetLog& net_log);
299 312
300 // Start initialization using |fetched_config_|. 313 // Start initialization using |fetched_config_|.
301 void InitializeUsingLastFetchedConfig(); 314 void InitializeUsingLastFetchedConfig();
302 315
316 // Start the initialization skipping past the "decision" phase.
317 void InitializeUsingDecidedConfig(
318 int decider_result,
319 ProxyResolverScriptData* script_data,
320 const ProxyConfig& effective_config);
321
303 // NetworkChangeNotifier::IPAddressObserver 322 // NetworkChangeNotifier::IPAddressObserver
304 // When this is called, we re-fetch PAC scripts and re-run WPAD. 323 // When this is called, we re-fetch PAC scripts and re-run WPAD.
305 virtual void OnIPAddressChanged() OVERRIDE; 324 virtual void OnIPAddressChanged() OVERRIDE;
306 325
307 // ProxyConfigService::Observer 326 // ProxyConfigService::Observer
308 virtual void OnProxyConfigChanged( 327 virtual void OnProxyConfigChanged(
309 const ProxyConfig& config, 328 const ProxyConfig& config,
310 ProxyConfigService::ConfigAvailability availability) OVERRIDE; 329 ProxyConfigService::ConfigAvailability availability) OVERRIDE;
311 330
312 scoped_ptr<ProxyConfigService> config_service_; 331 scoped_ptr<ProxyConfigService> config_service_;
(...skipping 28 matching lines...) Expand all
341 // script configured in DHCP, if any. Can be NULL if the ProxyResolver has 360 // script configured in DHCP, if any. Can be NULL if the ProxyResolver has
342 // no need for DHCP PAC script fetching. 361 // no need for DHCP PAC script fetching.
343 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher_; 362 scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher_;
344 363
345 // Helper to download the PAC script (wpad + custom) and apply fallback rules. 364 // Helper to download the PAC script (wpad + custom) and apply fallback rules.
346 // 365 //
347 // Note that the declaration is important here: |proxy_script_fetcher_| and 366 // Note that the declaration is important here: |proxy_script_fetcher_| and
348 // |proxy_resolver_| must outlive |init_proxy_resolver_|. 367 // |proxy_resolver_| must outlive |init_proxy_resolver_|.
349 scoped_ptr<InitProxyResolver> init_proxy_resolver_; 368 scoped_ptr<InitProxyResolver> init_proxy_resolver_;
350 369
370 // Helper to poll the PAC script for changes.
371 scoped_ptr<ProxyScriptDeciderPoller> script_poller_;
372
351 State current_state_; 373 State current_state_;
352 374
353 // Either OK or an ERR_* value indicating that a permanent error (e.g. 375 // Either OK or an ERR_* value indicating that a permanent error (e.g.
354 // failed to fetch the PAC script) prevents proxy resolution. 376 // failed to fetch the PAC script) prevents proxy resolution.
355 int permanent_error_; 377 int permanent_error_;
356 378
357 // This is the log where any events generated by |init_proxy_resolver_| are 379 // This is the log where any events generated by |init_proxy_resolver_| are
358 // sent to. 380 // sent to.
359 NetLog* net_log_; 381 NetLog* net_log_;
360 382
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 419
398 base::WaitableEvent event_; 420 base::WaitableEvent event_;
399 CompletionCallback callback_; 421 CompletionCallback callback_;
400 ProxyInfo proxy_info_; 422 ProxyInfo proxy_info_;
401 int result_; 423 int result_;
402 }; 424 };
403 425
404 } // namespace net 426 } // namespace net
405 427
406 #endif // NET_PROXY_PROXY_SERVICE_H_ 428 #endif // NET_PROXY_PROXY_SERVICE_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_script_data.cc ('k') | net/proxy/proxy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698