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

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

Issue 1509513002: Remove ScopedVector from proxy_resolver_factory_mojo_unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | 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 <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 #include <vector>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "mojo/common/common_type_converters.h" 18 #include "mojo/common/common_type_converters.h"
19 #include "mojo/public/cpp/bindings/binding.h" 19 #include "mojo/public/cpp/bindings/binding.h"
20 #include "net/base/load_states.h" 20 #include "net/base/load_states.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 #include "net/base/test_completion_callback.h" 22 #include "net/base/test_completion_callback.h"
23 #include "net/dns/host_resolver.h" 23 #include "net/dns/host_resolver.h"
24 #include "net/log/test_net_log.h" 24 #include "net/log/test_net_log.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 interfaces::ProxyResolverRequestClientPtr client) override; 194 interfaces::ProxyResolverRequestClientPtr client) override;
195 195
196 void WakeWaiter(); 196 void WakeWaiter();
197 197
198 std::string pac_script_data_; 198 std::string pac_script_data_;
199 199
200 std::queue<GetProxyForUrlAction> get_proxy_actions_; 200 std::queue<GetProxyForUrlAction> get_proxy_actions_;
201 201
202 base::Closure quit_closure_; 202 base::Closure quit_closure_;
203 203
204 ScopedVector<interfaces::ProxyResolverRequestClientPtr> blocked_clients_; 204 std::vector<scoped_ptr<interfaces::ProxyResolverRequestClientPtr>>
205 blocked_clients_;
205 mojo::Binding<interfaces::ProxyResolver> binding_; 206 mojo::Binding<interfaces::ProxyResolver> binding_;
206 }; 207 };
207 208
208 MockMojoProxyResolver::~MockMojoProxyResolver() { 209 MockMojoProxyResolver::~MockMojoProxyResolver() {
209 EXPECT_TRUE(get_proxy_actions_.empty()) 210 EXPECT_TRUE(get_proxy_actions_.empty())
210 << "Actions remaining: " << get_proxy_actions_.size(); 211 << "Actions remaining: " << get_proxy_actions_.size();
211 } 212 }
212 213
213 MockMojoProxyResolver::MockMojoProxyResolver() : binding_(this) { 214 MockMojoProxyResolver::MockMojoProxyResolver() : binding_(this) {
214 } 215 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 break; 269 break;
269 } 270 }
270 case GetProxyForUrlAction::MAKE_DNS_REQUEST: { 271 case GetProxyForUrlAction::MAKE_DNS_REQUEST: {
271 interfaces::HostResolverRequestInfoPtr request( 272 interfaces::HostResolverRequestInfoPtr request(
272 interfaces::HostResolverRequestInfo::New()); 273 interfaces::HostResolverRequestInfo::New());
273 request->host = url; 274 request->host = url;
274 request->port = 12345; 275 request->port = 12345;
275 interfaces::HostResolverRequestClientPtr dns_client; 276 interfaces::HostResolverRequestClientPtr dns_client;
276 mojo::GetProxy(&dns_client); 277 mojo::GetProxy(&dns_client);
277 client->ResolveDns(request.Pass(), dns_client.Pass()); 278 client->ResolveDns(request.Pass(), dns_client.Pass());
278 blocked_clients_.push_back( 279 blocked_clients_.push_back(make_scoped_ptr(
279 new interfaces::ProxyResolverRequestClientPtr(client.Pass())); 280 new interfaces::ProxyResolverRequestClientPtr(std::move(client))));
280 break; 281 break;
281 } 282 }
282 } 283 }
283 WakeWaiter(); 284 WakeWaiter();
284 } 285 }
285 286
286 class Request { 287 class Request {
287 public: 288 public:
288 Request(ProxyResolver* resolver, const GURL& url); 289 Request(ProxyResolver* resolver, const GURL& url);
289 290
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 345 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
345 interfaces::ProxyResolverFactoryRequestClientPtr client) override; 346 interfaces::ProxyResolverFactoryRequestClientPtr client) override;
346 347
347 void WakeWaiter(); 348 void WakeWaiter();
348 349
349 MockMojoProxyResolver* resolver_; 350 MockMojoProxyResolver* resolver_;
350 std::queue<CreateProxyResolverAction> create_resolver_actions_; 351 std::queue<CreateProxyResolverAction> create_resolver_actions_;
351 352
352 base::Closure quit_closure_; 353 base::Closure quit_closure_;
353 354
354 ScopedVector<interfaces::ProxyResolverFactoryRequestClientPtr> 355 std::vector<scoped_ptr<interfaces::ProxyResolverFactoryRequestClientPtr>>
355 blocked_clients_; 356 blocked_clients_;
356 ScopedVector<mojo::InterfaceRequest<interfaces::ProxyResolver>> 357 std::vector<scoped_ptr<mojo::InterfaceRequest<interfaces::ProxyResolver>>>
357 blocked_resolver_requests_; 358 blocked_resolver_requests_;
358 mojo::Binding<interfaces::ProxyResolverFactory> binding_; 359 mojo::Binding<interfaces::ProxyResolverFactory> binding_;
359 }; 360 };
360 361
361 MockMojoProxyResolverFactory::MockMojoProxyResolverFactory( 362 MockMojoProxyResolverFactory::MockMojoProxyResolverFactory(
362 MockMojoProxyResolver* resolver, 363 MockMojoProxyResolver* resolver,
363 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> req) 364 mojo::InterfaceRequest<interfaces::ProxyResolverFactory> req)
364 : resolver_(resolver), binding_(this, req.Pass()) { 365 : resolver_(resolver), binding_(this, req.Pass()) {
365 } 366 }
366 367
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 switch (action.action) { 405 switch (action.action) {
405 case CreateProxyResolverAction::COMPLETE: { 406 case CreateProxyResolverAction::COMPLETE: {
406 if (action.error == OK) 407 if (action.error == OK)
407 resolver_->AddConnection(request.Pass()); 408 resolver_->AddConnection(request.Pass());
408 client->ReportResult(action.error); 409 client->ReportResult(action.error);
409 break; 410 break;
410 } 411 }
411 case CreateProxyResolverAction::DROP_CLIENT: { 412 case CreateProxyResolverAction::DROP_CLIENT: {
412 // Save |request| so its pipe isn't closed. 413 // Save |request| so its pipe isn't closed.
413 blocked_resolver_requests_.push_back( 414 blocked_resolver_requests_.push_back(
414 new mojo::InterfaceRequest<interfaces::ProxyResolver>( 415 make_scoped_ptr(new mojo::InterfaceRequest<interfaces::ProxyResolver>(
415 request.Pass())); 416 std::move(request))));
416 break; 417 break;
417 } 418 }
418 case CreateProxyResolverAction::DROP_RESOLVER: { 419 case CreateProxyResolverAction::DROP_RESOLVER: {
419 // Save |client| so its pipe isn't closed. 420 // Save |client| so its pipe isn't closed.
420 blocked_clients_.push_back( 421 blocked_clients_.push_back(
421 new interfaces::ProxyResolverFactoryRequestClientPtr(client.Pass())); 422 make_scoped_ptr(new interfaces::ProxyResolverFactoryRequestClientPtr(
423 std::move(client))));
422 break; 424 break;
423 } 425 }
424 case CreateProxyResolverAction::DROP_BOTH: { 426 case CreateProxyResolverAction::DROP_BOTH: {
425 // Both |request| and |client| will be closed. 427 // Both |request| and |client| will be closed.
426 break; 428 break;
427 } 429 }
428 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: { 430 case CreateProxyResolverAction::WAIT_FOR_CLIENT_DISCONNECT: {
429 ASSERT_FALSE(client.WaitForIncomingResponse()); 431 ASSERT_FALSE(client.WaitForIncomingResponse());
430 break; 432 break;
431 } 433 }
432 case CreateProxyResolverAction::MAKE_DNS_REQUEST: { 434 case CreateProxyResolverAction::MAKE_DNS_REQUEST: {
433 interfaces::HostResolverRequestInfoPtr request( 435 interfaces::HostResolverRequestInfoPtr request(
434 interfaces::HostResolverRequestInfo::New()); 436 interfaces::HostResolverRequestInfo::New());
435 request->host = pac_script; 437 request->host = pac_script;
436 request->port = 12345; 438 request->port = 12345;
437 interfaces::HostResolverRequestClientPtr dns_client; 439 interfaces::HostResolverRequestClientPtr dns_client;
438 mojo::GetProxy(&dns_client); 440 mojo::GetProxy(&dns_client);
439 client->ResolveDns(request.Pass(), dns_client.Pass()); 441 client->ResolveDns(request.Pass(), dns_client.Pass());
440 blocked_clients_.push_back( 442 blocked_clients_.push_back(
441 new interfaces::ProxyResolverFactoryRequestClientPtr(client.Pass())); 443 make_scoped_ptr(new interfaces::ProxyResolverFactoryRequestClientPtr(
eroman 2015/12/08 19:50:17 strictly speaking these changes from .Pass() --> s
444 std::move(client))));
442 break; 445 break;
443 } 446 }
444 } 447 }
445 WakeWaiter(); 448 WakeWaiter();
446 } 449 }
447 450
448 void DeleteResolverFactoryRequestCallback( 451 void DeleteResolverFactoryRequestCallback(
449 scoped_ptr<ProxyResolverFactory::Request>* request, 452 scoped_ptr<ProxyResolverFactory::Request>* request,
450 const CompletionCallback& callback, 453 const CompletionCallback& callback,
451 int result) { 454 int result) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 mock_proxy_resolver_.ClearBlockedClients(); 887 mock_proxy_resolver_.ClearBlockedClients();
885 request->WaitForResult(); 888 request->WaitForResult();
886 } 889 }
887 890
888 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { 891 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) {
889 CreateProxyResolver(); 892 CreateProxyResolver();
890 proxy_resolver_mojo_.reset(); 893 proxy_resolver_mojo_.reset();
891 on_delete_callback_.WaitForResult(); 894 on_delete_callback_.WaitForResult();
892 } 895 }
893 } // namespace net 896 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698