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_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 5 #ifndef NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
6 #define NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 6 #define NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class TaskRunner; | 24 class TaskRunner; |
25 } | 25 } |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 | 28 |
29 class ProxyScriptFetcher; | 29 class ProxyScriptFetcher; |
30 class URLRequestContext; | 30 class URLRequestContext; |
31 | 31 |
32 // For a given adapter, this class takes care of first doing a DHCP lookup | 32 // For a given adapter, this class takes care of first doing a DHCP lookup |
33 // to get the PAC URL, then if there is one, trying to fetch it. | 33 // to get the PAC URL, then if there is one, trying to fetch it. |
34 class NET_EXPORT_PRIVATE DhcpProxyScriptAdapterFetcher | 34 class NET_EXPORT_PRIVATE DhcpProxyScriptAdapterFetcher |
35 : public base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher>, | 35 : public base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher> { |
36 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
37 public: | 36 public: |
38 // |url_request_context| must outlive DhcpProxyScriptAdapterFetcher. | 37 // |url_request_context| must outlive DhcpProxyScriptAdapterFetcher. |
39 // |task_runner| will be used to post tasks to a thread. | 38 // |task_runner| will be used to post tasks to a thread. |
40 DhcpProxyScriptAdapterFetcher(URLRequestContext* url_request_context, | 39 DhcpProxyScriptAdapterFetcher(URLRequestContext* url_request_context, |
41 scoped_refptr<base::TaskRunner> task_runner); | 40 scoped_refptr<base::TaskRunner> task_runner); |
42 virtual ~DhcpProxyScriptAdapterFetcher(); | 41 virtual ~DhcpProxyScriptAdapterFetcher(); |
43 | 42 |
44 // Starts a fetch. On completion (but not cancellation), |callback| | 43 // Starts a fetch. On completion (but not cancellation), |callback| |
45 // will be invoked with the network error indicating success or failure | 44 // will be invoked with the network error indicating success or failure |
46 // of fetching a DHCP-configured PAC file on this adapter. | 45 // of fetching a DHCP-configured PAC file on this adapter. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 CompletionCallback callback_; | 177 CompletionCallback callback_; |
179 | 178 |
180 // Fetcher to retrieve PAC files once URL is known. | 179 // Fetcher to retrieve PAC files once URL is known. |
181 std::unique_ptr<ProxyScriptFetcher> script_fetcher_; | 180 std::unique_ptr<ProxyScriptFetcher> script_fetcher_; |
182 | 181 |
183 // Implements a timeout on the call to the Win32 DHCP API. | 182 // Implements a timeout on the call to the Win32 DHCP API. |
184 base::OneShotTimer wait_timer_; | 183 base::OneShotTimer wait_timer_; |
185 | 184 |
186 URLRequestContext* const url_request_context_; | 185 URLRequestContext* const url_request_context_; |
187 | 186 |
| 187 THREAD_CHECKER(thread_checker_); |
| 188 |
188 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); | 189 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); |
189 }; | 190 }; |
190 | 191 |
191 } // namespace net | 192 } // namespace net |
192 | 193 |
193 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 194 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
OLD | NEW |