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 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 : public DhcpProxyScriptAdapterFetcher { | 150 : public DhcpProxyScriptAdapterFetcher { |
151 public: | 151 public: |
152 DelayingDhcpProxyScriptAdapterFetcher( | 152 DelayingDhcpProxyScriptAdapterFetcher( |
153 URLRequestContext* url_request_context, | 153 URLRequestContext* url_request_context, |
154 scoped_refptr<base::TaskRunner> task_runner) | 154 scoped_refptr<base::TaskRunner> task_runner) |
155 : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) { | 155 : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) { |
156 } | 156 } |
157 | 157 |
158 class DelayingDhcpQuery : public DhcpQuery { | 158 class DelayingDhcpQuery : public DhcpQuery { |
159 public: | 159 public: |
160 explicit DelayingDhcpQuery() | 160 explicit DelayingDhcpQuery() : DhcpQuery() {} |
161 : DhcpQuery() { | |
162 } | |
163 | 161 |
164 std::string ImplGetPacURLFromDhcp( | 162 std::string ImplGetPacURLFromDhcp( |
165 const std::string& adapter_name) override { | 163 const std::string& adapter_name) override { |
166 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); | 164 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); |
167 return DhcpQuery::ImplGetPacURLFromDhcp(adapter_name); | 165 return DhcpQuery::ImplGetPacURLFromDhcp(adapter_name); |
168 } | 166 } |
| 167 |
| 168 private: |
| 169 ~DelayingDhcpQuery() override {} |
169 }; | 170 }; |
170 | 171 |
171 DhcpQuery* ImplCreateDhcpQuery() override { | 172 DhcpQuery* ImplCreateDhcpQuery() override { |
172 return new DelayingDhcpQuery(); | 173 return new DelayingDhcpQuery(); |
173 } | 174 } |
174 }; | 175 }; |
175 | 176 |
176 // For RealFetchWithDeferredCancel, below. | 177 // For RealFetchWithDeferredCancel, below. |
177 class DelayingDhcpProxyScriptFetcherWin | 178 class DelayingDhcpProxyScriptFetcherWin |
178 : public DhcpProxyScriptFetcherWin { | 179 : public DhcpProxyScriptFetcherWin { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 base::OneShotTimer<DummyDhcpProxyScriptAdapterFetcher> timer_; | 263 base::OneShotTimer<DummyDhcpProxyScriptAdapterFetcher> timer_; |
263 }; | 264 }; |
264 | 265 |
265 class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { | 266 class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin { |
266 public: | 267 public: |
267 class MockAdapterQuery : public AdapterQuery { | 268 class MockAdapterQuery : public AdapterQuery { |
268 public: | 269 public: |
269 MockAdapterQuery() { | 270 MockAdapterQuery() { |
270 } | 271 } |
271 | 272 |
272 ~MockAdapterQuery() override {} | |
273 | |
274 bool ImplGetCandidateAdapterNames( | 273 bool ImplGetCandidateAdapterNames( |
275 std::set<std::string>* adapter_names) override { | 274 std::set<std::string>* adapter_names) override { |
276 adapter_names->insert( | 275 adapter_names->insert( |
277 mock_adapter_names_.begin(), mock_adapter_names_.end()); | 276 mock_adapter_names_.begin(), mock_adapter_names_.end()); |
278 return true; | 277 return true; |
279 } | 278 } |
280 | 279 |
281 std::vector<std::string> mock_adapter_names_; | 280 std::vector<std::string> mock_adapter_names_; |
| 281 |
| 282 private: |
| 283 ~MockAdapterQuery() override {} |
282 }; | 284 }; |
283 | 285 |
284 MockDhcpProxyScriptFetcherWin(URLRequestContext* context) | 286 MockDhcpProxyScriptFetcherWin(URLRequestContext* context) |
285 : DhcpProxyScriptFetcherWin(context), | 287 : DhcpProxyScriptFetcherWin(context), |
286 num_fetchers_created_(0), | 288 num_fetchers_created_(0), |
287 worker_finished_event_(true, false) { | 289 worker_finished_event_(true, false) { |
288 ResetTestState(); | 290 ResetTestState(); |
289 } | 291 } |
290 | 292 |
291 ~MockDhcpProxyScriptFetcherWin() override { ResetTestState(); } | 293 ~MockDhcpProxyScriptFetcherWin() override { ResetTestState(); } |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 639 } |
638 | 640 |
639 // Re-do the first test to make sure the last test that was run did | 641 // Re-do the first test to make sure the last test that was run did |
640 // not leave things in a bad state. | 642 // not leave things in a bad state. |
641 (*test_functions.begin())(&client); | 643 (*test_functions.begin())(&client); |
642 } | 644 } |
643 | 645 |
644 } // namespace | 646 } // namespace |
645 | 647 |
646 } // namespace net | 648 } // namespace net |
OLD | NEW |