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

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

Issue 2259823002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.cc ('k') | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/proxy_resolver_factory_mojo.h" 5 #include "net/proxy/proxy_resolver_factory_mojo.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 break; 283 break;
284 } 284 }
285 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { 285 case GetProxyForUrlAction::MAKE_DNS_REQUEST: {
286 interfaces::HostResolverRequestInfoPtr request( 286 interfaces::HostResolverRequestInfoPtr request(
287 interfaces::HostResolverRequestInfo::New()); 287 interfaces::HostResolverRequestInfo::New());
288 request->host = url.spec(); 288 request->host = url.spec();
289 request->port = 12345; 289 request->port = 12345;
290 interfaces::HostResolverRequestClientPtr dns_client; 290 interfaces::HostResolverRequestClientPtr dns_client;
291 mojo::GetProxy(&dns_client); 291 mojo::GetProxy(&dns_client);
292 client->ResolveDns(std::move(request), std::move(dns_client)); 292 client->ResolveDns(std::move(request), std::move(dns_client));
293 blocked_clients_.push_back(base::WrapUnique( 293 blocked_clients_.push_back(
294 new interfaces::ProxyResolverRequestClientPtr(std::move(client)))); 294 base::MakeUnique<interfaces::ProxyResolverRequestClientPtr>(
295 std::move(client)));
295 break; 296 break;
296 } 297 }
297 } 298 }
298 WakeWaiter(); 299 WakeWaiter();
299 } 300 }
300 301
301 class Request { 302 class Request {
302 public: 303 public:
303 Request(ProxyResolver* resolver, const GURL& url); 304 Request(ProxyResolver* resolver, const GURL& url);
304 305
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 client->OnError(12345, pac_script); 419 client->OnError(12345, pac_script);
419 switch (action.action) { 420 switch (action.action) {
420 case CreateProxyResolverAction::COMPLETE: { 421 case CreateProxyResolverAction::COMPLETE: {
421 if (action.error == OK) 422 if (action.error == OK)
422 resolver_->AddConnection(std::move(request)); 423 resolver_->AddConnection(std::move(request));
423 client->ReportResult(action.error); 424 client->ReportResult(action.error);
424 break; 425 break;
425 } 426 }
426 case CreateProxyResolverAction::DROP_CLIENT: { 427 case CreateProxyResolverAction::DROP_CLIENT: {
427 // Save |request| so its pipe isn't closed. 428 // Save |request| so its pipe isn't closed.
428 blocked_resolver_requests_.push_back(base::WrapUnique( 429 blocked_resolver_requests_.push_back(
429 new mojo::InterfaceRequest<interfaces::ProxyResolver>( 430 base::MakeUnique<mojo::InterfaceRequest<interfaces::ProxyResolver>>(
430 std::move(request)))); 431 std::move(request)));
431 break; 432 break;
432 } 433 }
433 case CreateProxyResolverAction::DROP_RESOLVER: { 434 case CreateProxyResolverAction::DROP_RESOLVER: {
434 // Save |client| so its pipe isn't closed. 435 // Save |client| so its pipe isn't closed.
435 blocked_clients_.push_back( 436 blocked_clients_.push_back(
436 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr( 437 base::MakeUnique<interfaces::ProxyResolverFactoryRequestClientPtr>(
437 std::move(client)))); 438 std::move(client)));
438 break; 439 break;
439 } 440 }
440 case CreateProxyResolverAction::DROP_BOTH: { 441 case CreateProxyResolverAction::DROP_BOTH: {
441 // Both |request| and |client| will be closed. 442 // Both |request| and |client| will be closed.
442 break; 443 break;
443 } 444 }
444 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { 445 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: {
445 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( 446 base::MessageLoop::ScopedNestableTaskAllower nestable_allower(
446 base::MessageLoop::current()); 447 base::MessageLoop::current());
447 base::RunLoop run_loop; 448 base::RunLoop run_loop;
448 client.set_connection_error_handler(run_loop.QuitClosure()); 449 client.set_connection_error_handler(run_loop.QuitClosure());
449 run_loop.Run(); 450 run_loop.Run();
450 ASSERT_TRUE(client.encountered_error()); 451 ASSERT_TRUE(client.encountered_error());
451 break; 452 break;
452 } 453 }
453 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { 454 case CreateProxyResolverAction::MAKE_DNS_REQUEST: {
454 interfaces::HostResolverRequestInfoPtr request( 455 interfaces::HostResolverRequestInfoPtr request(
455 interfaces::HostResolverRequestInfo::New()); 456 interfaces::HostResolverRequestInfo::New());
456 request->host = pac_script; 457 request->host = pac_script;
457 request->port = 12345; 458 request->port = 12345;
458 interfaces::HostResolverRequestClientPtr dns_client; 459 interfaces::HostResolverRequestClientPtr dns_client;
459 mojo::GetProxy(&dns_client); 460 mojo::GetProxy(&dns_client);
460 client->ResolveDns(std::move(request), std::move(dns_client)); 461 client->ResolveDns(std::move(request), std::move(dns_client));
461 blocked_clients_.push_back( 462 blocked_clients_.push_back(
462 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr( 463 base::MakeUnique<interfaces::ProxyResolverFactoryRequestClientPtr>(
463 std::move(client)))); 464 std::move(client)));
464 break; 465 break;
465 } 466 }
466 } 467 }
467 WakeWaiter(); 468 WakeWaiter();
468 } 469 }
469 470
470 void DeleteResolverFactoryRequestCallback( 471 void DeleteResolverFactoryRequestCallback(
471 std::unique_ptr<ProxyResolverFactory::Request>* request, 472 std::unique_ptr<ProxyResolverFactory::Request>* request,
472 const CompletionCallback& callback, 473 const CompletionCallback& callback,
473 int result) { 474 int result) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 void SetUp() override { 534 void SetUp() override {
534 mock_proxy_resolver_factory_.reset(new MockMojoProxyResolverFactory( 535 mock_proxy_resolver_factory_.reset(new MockMojoProxyResolverFactory(
535 &mock_proxy_resolver_, mojo::GetProxy(&factory_ptr_))); 536 &mock_proxy_resolver_, mojo::GetProxy(&factory_ptr_)));
536 proxy_resolver_factory_mojo_.reset(new ProxyResolverFactoryMojo( 537 proxy_resolver_factory_mojo_.reset(new ProxyResolverFactoryMojo(
537 this, &host_resolver_, 538 this, &host_resolver_,
538 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(), 539 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(),
539 &net_log_)); 540 &net_log_));
540 } 541 }
541 542
542 std::unique_ptr<Request> MakeRequest(const GURL& url) { 543 std::unique_ptr<Request> MakeRequest(const GURL& url) {
543 return base::WrapUnique(new Request(proxy_resolver_mojo_.get(), url)); 544 return base::MakeUnique<Request>(proxy_resolver_mojo_.get(), url);
544 } 545 }
545 546
546 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( 547 std::unique_ptr<base::ScopedClosureRunner> CreateResolver(
547 const mojo::String& pac_script, 548 const mojo::String& pac_script,
548 mojo::InterfaceRequest<interfaces::ProxyResolver> req, 549 mojo::InterfaceRequest<interfaces::ProxyResolver> req,
549 interfaces::ProxyResolverFactoryRequestClientPtr client) override { 550 interfaces::ProxyResolverFactoryRequestClientPtr client) override {
550 factory_ptr_->CreateResolver(pac_script, std::move(req), std::move(client)); 551 factory_ptr_->CreateResolver(pac_script, std::move(req), std::move(client));
551 return base::WrapUnique( 552 return base::MakeUnique<base::ScopedClosureRunner>(
552 new base::ScopedClosureRunner(on_delete_callback_.closure())); 553 on_delete_callback_.closure());
553 } 554 }
554 555
555 mojo::Array<interfaces::ProxyServerPtr> ProxyServersFromPacString( 556 mojo::Array<interfaces::ProxyServerPtr> ProxyServersFromPacString(
556 const std::string& pac_string) { 557 const std::string& pac_string) {
557 ProxyInfo proxy_info; 558 ProxyInfo proxy_info;
558 proxy_info.UsePacString(pac_string); 559 proxy_info.UsePacString(pac_string);
559 560
560 return mojo::Array<interfaces::ProxyServerPtr>::From( 561 return mojo::Array<interfaces::ProxyServerPtr>::From(
561 proxy_info.proxy_list().GetAll()); 562 proxy_info.proxy_list().GetAll());
562 } 563 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 mock_proxy_resolver_.ClearBlockedClients(); 910 mock_proxy_resolver_.ClearBlockedClients();
910 request->WaitForResult(); 911 request->WaitForResult();
911 } 912 }
912 913
913 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { 914 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) {
914 CreateProxyResolver(); 915 CreateProxyResolver();
915 proxy_resolver_mojo_.reset(); 916 proxy_resolver_mojo_.reset();
916 on_delete_callback_.WaitForResult(); 917 on_delete_callback_.WaitForResult();
917 } 918 }
918 } // namespace net 919 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.cc ('k') | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698