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

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

Issue 2096293002: Eliminate usage of InterfacePtr::WaitForIncomingResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « mash/catalog_viewer/catalog_viewer.cc ('k') | services/catalog/public/interfaces/catalog.mojom » ('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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 case GetProxyForUrlAction::DROP: { 261 case GetProxyForUrlAction::DROP: {
262 client.reset(); 262 client.reset();
263 break; 263 break;
264 } 264 }
265 case GetProxyForUrlAction::DISCONNECT: { 265 case GetProxyForUrlAction::DISCONNECT: {
266 binding_.Close(); 266 binding_.Close();
267 break; 267 break;
268 } 268 }
269 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: { 269 case GetProxyForUrlAction::WAIT_FOR_CLIENT_DISCONNECT: {
270 ASSERT_FALSE(client.WaitForIncomingResponse()); 270 base::RunLoop run_loop;
271 client.set_connection_error_handler(run_loop.QuitClosure());
272 run_loop.Run();
273 ASSERT_TRUE(client.encountered_error());
leonhsl(Using Gerrit) 2016/06/27 11:03:16 I think InterfacePtr would detect the connection e
yzshen1 2016/06/29 21:36:20 Please look at base::MessageLoop::ScopedNestableTa
leonhsl(Using Gerrit) 2016/06/29 22:53:49 Yeah I noticed the multiple layers of base::RunLoo
leonhsl(Using Gerrit) 2016/07/01 08:53:50 Done.
271 break; 274 break;
272 } 275 }
273 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { 276 case GetProxyForUrlAction::MAKE_DNS_REQUEST: {
274 interfaces::HostResolverRequestInfoPtr request( 277 interfaces::HostResolverRequestInfoPtr request(
275 interfaces::HostResolverRequestInfo::New()); 278 interfaces::HostResolverRequestInfo::New());
276 request->host = url.spec(); 279 request->host = url.spec();
277 request->port = 12345; 280 request->port = 12345;
278 interfaces::HostResolverRequestClientPtr dns_client; 281 interfaces::HostResolverRequestClientPtr dns_client;
279 mojo::GetProxy(&dns_client); 282 mojo::GetProxy(&dns_client);
280 client->ResolveDns(std::move(request), std::move(dns_client)); 283 client->ResolveDns(std::move(request), std::move(dns_client));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 blocked_clients_.push_back( 426 blocked_clients_.push_back(
424 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr( 427 base::WrapUnique(new interfaces::ProxyResolverFactoryRequestClientPtr(
425 std::move(client)))); 428 std::move(client))));
426 break; 429 break;
427 } 430 }
428 case CreateProxyResolverAction::DROP_BOTH: { 431 case CreateProxyResolverAction::DROP_BOTH: {
429 // Both |request| and |client| will be closed. 432 // Both |request| and |client| will be closed.
430 break; 433 break;
431 } 434 }
432 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { 435 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: {
433 ASSERT_FALSE(client.WaitForIncomingResponse()); 436 base::RunLoop run_loop;
437 client.set_connection_error_handler(run_loop.QuitClosure());
438 run_loop.RunUntilIdle();
yzshen1 2016/06/29 21:36:20 Please note that RunUntilIdle is incorrect. The me
leonhsl(Using Gerrit) 2016/06/29 22:53:49 Understood.
leonhsl(Using Gerrit) 2016/07/01 08:53:50 Done.
439 ASSERT_TRUE(client.encountered_error());
434 break; 440 break;
435 } 441 }
436 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { 442 case CreateProxyResolverAction::MAKE_DNS_REQUEST: {
437 interfaces::HostResolverRequestInfoPtr request( 443 interfaces::HostResolverRequestInfoPtr request(
438 interfaces::HostResolverRequestInfo::New()); 444 interfaces::HostResolverRequestInfo::New());
439 request->host = pac_script; 445 request->host = pac_script;
440 request->port = 12345; 446 request->port = 12345;
441 interfaces::HostResolverRequestClientPtr dns_client; 447 interfaces::HostResolverRequestClientPtr dns_client;
442 mojo::GetProxy(&dns_client); 448 mojo::GetProxy(&dns_client);
443 client->ResolveDns(std::move(request), std::move(dns_client)); 449 client->ResolveDns(std::move(request), std::move(dns_client));
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 mock_proxy_resolver_.ClearBlockedClients(); 897 mock_proxy_resolver_.ClearBlockedClients();
892 request->WaitForResult(); 898 request->WaitForResult();
893 } 899 }
894 900
895 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { 901 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) {
896 CreateProxyResolver(); 902 CreateProxyResolver();
897 proxy_resolver_mojo_.reset(); 903 proxy_resolver_mojo_.reset();
898 on_delete_callback_.WaitForResult(); 904 on_delete_callback_.WaitForResult();
899 } 905 }
900 } // namespace net 906 } // namespace net
OLDNEW
« no previous file with comments | « mash/catalog_viewer/catalog_viewer.cc ('k') | services/catalog/public/interfaces/catalog.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698