| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 19 #include "base/values.h" | 20 #include "base/values.h" |
| 20 #include "mojo/common/common_type_converters.h" | 21 #include "mojo/common/common_type_converters.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "net/base/load_states.h" | 23 #include "net/base/load_states.h" |
| 23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 24 #include "net/base/test_completion_callback.h" | 25 #include "net/base/test_completion_callback.h" |
| 25 #include "net/dns/host_resolver.h" | 26 #include "net/dns/host_resolver.h" |
| 26 #include "net/log/test_net_log.h" | 27 #include "net/log/test_net_log.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 266 } |
| 266 case GetProxyForUrlAction::DROP: { | 267 case GetProxyForUrlAction::DROP: { |
| 267 client.reset(); | 268 client.reset(); |
| 268 break; | 269 break; |
| 269 } | 270 } |
| 270 case GetProxyForUrlAction::DISCONNECT: { | 271 case GetProxyForUrlAction::DISCONNECT: { |
| 271 binding_.Close(); | 272 binding_.Close(); |
| 272 break; | 273 break; |
| 273 } | 274 } |
| 274 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: { | 275 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: { |
| 275 ASSERT_FALSE(client.WaitForIncomingResponse()); | 276 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( |
| 277 base::MessageLoop::current()); |
| 278 base::RunLoop run_loop; |
| 279 client.set_connection_error_handler(run_loop.QuitClosure()); |
| 280 run_loop.Run(); |
| 281 ASSERT_TRUE(client.encountered_error()); |
| 276 break; | 282 break; |
| 277 } | 283 } |
| 278 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { | 284 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { |
| 279 interfaces::HostResolverRequestInfoPtr request( | 285 interfaces::HostResolverRequestInfoPtr request( |
| 280 interfaces::HostResolverRequestInfo::New()); | 286 interfaces::HostResolverRequestInfo::New()); |
| 281 request->host = url.spec(); | 287 request->host = url.spec(); |
| 282 request->port = 12345; | 288 request->port = 12345; |
| 283 interfaces::HostResolverRequestClientPtr dns_client; | 289 interfaces::HostResolverRequestClientPtr dns_client; |
| 284 mojo::GetProxy(&dns_client); | 290 mojo::GetProxy(&dns_client); |
| 285 client->ResolveDns(std::move(request), std::move(dns_client)); | 291 client->ResolveDns(std::move(request), std::move(dns_client)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 blocked_clients_.push_back( | 434 blocked_clients_.push_back( |
| 429 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr( | 435 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr( |
| 430 std::move(client)))); | 436 std::move(client)))); |
| 431 break; | 437 break; |
| 432 } | 438 } |
| 433 case CreateProxyResolverAction::DROP_BOTH: { | 439 case CreateProxyResolverAction::DROP_BOTH: { |
| 434 // Both |request| and |client| will be closed. | 440 // Both |request| and |client| will be closed. |
| 435 break; | 441 break; |
| 436 } | 442 } |
| 437 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { | 443 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { |
| 438 ASSERT_FALSE(client.WaitForIncomingResponse()); | 444 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( |
| 445 base::MessageLoop::current()); |
| 446 base::RunLoop run_loop; |
| 447 client.set_connection_error_handler(run_loop.QuitClosure()); |
| 448 run_loop.Run(); |
| 449 ASSERT_TRUE(client.encountered_error()); |
| 439 break; | 450 break; |
| 440 } | 451 } |
| 441 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { | 452 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { |
| 442 interfaces::HostResolverRequestInfoPtr request( | 453 interfaces::HostResolverRequestInfoPtr request( |
| 443 interfaces::HostResolverRequestInfo::New()); | 454 interfaces::HostResolverRequestInfo::New()); |
| 444 request->host = pac_script; | 455 request->host = pac_script; |
| 445 request->port = 12345; | 456 request->port = 12345; |
| 446 interfaces::HostResolverRequestClientPtr dns_client; | 457 interfaces::HostResolverRequestClientPtr dns_client; |
| 447 mojo::GetProxy(&dns_client); | 458 mojo::GetProxy(&dns_client); |
| 448 client->ResolveDns(std::move(request), std::move(dns_client)); | 459 client->ResolveDns(std::move(request), std::move(dns_client)); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 mock_proxy_resolver_.ClearBlockedClients(); | 907 mock_proxy_resolver_.ClearBlockedClients(); |
| 897 request->WaitForResult(); | 908 request->WaitForResult(); |
| 898 } | 909 } |
| 899 | 910 |
| 900 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { | 911 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { |
| 901 CreateProxyResolver(); | 912 CreateProxyResolver(); |
| 902 proxy_resolver_mojo_.reset(); | 913 proxy_resolver_mojo_.reset(); |
| 903 on_delete_callback_.WaitForResult(); | 914 on_delete_callback_.WaitForResult(); |
| 904 } | 915 } |
| 905 } // namespace net | 916 } // namespace net |
| OLD | NEW |