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_PROXY_SCRIPT_FETCHER_WIN_H_ | 5 #ifndef NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_WIN_H_ |
6 #define NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_WIN_H_ | 6 #define NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "base/time.h" |
15 #include "base/timer.h" | 16 #include "base/timer.h" |
16 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 17 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class DhcpProxyScriptAdapterFetcher; | 21 class DhcpProxyScriptAdapterFetcher; |
21 class URLRequestContext; | 22 class URLRequestContext; |
22 | 23 |
23 // Windows-specific implementation. | 24 // Windows-specific implementation. |
24 class DhcpProxyScriptFetcherWin | 25 class DhcpProxyScriptFetcherWin |
(...skipping 12 matching lines...) Expand all Loading... |
37 const GURL& GetPacURL() const OVERRIDE; | 38 const GURL& GetPacURL() const OVERRIDE; |
38 std::string GetFetcherName() const OVERRIDE; | 39 std::string GetFetcherName() const OVERRIDE; |
39 | 40 |
40 // Sets |adapter_names| to contain the name of each network adapter on | 41 // Sets |adapter_names| to contain the name of each network adapter on |
41 // this machine that has DHCP enabled and is not a loop-back adapter. Returns | 42 // this machine that has DHCP enabled and is not a loop-back adapter. Returns |
42 // false on error. | 43 // false on error. |
43 static bool GetCandidateAdapterNames(std::set<std::string>* adapter_names); | 44 static bool GetCandidateAdapterNames(std::set<std::string>* adapter_names); |
44 | 45 |
45 protected: | 46 protected: |
46 // Event/state transition handlers | 47 // Event/state transition handlers |
| 48 void CancelImpl(bool user_initiated); |
47 void OnFetcherDone(int result); | 49 void OnFetcherDone(int result); |
48 void OnWaitTimer(); | 50 void OnWaitTimer(); |
49 void TransitionToDone(); | 51 void TransitionToDone(); |
50 | 52 |
51 // Virtual methods introduced to allow unit testing. | 53 // Virtual methods introduced to allow unit testing. |
52 virtual DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher(); | 54 virtual DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher(); |
53 virtual bool ImplGetCandidateAdapterNames( | 55 virtual bool ImplGetCandidateAdapterNames( |
54 std::set<std::string>* adapter_names); | 56 std::set<std::string>* adapter_names); |
55 virtual int ImplGetMaxWaitMs(); | 57 virtual int ImplGetMaxWaitMs(); |
56 | 58 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 108 |
107 // Pointer to string we will write results to. Not valid in states | 109 // Pointer to string we will write results to. Not valid in states |
108 // START and DONE. | 110 // START and DONE. |
109 string16* destination_string_; | 111 string16* destination_string_; |
110 | 112 |
111 // PAC URL retrieved from DHCP, if any. Valid only in state STATE_DONE. | 113 // PAC URL retrieved from DHCP, if any. Valid only in state STATE_DONE. |
112 GURL pac_url_; | 114 GURL pac_url_; |
113 | 115 |
114 base::OneShotTimer<DhcpProxyScriptFetcherWin> wait_timer_; | 116 base::OneShotTimer<DhcpProxyScriptFetcherWin> wait_timer_; |
115 | 117 |
| 118 // Time |Fetch()| was last called, 0 if never. |
| 119 base::TimeTicks fetch_start_time_; |
| 120 |
116 scoped_refptr<URLRequestContext> url_request_context_; | 121 scoped_refptr<URLRequestContext> url_request_context_; |
117 | 122 |
118 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptFetcherWin); | 123 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptFetcherWin); |
119 }; | 124 }; |
120 | 125 |
121 } // namespace net | 126 } // namespace net |
122 | 127 |
123 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_WIN_H_ | 128 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_FETCHER_WIN_H_ |
OLD | NEW |