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

Side by Side Diff: net/url_request/url_request_ftp_job_unittest.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/url_request/url_request_ftp_job.h" 5 #include "net/url_request/url_request_ftp_job.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
13 #include "net/base/load_states.h" 14 #include "net/base/load_states.h"
14 #include "net/base/request_priority.h" 15 #include "net/base/request_priority.h"
15 #include "net/ftp/ftp_auth_cache.h" 16 #include "net/ftp/ftp_auth_cache.h"
16 #include "net/http/http_transaction_test_util.h" 17 #include "net/http/http_transaction_test_util.h"
(...skipping 22 matching lines...) Expand all
39 40
40 int CreateProxyResolver( 41 int CreateProxyResolver(
41 const scoped_refptr<ProxyResolverScriptData>& pac_script, 42 const scoped_refptr<ProxyResolverScriptData>& pac_script,
42 scoped_ptr<ProxyResolver>* resolver, 43 scoped_ptr<ProxyResolver>* resolver,
43 const CompletionCallback& callback, 44 const CompletionCallback& callback,
44 scoped_ptr<Request>* request) override { 45 scoped_ptr<Request>* request) override {
45 EXPECT_FALSE(resolver_); 46 EXPECT_FALSE(resolver_);
46 scoped_ptr<MockAsyncProxyResolver> owned_resolver( 47 scoped_ptr<MockAsyncProxyResolver> owned_resolver(
47 new MockAsyncProxyResolver()); 48 new MockAsyncProxyResolver());
48 resolver_ = owned_resolver.get(); 49 resolver_ = owned_resolver.get();
49 *resolver = owned_resolver.Pass(); 50 *resolver = std::move(owned_resolver);
50 return OK; 51 return OK;
51 } 52 }
52 53
53 MockAsyncProxyResolver* resolver() { return resolver_; } 54 MockAsyncProxyResolver* resolver() { return resolver_; }
54 55
55 private: 56 private:
56 MockAsyncProxyResolver* resolver_; 57 MockAsyncProxyResolver* resolver_;
57 }; 58 };
58 59
59 } // namespace 60 } // namespace
60 61
61 class FtpTestURLRequestContext : public TestURLRequestContext { 62 class FtpTestURLRequestContext : public TestURLRequestContext {
62 public: 63 public:
63 FtpTestURLRequestContext(ClientSocketFactory* socket_factory, 64 FtpTestURLRequestContext(ClientSocketFactory* socket_factory,
64 scoped_ptr<ProxyService> proxy_service, 65 scoped_ptr<ProxyService> proxy_service,
65 NetworkDelegate* network_delegate, 66 NetworkDelegate* network_delegate,
66 FtpTransactionFactory* ftp_transaction_factory) 67 FtpTransactionFactory* ftp_transaction_factory)
67 : TestURLRequestContext(true), 68 : TestURLRequestContext(true),
68 ftp_protocol_handler_(new FtpProtocolHandler(ftp_transaction_factory)) { 69 ftp_protocol_handler_(new FtpProtocolHandler(ftp_transaction_factory)) {
69 set_client_socket_factory(socket_factory); 70 set_client_socket_factory(socket_factory);
70 context_storage_.set_proxy_service(proxy_service.Pass()); 71 context_storage_.set_proxy_service(std::move(proxy_service));
71 set_network_delegate(network_delegate); 72 set_network_delegate(network_delegate);
72 scoped_ptr<URLRequestJobFactoryImpl> job_factory = 73 scoped_ptr<URLRequestJobFactoryImpl> job_factory =
73 make_scoped_ptr(new URLRequestJobFactoryImpl); 74 make_scoped_ptr(new URLRequestJobFactoryImpl);
74 job_factory->SetProtocolHandler("ftp", 75 job_factory->SetProtocolHandler("ftp",
75 make_scoped_ptr(ftp_protocol_handler_)); 76 make_scoped_ptr(ftp_protocol_handler_));
76 context_storage_.set_job_factory(job_factory.Pass()); 77 context_storage_.set_job_factory(std::move(job_factory));
77 Init(); 78 Init();
78 } 79 }
79 80
80 FtpAuthCache* GetFtpAuthCache() { 81 FtpAuthCache* GetFtpAuthCache() {
81 return ftp_protocol_handler_->ftp_auth_cache_.get(); 82 return ftp_protocol_handler_->ftp_auth_cache_.get();
82 } 83 }
83 84
84 void set_proxy_service(scoped_ptr<ProxyService> proxy_service) { 85 void set_proxy_service(scoped_ptr<ProxyService> proxy_service) {
85 context_storage_.set_proxy_service(proxy_service.Pass()); 86 context_storage_.set_proxy_service(std::move(proxy_service));
86 } 87 }
87 88
88 private: 89 private:
89 FtpProtocolHandler* ftp_protocol_handler_; 90 FtpProtocolHandler* ftp_protocol_handler_;
90 }; 91 };
91 92
92 namespace { 93 namespace {
93 94
94 class SimpleProxyConfigService : public ProxyConfigService { 95 class SimpleProxyConfigService : public ProxyConfigService {
95 public: 96 public:
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // Regression test for http://crbug.com/237526. 315 // Regression test for http://crbug.com/237526.
315 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) { 316 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) {
316 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory( 317 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory(
317 new MockProxyResolverFactory()); 318 new MockProxyResolverFactory());
318 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get(); 319 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get();
319 320
320 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 321 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
321 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService( 322 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService(
322 make_scoped_ptr(new ProxyConfigServiceFixed( 323 make_scoped_ptr(new ProxyConfigServiceFixed(
323 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))), 324 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
324 owned_resolver_factory.Pass(), nullptr))); 325 std::move(owned_resolver_factory), nullptr)));
325 326
326 TestDelegate request_delegate; 327 TestDelegate request_delegate;
327 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 328 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
328 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 329 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
329 url_request->Start(); 330 url_request->Start();
330 331
331 // Verify PAC request is in progress. 332 // Verify PAC request is in progress.
332 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 333 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
333 url_request->GetLoadState().state); 334 url_request->GetLoadState().state);
334 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 335 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size());
(...skipping 10 matching lines...) Expand all
345 // above test is not sufficient. 346 // above test is not sufficient.
346 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) { 347 TEST_F(URLRequestFtpJobTest, FtpProxyRequestCancelRequest) {
347 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory( 348 scoped_ptr<MockProxyResolverFactory> owned_resolver_factory(
348 new MockProxyResolverFactory()); 349 new MockProxyResolverFactory());
349 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get(); 350 MockProxyResolverFactory* resolver_factory = owned_resolver_factory.get();
350 351
351 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 352 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
352 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService( 353 request_context()->set_proxy_service(make_scoped_ptr(new ProxyService(
353 make_scoped_ptr(new ProxyConfigServiceFixed( 354 make_scoped_ptr(new ProxyConfigServiceFixed(
354 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))), 355 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
355 owned_resolver_factory.Pass(), nullptr))); 356 std::move(owned_resolver_factory), nullptr)));
356 357
357 TestDelegate request_delegate; 358 TestDelegate request_delegate;
358 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 359 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
359 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 360 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
360 361
361 // Verify PAC request is in progress. 362 // Verify PAC request is in progress.
362 url_request->Start(); 363 url_request->Start();
363 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL, 364 EXPECT_EQ(net::LoadState::LOAD_STATE_RESOLVING_PROXY_FOR_URL,
364 url_request->GetLoadState().state); 365 url_request->GetLoadState().state);
365 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size()); 366 EXPECT_EQ(1u, resolver_factory->resolver()->pending_requests().size());
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 EXPECT_TRUE(url_request2->status().is_success()); 791 EXPECT_TRUE(url_request2->status().is_success());
791 EXPECT_EQ(2, network_delegate()->completed_requests()); 792 EXPECT_EQ(2, network_delegate()->completed_requests());
792 EXPECT_EQ(0, network_delegate()->error_count()); 793 EXPECT_EQ(0, network_delegate()->error_count());
793 EXPECT_FALSE(request_delegate2.auth_required_called()); 794 EXPECT_FALSE(request_delegate2.auth_required_called());
794 EXPECT_EQ("test2.html", request_delegate2.data_received()); 795 EXPECT_EQ("test2.html", request_delegate2.data_received());
795 } 796 }
796 797
797 } // namespace 798 } // namespace
798 799
799 } // namespace net 800 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_storage.cc ('k') | net/url_request/url_request_http_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698