Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) { 162 : DhcpProxyScriptAdapterFetcher(url_request_context, task_runner) {
163 } 163 }
164 164
165 class DelayingDhcpQuery : public DhcpQuery { 165 class DelayingDhcpQuery : public DhcpQuery {
166 public: 166 public:
167 explicit DelayingDhcpQuery() 167 explicit DelayingDhcpQuery()
168 : DhcpQuery() { 168 : DhcpQuery() {
169 } 169 }
170 170
171 std::string ImplGetPacURLFromDhcp( 171 std::string ImplGetPacURLFromDhcp(
172 const std::string& adapter_name) OVERRIDE { 172 const std::string& adapter_name) override {
173 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); 173 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
174 return DhcpQuery::ImplGetPacURLFromDhcp(adapter_name); 174 return DhcpQuery::ImplGetPacURLFromDhcp(adapter_name);
175 } 175 }
176 }; 176 };
177 177
178 DhcpQuery* ImplCreateDhcpQuery() OVERRIDE { 178 DhcpQuery* ImplCreateDhcpQuery() override {
179 return new DelayingDhcpQuery(); 179 return new DelayingDhcpQuery();
180 } 180 }
181 }; 181 };
182 182
183 // For RealFetchWithDeferredCancel, below. 183 // For RealFetchWithDeferredCancel, below.
184 class DelayingDhcpProxyScriptFetcherWin 184 class DelayingDhcpProxyScriptFetcherWin
185 : public DhcpProxyScriptFetcherWin { 185 : public DhcpProxyScriptFetcherWin {
186 public: 186 public:
187 explicit DelayingDhcpProxyScriptFetcherWin( 187 explicit DelayingDhcpProxyScriptFetcherWin(
188 URLRequestContext* context) 188 URLRequestContext* context)
189 : DhcpProxyScriptFetcherWin(context) { 189 : DhcpProxyScriptFetcherWin(context) {
190 } 190 }
191 191
192 DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() OVERRIDE { 192 DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() override {
193 return new DelayingDhcpProxyScriptAdapterFetcher(url_request_context(), 193 return new DelayingDhcpProxyScriptAdapterFetcher(url_request_context(),
194 GetTaskRunner()); 194 GetTaskRunner());
195 } 195 }
196 }; 196 };
197 197
198 TEST(DhcpProxyScriptFetcherWin, RealFetchWithDeferredCancel) { 198 TEST(DhcpProxyScriptFetcherWin, RealFetchWithDeferredCancel) {
199 // Does a Fetch() with a slightly delayed cancel. As before, just 199 // Does a Fetch() with a slightly delayed cancel. As before, just
200 // exercises the code without stubbing out dependencies, but 200 // exercises the code without stubbing out dependencies, but
201 // introduces a guaranteed 20 ms delay on the worker threads so that 201 // introduces a guaranteed 20 ms delay on the worker threads so that
202 // the cancel is called before they complete. 202 // the cancel is called before they complete.
(...skipping 14 matching lines...) Expand all
217 DummyDhcpProxyScriptAdapterFetcher(URLRequestContext* context, 217 DummyDhcpProxyScriptAdapterFetcher(URLRequestContext* context,
218 scoped_refptr<base::TaskRunner> runner) 218 scoped_refptr<base::TaskRunner> runner)
219 : DhcpProxyScriptAdapterFetcher(context, runner), 219 : DhcpProxyScriptAdapterFetcher(context, runner),
220 did_finish_(false), 220 did_finish_(false),
221 result_(OK), 221 result_(OK),
222 pac_script_(L"bingo"), 222 pac_script_(L"bingo"),
223 fetch_delay_ms_(1) { 223 fetch_delay_ms_(1) {
224 } 224 }
225 225
226 void Fetch(const std::string& adapter_name, 226 void Fetch(const std::string& adapter_name,
227 const CompletionCallback& callback) OVERRIDE { 227 const CompletionCallback& callback) override {
228 callback_ = callback; 228 callback_ = callback;
229 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_), 229 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(fetch_delay_ms_),
230 this, &DummyDhcpProxyScriptAdapterFetcher::OnTimer); 230 this, &DummyDhcpProxyScriptAdapterFetcher::OnTimer);
231 } 231 }
232 232
233 void Cancel() OVERRIDE { 233 void Cancel() override {
234 timer_.Stop(); 234 timer_.Stop();
235 } 235 }
236 236
237 bool DidFinish() const OVERRIDE { 237 bool DidFinish() const override {
238 return did_finish_; 238 return did_finish_;
239 } 239 }
240 240
241 int GetResult() const OVERRIDE { 241 int GetResult() const override {
242 return result_; 242 return result_;
243 } 243 }
244 244
245 base::string16 GetPacScript() const OVERRIDE { 245 base::string16 GetPacScript() const override {
246 return pac_script_; 246 return pac_script_;
247 } 247 }
248 248
249 void OnTimer() { 249 void OnTimer() {
250 callback_.Run(result_); 250 callback_.Run(result_);
251 } 251 }
252 252
253 void Configure(bool did_finish, 253 void Configure(bool did_finish,
254 int result, 254 int result,
255 base::string16 pac_script, 255 base::string16 pac_script,
(...skipping 17 matching lines...) Expand all
273 public: 273 public:
274 class MockAdapterQuery : public AdapterQuery { 274 class MockAdapterQuery : public AdapterQuery {
275 public: 275 public:
276 MockAdapterQuery() { 276 MockAdapterQuery() {
277 } 277 }
278 278
279 virtual ~MockAdapterQuery() { 279 virtual ~MockAdapterQuery() {
280 } 280 }
281 281
282 virtual bool ImplGetCandidateAdapterNames( 282 virtual bool ImplGetCandidateAdapterNames(
283 std::set<std::string>* adapter_names) OVERRIDE { 283 std::set<std::string>* adapter_names) override {
284 adapter_names->insert( 284 adapter_names->insert(
285 mock_adapter_names_.begin(), mock_adapter_names_.end()); 285 mock_adapter_names_.begin(), mock_adapter_names_.end());
286 return true; 286 return true;
287 } 287 }
288 288
289 std::vector<std::string> mock_adapter_names_; 289 std::vector<std::string> mock_adapter_names_;
290 }; 290 };
291 291
292 MockDhcpProxyScriptFetcherWin(URLRequestContext* context) 292 MockDhcpProxyScriptFetcherWin(URLRequestContext* context)
293 : DhcpProxyScriptFetcherWin(context), 293 : DhcpProxyScriptFetcherWin(context),
(...skipping 23 matching lines...) Expand all
317 base::string16 pac_script, 317 base::string16 pac_script,
318 base::TimeDelta fetch_delay) { 318 base::TimeDelta fetch_delay) {
319 scoped_ptr<DummyDhcpProxyScriptAdapterFetcher> adapter_fetcher( 319 scoped_ptr<DummyDhcpProxyScriptAdapterFetcher> adapter_fetcher(
320 new DummyDhcpProxyScriptAdapterFetcher(url_request_context(), 320 new DummyDhcpProxyScriptAdapterFetcher(url_request_context(),
321 GetTaskRunner())); 321 GetTaskRunner()));
322 adapter_fetcher->Configure( 322 adapter_fetcher->Configure(
323 did_finish, result, pac_script, fetch_delay.InMilliseconds()); 323 did_finish, result, pac_script, fetch_delay.InMilliseconds());
324 PushBackAdapter(adapter_name, adapter_fetcher.release()); 324 PushBackAdapter(adapter_name, adapter_fetcher.release());
325 } 325 }
326 326
327 DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() OVERRIDE { 327 DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() override {
328 ++num_fetchers_created_; 328 ++num_fetchers_created_;
329 return adapter_fetchers_[next_adapter_fetcher_index_++]; 329 return adapter_fetchers_[next_adapter_fetcher_index_++];
330 } 330 }
331 331
332 virtual AdapterQuery* ImplCreateAdapterQuery() OVERRIDE { 332 virtual AdapterQuery* ImplCreateAdapterQuery() override {
333 DCHECK(adapter_query_); 333 DCHECK(adapter_query_);
334 return adapter_query_.get(); 334 return adapter_query_.get();
335 } 335 }
336 336
337 base::TimeDelta ImplGetMaxWait() OVERRIDE { 337 base::TimeDelta ImplGetMaxWait() override {
338 return max_wait_; 338 return max_wait_;
339 } 339 }
340 340
341 void ImplOnGetCandidateAdapterNamesDone() OVERRIDE { 341 void ImplOnGetCandidateAdapterNamesDone() override {
342 worker_finished_event_.Signal(); 342 worker_finished_event_.Signal();
343 } 343 }
344 344
345 void ResetTestState() { 345 void ResetTestState() {
346 // Delete any adapter fetcher objects we didn't hand out. 346 // Delete any adapter fetcher objects we didn't hand out.
347 std::vector<DhcpProxyScriptAdapterFetcher*>::const_iterator it 347 std::vector<DhcpProxyScriptAdapterFetcher*>::const_iterator it
348 = adapter_fetchers_.begin(); 348 = adapter_fetchers_.begin();
349 for (; it != adapter_fetchers_.end(); ++it) { 349 for (; it != adapter_fetchers_.end(); ++it) {
350 if (num_fetchers_created_-- <= 0) { 350 if (num_fetchers_created_-- <= 0) {
351 delete (*it); 351 delete (*it);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 647 }
648 648
649 // Re-do the first test to make sure the last test that was run did 649 // Re-do the first test to make sure the last test that was run did
650 // not leave things in a bad state. 650 // not leave things in a bad state.
651 (*test_functions.begin())(&client); 651 (*test_functions.begin())(&client);
652 } 652 }
653 653
654 } // namespace 654 } // namespace
655 655
656 } // namespace net 656 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698