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

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

Issue 2416483002: Use std::string instead of mojo::String in //net. (Closed)
Patch Set: Created 4 years, 2 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/proxy_resolver_factory_mojo.cc ('k') | net/proxy/proxy_service_mojo_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>
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/message_loop/message_loop.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "mojo/common/common_type_converters.h"
22 #include "mojo/public/cpp/bindings/binding.h" 21 #include "mojo/public/cpp/bindings/binding.h"
23 #include "net/base/load_states.h" 22 #include "net/base/load_states.h"
24 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
25 #include "net/base/test_completion_callback.h" 24 #include "net/base/test_completion_callback.h"
26 #include "net/dns/host_resolver.h" 25 #include "net/dns/host_resolver.h"
27 #include "net/log/net_log_event_type.h" 26 #include "net/log/net_log_event_type.h"
28 #include "net/log/net_log_with_source.h" 27 #include "net/log/net_log_with_source.h"
29 #include "net/log/test_net_log.h" 28 #include "net/log/test_net_log.h"
30 #include "net/proxy/mojo_proxy_resolver_factory.h" 29 #include "net/proxy/mojo_proxy_resolver_factory.h"
31 #include "net/proxy/proxy_info.h" 30 #include "net/proxy/proxy_info.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 340
342 void AddCreateProxyResolverAction(CreateProxyResolverAction action); 341 void AddCreateProxyResolverAction(CreateProxyResolverAction action);
343 342
344 void WaitForNextRequest(); 343 void WaitForNextRequest();
345 344
346 void ClearBlockedClients(); 345 void ClearBlockedClients();
347 346
348 private: 347 private:
349 // Overridden from interfaces::ProxyResolver: 348 // Overridden from interfaces::ProxyResolver:
350 void CreateResolver( 349 void CreateResolver(
351 const mojo::String& pac_url, 350 const std::string& pac_url,
352 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 351 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
353 interfaces::ProxyResolverFactoryRequestClientPtr client) override; 352 interfaces::ProxyResolverFactoryRequestClientPtr client) override;
354 353
355 void WakeWaiter(); 354 void WakeWaiter();
356 355
357 MockMojoProxyResolver* resolver_; 356 MockMojoProxyResolver* resolver_;
358 std::queue<CreateProxyResolverAction> create_resolver_actions_; 357 std::queue<CreateProxyResolverAction> create_resolver_actions_;
359 358
360 base::Closure quit_closure_; 359 base::Closure quit_closure_;
361 360
(...skipping 30 matching lines...) Expand all
392 if (!quit_closure_.is_null()) 391 if (!quit_closure_.is_null())
393 quit_closure_.Run(); 392 quit_closure_.Run();
394 quit_closure_.Reset(); 393 quit_closure_.Reset();
395 } 394 }
396 395
397 void MockMojoProxyResolverFactory::ClearBlockedClients() { 396 void MockMojoProxyResolverFactory::ClearBlockedClients() {
398 blocked_clients_.clear(); 397 blocked_clients_.clear();
399 } 398 }
400 399
401 void MockMojoProxyResolverFactory::CreateResolver( 400 void MockMojoProxyResolverFactory::CreateResolver(
402 const mojo::String& pac_script, 401 const std::string& pac_script,
403 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 402 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
404 interfaces::ProxyResolverFactoryRequestClientPtr client) { 403 interfaces::ProxyResolverFactoryRequestClientPtr client) {
405 ASSERT_FALSE(create_resolver_actions_.empty()); 404 ASSERT_FALSE(create_resolver_actions_.empty());
406 CreateProxyResolverAction action = create_resolver_actions_.front(); 405 CreateProxyResolverAction action = create_resolver_actions_.front();
407 create_resolver_actions_.pop(); 406 create_resolver_actions_.pop();
408 407
409 EXPECT_EQ(action.expected_pac_script, pac_script.To<std::string>()); 408 EXPECT_EQ(action.expected_pac_script, pac_script);
410 client->Alert(pac_script); 409 client->Alert(pac_script);
411 client->OnError(12345, pac_script); 410 client->OnError(12345, pac_script);
412 switch (action.action) { 411 switch (action.action) {
413 case CreateProxyResolverAction::COMPLETE: { 412 case CreateProxyResolverAction::COMPLETE: {
414 if (action.error == OK) 413 if (action.error == OK)
415 resolver_->AddConnection(std::move(request)); 414 resolver_->AddConnection(std::move(request));
416 client->ReportResult(action.error); 415 client->ReportResult(action.error);
417 break; 416 break;
418 } 417 }
419 case CreateProxyResolverAction::DROP_CLIENT: { 418 case CreateProxyResolverAction::DROP_CLIENT: {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 this, &host_resolver_, 527 this, &host_resolver_,
529 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(), 528 base::Callback<std::unique_ptr<ProxyResolverErrorObserver>()>(),
530 &net_log_)); 529 &net_log_));
531 } 530 }
532 531
533 std::unique_ptr<Request> MakeRequest(const GURL& url) { 532 std::unique_ptr<Request> MakeRequest(const GURL& url) {
534 return base::MakeUnique<Request>(proxy_resolver_mojo_.get(), url); 533 return base::MakeUnique<Request>(proxy_resolver_mojo_.get(), url);
535 } 534 }
536 535
537 std::unique_ptr<base::ScopedClosureRunner> CreateResolver( 536 std::unique_ptr<base::ScopedClosureRunner> CreateResolver(
538 const mojo::String& pac_script, 537 const std::string& pac_script,
539 mojo::InterfaceRequest<interfaces::ProxyResolver> req, 538 mojo::InterfaceRequest<interfaces::ProxyResolver> req,
540 interfaces::ProxyResolverFactoryRequestClientPtr client) override { 539 interfaces::ProxyResolverFactoryRequestClientPtr client) override {
541 factory_ptr_->CreateResolver(pac_script, std::move(req), std::move(client)); 540 factory_ptr_->CreateResolver(pac_script, std::move(req), std::move(client));
542 return base::MakeUnique<base::ScopedClosureRunner>( 541 return base::MakeUnique<base::ScopedClosureRunner>(
543 on_delete_callback_.closure()); 542 on_delete_callback_.closure());
544 } 543 }
545 544
546 ProxyInfo ProxyServersFromPacString(const std::string& pac_string) { 545 ProxyInfo ProxyServersFromPacString(const std::string& pac_string) {
547 ProxyInfo proxy_info; 546 ProxyInfo proxy_info;
548 proxy_info.UsePacString(pac_string); 547 proxy_info.UsePacString(pac_string);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 mock_proxy_resolver_.ClearBlockedClients(); 896 mock_proxy_resolver_.ClearBlockedClients();
898 request->WaitForResult(); 897 request->WaitForResult();
899 } 898 }
900 899
901 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) { 900 TEST_F(ProxyResolverFactoryMojoTest, DeleteResolver) {
902 CreateProxyResolver(); 901 CreateProxyResolver();
903 proxy_resolver_mojo_.reset(); 902 proxy_resolver_mojo_.reset();
904 on_delete_callback_.WaitForResult(); 903 on_delete_callback_.WaitForResult();
905 } 904 }
906 } // namespace net 905 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_factory_mojo.cc ('k') | net/proxy/proxy_service_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698