| OLD | NEW |
| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 base::RunLoop run_loop; | 272 base::RunLoop run_loop; |
| 273 client.set_connection_error_handler(run_loop.QuitClosure()); | 273 client.set_connection_error_handler(run_loop.QuitClosure()); |
| 274 run_loop.Run(); | 274 run_loop.Run(); |
| 275 ASSERT_TRUE(client.encountered_error()); | 275 ASSERT_TRUE(client.encountered_error()); |
| 276 break; | 276 break; |
| 277 } | 277 } |
| 278 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { | 278 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { |
| 279 auto request = base::MakeUnique<HostResolver::RequestInfo>( | 279 auto request = base::MakeUnique<HostResolver::RequestInfo>( |
| 280 HostPortPair(url.spec(), 12345)); | 280 HostPortPair(url.spec(), 12345)); |
| 281 interfaces::HostResolverRequestClientPtr dns_client; | 281 interfaces::HostResolverRequestClientPtr dns_client; |
| 282 mojo::GetProxy(&dns_client); | 282 mojo::MakeRequest(&dns_client); |
| 283 client->ResolveDns(std::move(request), std::move(dns_client)); | 283 client->ResolveDns(std::move(request), std::move(dns_client)); |
| 284 blocked_clients_.push_back( | 284 blocked_clients_.push_back( |
| 285 base::MakeUnique<interfaces::ProxyResolverRequestClientPtr>( | 285 base::MakeUnique<interfaces::ProxyResolverRequestClientPtr>( |
| 286 std::move(client))); | 286 std::move(client))); |
| 287 break; | 287 break; |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 WakeWaiter(); | 290 WakeWaiter(); |
| 291 } | 291 } |
| 292 | 292 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 base::RunLoop run_loop; | 440 base::RunLoop run_loop; |
| 441 client.set_connection_error_handler(run_loop.QuitClosure()); | 441 client.set_connection_error_handler(run_loop.QuitClosure()); |
| 442 run_loop.Run(); | 442 run_loop.Run(); |
| 443 ASSERT_TRUE(client.encountered_error()); | 443 ASSERT_TRUE(client.encountered_error()); |
| 444 break; | 444 break; |
| 445 } | 445 } |
| 446 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { | 446 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { |
| 447 auto request = base::MakeUnique<HostResolver::RequestInfo>( | 447 auto request = base::MakeUnique<HostResolver::RequestInfo>( |
| 448 HostPortPair(pac_script, 12345)); | 448 HostPortPair(pac_script, 12345)); |
| 449 interfaces::HostResolverRequestClientPtr dns_client; | 449 interfaces::HostResolverRequestClientPtr dns_client; |
| 450 mojo::GetProxy(&dns_client); | 450 mojo::MakeRequest(&dns_client); |
| 451 client->ResolveDns(std::move(request), std::move(dns_client)); | 451 client->ResolveDns(std::move(request), std::move(dns_client)); |
| 452 blocked_clients_.push_back( | 452 blocked_clients_.push_back( |
| 453 base::MakeUnique<interfaces::ProxyResolverFactoryRequestClientPtr>( | 453 base::MakeUnique<interfaces::ProxyResolverFactoryRequestClientPtr>( |
| 454 std::move(client))); | 454 std::move(client))); |
| 455 break; | 455 break; |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 WakeWaiter(); | 458 WakeWaiter(); |
| 459 } | 459 } |
| 460 | 460 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 EXPECT_EQ(12345, line_number); | 516 EXPECT_EQ(12345, line_number); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace | 519 } // namespace |
| 520 | 520 |
| 521 class ProxyResolverFactoryMojoTest : public testing::Test, | 521 class ProxyResolverFactoryMojoTest : public testing::Test, |
| 522 public MojoProxyResolverFactory { | 522 public MojoProxyResolverFactory { |
| 523 public: | 523 public: |
| 524 void SetUp() override { | 524 void SetUp() override { |
| 525 mock_proxy_resolver_factory_.reset(new MockMojoProxyResolverFactory( | 525 mock_proxy_resolver_factory_.reset(new MockMojoProxyResolverFactory( |
| 526 &mock_proxy_resolver_, mojo::GetProxy(&factory_ptr_))); | 526 &mock_proxy_resolver_, mojo::MakeRequest(&factory_ptr_))); |
| 527 proxy_resolver_factory_mojo_.reset(new ProxyResolverFactoryMojo( | 527 proxy_resolver_factory_mojo_.reset(new ProxyResolverFactoryMojo( |
| 528 this, &host_resolver_, | 528 this, &host_resolver_, |
| 529 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(), | 529 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(), |
| 530 &net_log_)); | 530 &net_log_)); |
| 531 } | 531 } |
| 532 | 532 |
| 533 std::unique_ptr<Request> MakeRequest(const GURL& url) { | 533 std::unique_ptr<Request> MakeRequest(const GURL& url) { |
| 534 return base::MakeUnique<Request>(proxy_resolver_mojo_.get(), url); | 534 return base::MakeUnique<Request>(proxy_resolver_mojo_.get(), url); |
| 535 } | 535 } |
| 536 | 536 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 mock_proxy_resolver_.ClearBlockedClients(); | 898 mock_proxy_resolver_.ClearBlockedClients(); |
| 899 request->WaitForResult(); | 899 request->WaitForResult(); |
| 900 } | 900 } |
| 901 | 901 |
| 902 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { | 902 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { |
| 903 CreateProxyResolver(); | 903 CreateProxyResolver(); |
| 904 proxy_resolver_mojo_.reset(); | 904 proxy_resolver_mojo_.reset(); |
| 905 on_delete_callback_.WaitForResult(); | 905 on_delete_callback_.WaitForResult(); |
| 906 } | 906 } |
| 907 } // namespace net | 907 } // namespace net |
| OLD | NEW |