OLD | NEW |
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_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 5 #ifndef NET_PROXY_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
6 #define NET_PROXY_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 6 #define NET_PROXY_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class MessageLoopProxy; | 20 class MessageLoopProxy; |
21 } | 21 } |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 class ProxyScriptFetcher; | 25 class ProxyScriptFetcher; |
26 class URLRequestContext; | 26 class URLRequestContext; |
27 | 27 |
28 // For a given adapter, this class takes care of first doing a DHCP lookup | 28 // For a given adapter, this class takes care of first doing a DHCP lookup |
29 // to get the PAC URL, then if there is one, trying to fetch it. | 29 // to get the PAC URL, then if there is one, trying to fetch it. |
30 class NET_TEST DhcpProxyScriptAdapterFetcher | 30 class NET_EXPORT_PRIVATE DhcpProxyScriptAdapterFetcher |
31 : public base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher>, | 31 : public base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher>, |
32 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 32 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
33 public: | 33 public: |
34 // |url_request_context| must outlive DhcpProxyScriptAdapterFetcher. | 34 // |url_request_context| must outlive DhcpProxyScriptAdapterFetcher. |
35 explicit DhcpProxyScriptAdapterFetcher( | 35 explicit DhcpProxyScriptAdapterFetcher( |
36 URLRequestContext* url_request_context); | 36 URLRequestContext* url_request_context); |
37 virtual ~DhcpProxyScriptAdapterFetcher(); | 37 virtual ~DhcpProxyScriptAdapterFetcher(); |
38 | 38 |
39 // Starts a fetch. On completion (but not cancellation), |callback| | 39 // Starts a fetch. On completion (but not cancellation), |callback| |
40 // will be invoked with the network error indicating success or failure | 40 // will be invoked with the network error indicating success or failure |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 State state() const; | 108 State state() const; |
109 | 109 |
110 // This inner class is used to encapsulate the worker thread, which has | 110 // This inner class is used to encapsulate the worker thread, which has |
111 // only a weak reference back to the main object, so that the main object | 111 // only a weak reference back to the main object, so that the main object |
112 // can be destroyed before the thread ends. This also keeps the main | 112 // can be destroyed before the thread ends. This also keeps the main |
113 // object completely thread safe and allows it to be non-refcounted. | 113 // object completely thread safe and allows it to be non-refcounted. |
114 // | 114 // |
115 // TODO(joi): Replace with PostTaskAndReply once http://crbug.com/86301 | 115 // TODO(joi): Replace with PostTaskAndReply once http://crbug.com/86301 |
116 // has been implemented. | 116 // has been implemented. |
117 class NET_TEST WorkerThread | 117 class NET_EXPORT_PRIVATE WorkerThread |
118 : public base::RefCountedThreadSafe<WorkerThread> { | 118 : public base::RefCountedThreadSafe<WorkerThread> { |
119 public: | 119 public: |
120 // Creates and initializes (but does not start) the worker thread. | 120 // Creates and initializes (but does not start) the worker thread. |
121 explicit WorkerThread( | 121 explicit WorkerThread( |
122 const base::WeakPtr<DhcpProxyScriptAdapterFetcher>& owner); | 122 const base::WeakPtr<DhcpProxyScriptAdapterFetcher>& owner); |
123 virtual ~WorkerThread(); | 123 virtual ~WorkerThread(); |
124 | 124 |
125 // Starts the worker thread, fetching information for |adapter_name| using | 125 // Starts the worker thread, fetching information for |adapter_name| using |
126 // |get_pac_from_url_func|. | 126 // |get_pac_from_url_func|. |
127 void Start(const std::string& adapter_name); | 127 void Start(const std::string& adapter_name); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 base::OneShotTimer<DhcpProxyScriptAdapterFetcher> wait_timer_; | 197 base::OneShotTimer<DhcpProxyScriptAdapterFetcher> wait_timer_; |
198 | 198 |
199 scoped_refptr<URLRequestContext> url_request_context_; | 199 scoped_refptr<URLRequestContext> url_request_context_; |
200 | 200 |
201 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); | 201 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); |
202 }; | 202 }; |
203 | 203 |
204 } // namespace net | 204 } // namespace net |
205 | 205 |
206 #endif // NET_PROXY_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 206 #endif // NET_PROXY_DHCP_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
OLD | NEW |