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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 State state() const; | 114 State state() const; |
115 | 115 |
116 // This inner class encapsulates work done on a worker pool thread. | 116 // This inner class encapsulates work done on a worker pool thread. |
117 // By using a separate object, we can keep the main object completely | 117 // By using a separate object, we can keep the main object completely |
118 // thread safe and let it be non-refcounted. | 118 // thread safe and let it be non-refcounted. |
119 class NET_EXPORT_PRIVATE DhcpQuery | 119 class NET_EXPORT_PRIVATE DhcpQuery |
120 : public base::RefCountedThreadSafe<DhcpQuery> { | 120 : public base::RefCountedThreadSafe<DhcpQuery> { |
121 public: | 121 public: |
122 DhcpQuery(); | 122 DhcpQuery(); |
123 virtual ~DhcpQuery(); | |
124 | 123 |
125 // This method should run on a worker pool thread, via PostTaskAndReply. | 124 // This method should run on a worker pool thread, via PostTaskAndReply. |
126 // After it has run, the |url()| method on this object will return the | 125 // After it has run, the |url()| method on this object will return the |
127 // URL retrieved. | 126 // URL retrieved. |
128 void GetPacURLForAdapter(const std::string& adapter_name); | 127 void GetPacURLForAdapter(const std::string& adapter_name); |
129 | 128 |
130 // Returns the URL retrieved for the given adapter, once the task has run. | 129 // Returns the URL retrieved for the given adapter, once the task has run. |
131 const std::string& url() const; | 130 const std::string& url() const; |
132 | 131 |
133 protected: | 132 protected: |
134 // Virtual method introduced to allow unit testing. | 133 // Virtual method introduced to allow unit testing. |
135 virtual std::string ImplGetPacURLFromDhcp(const std::string& adapter_name); | 134 virtual std::string ImplGetPacURLFromDhcp(const std::string& adapter_name); |
136 | 135 |
| 136 friend class base::RefCountedThreadSafe<DhcpQuery>; |
| 137 virtual ~DhcpQuery(); |
| 138 |
137 private: | 139 private: |
138 // The URL retrieved for the given adapter. | 140 // The URL retrieved for the given adapter. |
139 std::string url_; | 141 std::string url_; |
140 | 142 |
141 DISALLOW_COPY_AND_ASSIGN(DhcpQuery); | 143 DISALLOW_COPY_AND_ASSIGN(DhcpQuery); |
142 }; | 144 }; |
143 | 145 |
144 // Virtual methods introduced to allow unit testing. | 146 // Virtual methods introduced to allow unit testing. |
145 virtual ProxyScriptFetcher* ImplCreateScriptFetcher(); | 147 virtual ProxyScriptFetcher* ImplCreateScriptFetcher(); |
146 virtual DhcpQuery* ImplCreateDhcpQuery(); | 148 virtual DhcpQuery* ImplCreateDhcpQuery(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 base::OneShotTimer<DhcpProxyScriptAdapterFetcher> wait_timer_; | 181 base::OneShotTimer<DhcpProxyScriptAdapterFetcher> wait_timer_; |
180 | 182 |
181 URLRequestContext* const url_request_context_; | 183 URLRequestContext* const url_request_context_; |
182 | 184 |
183 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); | 185 DISALLOW_IMPLICIT_CONSTRUCTORS(DhcpProxyScriptAdapterFetcher); |
184 }; | 186 }; |
185 | 187 |
186 } // namespace net | 188 } // namespace net |
187 | 189 |
188 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ | 190 #endif // NET_PROXY_DHCP_PROXY_SCRIPT_ADAPTER_FETCHER_WIN_H_ |
OLD | NEW |