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_SERVICE_H_ | 5 #ifndef NET_PROXY_PROXY_SERVICE_H_ |
6 #define NET_PROXY_PROXY_SERVICE_H_ | 6 #define NET_PROXY_PROXY_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/load_states.h" | 17 #include "net/base/load_states.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
20 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
21 #include "net/proxy/proxy_config_service.h" | 21 #include "net/proxy/proxy_config_service.h" |
22 #include "net/proxy/proxy_info.h" | 22 #include "net/proxy/proxy_info.h" |
23 #include "net/proxy/proxy_server.h" | 23 #include "net/proxy/proxy_server.h" |
24 | 24 |
25 class GURL; | 25 class GURL; |
26 class MessageLoop; | |
27 | 26 |
28 namespace base { | 27 namespace base { |
| 28 class MessageLoop; |
29 class SingleThreadTaskRunner; | 29 class SingleThreadTaskRunner; |
30 } // namespace base | 30 } // namespace base |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 | 33 |
34 class DhcpProxyScriptFetcher; | 34 class DhcpProxyScriptFetcher; |
35 class HostResolver; | 35 class HostResolver; |
36 class NetworkDelegate; | 36 class NetworkDelegate; |
37 class ProxyResolver; | 37 class ProxyResolver; |
38 class ProxyResolverScriptData; | 38 class ProxyResolverScriptData; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // hardcoded proxy fallback list (|pac_string|) for every URL. | 234 // hardcoded proxy fallback list (|pac_string|) for every URL. |
235 // | 235 // |
236 // |pac_string| is a list of proxy servers, in the format that a PAC script | 236 // |pac_string| is a list of proxy servers, in the format that a PAC script |
237 // would return it. For example, "PROXY foobar:99; SOCKS fml:2; DIRECT" | 237 // would return it. For example, "PROXY foobar:99; SOCKS fml:2; DIRECT" |
238 static ProxyService* CreateFixedFromPacResult(const std::string& pac_string); | 238 static ProxyService* CreateFixedFromPacResult(const std::string& pac_string); |
239 | 239 |
240 // Creates a config service appropriate for this platform that fetches the | 240 // Creates a config service appropriate for this platform that fetches the |
241 // system proxy settings. | 241 // system proxy settings. |
242 static ProxyConfigService* CreateSystemProxyConfigService( | 242 static ProxyConfigService* CreateSystemProxyConfigService( |
243 base::SingleThreadTaskRunner* io_thread_task_runner, | 243 base::SingleThreadTaskRunner* io_thread_task_runner, |
244 MessageLoop* file_loop); | 244 base::MessageLoop* file_loop); |
245 | 245 |
246 // This method should only be used by unit tests. | 246 // This method should only be used by unit tests. |
247 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { | 247 void set_stall_proxy_auto_config_delay(base::TimeDelta delay) { |
248 stall_proxy_auto_config_delay_ = delay; | 248 stall_proxy_auto_config_delay_ = delay; |
249 } | 249 } |
250 | 250 |
251 // This method should only be used by unit tests. Returns the previously | 251 // This method should only be used by unit tests. Returns the previously |
252 // active policy. | 252 // active policy. |
253 static const PacPollPolicy* set_pac_script_poll_policy( | 253 static const PacPollPolicy* set_pac_script_poll_policy( |
254 const PacPollPolicy* policy); | 254 const PacPollPolicy* policy); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // The amount of time to stall requests following IP address changes. | 400 // The amount of time to stall requests following IP address changes. |
401 base::TimeDelta stall_proxy_auto_config_delay_; | 401 base::TimeDelta stall_proxy_auto_config_delay_; |
402 | 402 |
403 DISALLOW_COPY_AND_ASSIGN(ProxyService); | 403 DISALLOW_COPY_AND_ASSIGN(ProxyService); |
404 }; | 404 }; |
405 | 405 |
406 // Wrapper for invoking methods on a ProxyService synchronously. | 406 // Wrapper for invoking methods on a ProxyService synchronously. |
407 class NET_EXPORT SyncProxyServiceHelper | 407 class NET_EXPORT SyncProxyServiceHelper |
408 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { | 408 : public base::RefCountedThreadSafe<SyncProxyServiceHelper> { |
409 public: | 409 public: |
410 SyncProxyServiceHelper(MessageLoop* io_message_loop, | 410 SyncProxyServiceHelper(base::MessageLoop* io_message_loop, |
411 ProxyService* proxy_service); | 411 ProxyService* proxy_service); |
412 | 412 |
413 int ResolveProxy(const GURL& url, | 413 int ResolveProxy(const GURL& url, |
414 ProxyInfo* proxy_info, | 414 ProxyInfo* proxy_info, |
415 const BoundNetLog& net_log); | 415 const BoundNetLog& net_log); |
416 int ReconsiderProxyAfterError(const GURL& url, | 416 int ReconsiderProxyAfterError(const GURL& url, |
417 ProxyInfo* proxy_info, | 417 ProxyInfo* proxy_info, |
418 const BoundNetLog& net_log); | 418 const BoundNetLog& net_log); |
419 | 419 |
420 private: | 420 private: |
421 friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>; | 421 friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>; |
422 | 422 |
423 virtual ~SyncProxyServiceHelper(); | 423 virtual ~SyncProxyServiceHelper(); |
424 | 424 |
425 void StartAsyncResolve(const GURL& url, const BoundNetLog& net_log); | 425 void StartAsyncResolve(const GURL& url, const BoundNetLog& net_log); |
426 void StartAsyncReconsider(const GURL& url, const BoundNetLog& net_log); | 426 void StartAsyncReconsider(const GURL& url, const BoundNetLog& net_log); |
427 | 427 |
428 void OnCompletion(int result); | 428 void OnCompletion(int result); |
429 | 429 |
430 MessageLoop* io_message_loop_; | 430 base::MessageLoop* io_message_loop_; |
431 ProxyService* proxy_service_; | 431 ProxyService* proxy_service_; |
432 | 432 |
433 base::WaitableEvent event_; | 433 base::WaitableEvent event_; |
434 CompletionCallback callback_; | 434 CompletionCallback callback_; |
435 ProxyInfo proxy_info_; | 435 ProxyInfo proxy_info_; |
436 int result_; | 436 int result_; |
437 }; | 437 }; |
438 | 438 |
439 } // namespace net | 439 } // namespace net |
440 | 440 |
441 #endif // NET_PROXY_PROXY_SERVICE_H_ | 441 #endif // NET_PROXY_PROXY_SERVICE_H_ |
OLD | NEW |