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

Side by Side Diff: content/shell/browser/shell_url_request_context_getter.cc

Issue 1544293002: Convert Pass()→std::move() in //content (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/shell_url_request_context_getter.h" 5 #include "content/shell/browser/shell_url_request_context_getter.h"
6 6
7 #include <utility>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
14 #include "base/threading/sequenced_worker_pool.h" 16 #include "base/threading/sequenced_worker_pool.h"
15 #include "base/threading/worker_pool.h" 17 #include "base/threading/worker_pool.h"
16 #include "build/build_config.h" 18 #include "build/build_config.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 base::MessageLoop* io_loop, 70 base::MessageLoop* io_loop,
69 base::MessageLoop* file_loop, 71 base::MessageLoop* file_loop,
70 ProtocolHandlerMap* protocol_handlers, 72 ProtocolHandlerMap* protocol_handlers,
71 URLRequestInterceptorScopedVector request_interceptors, 73 URLRequestInterceptorScopedVector request_interceptors,
72 net::NetLog* net_log) 74 net::NetLog* net_log)
73 : ignore_certificate_errors_(ignore_certificate_errors), 75 : ignore_certificate_errors_(ignore_certificate_errors),
74 base_path_(base_path), 76 base_path_(base_path),
75 io_loop_(io_loop), 77 io_loop_(io_loop),
76 file_loop_(file_loop), 78 file_loop_(file_loop),
77 net_log_(net_log), 79 net_log_(net_log),
78 request_interceptors_(request_interceptors.Pass()) { 80 request_interceptors_(std::move(request_interceptors)) {
79 // Must first be created on the UI thread. 81 // Must first be created on the UI thread.
80 DCHECK_CURRENTLY_ON(BrowserThread::UI); 82 DCHECK_CURRENTLY_ON(BrowserThread::UI);
81 83
82 std::swap(protocol_handlers_, *protocol_handlers); 84 std::swap(protocol_handlers_, *protocol_handlers);
83 85
84 // We must create the proxy config service on the UI loop on Linux because it 86 // We must create the proxy config service on the UI loop on Linux because it
85 // must synchronously run on the glib message loop. This will be passed to 87 // must synchronously run on the glib message loop. This will be passed to
86 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). 88 // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
87 proxy_config_service_ = GetProxyConfigService(); 89 proxy_config_service_ = GetProxyConfigService();
88 } 90 }
89 91
90 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { 92 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
91 } 93 }
92 94
93 scoped_ptr<net::NetworkDelegate> 95 scoped_ptr<net::NetworkDelegate>
94 ShellURLRequestContextGetter::CreateNetworkDelegate() { 96 ShellURLRequestContextGetter::CreateNetworkDelegate() {
95 return make_scoped_ptr(new ShellNetworkDelegate); 97 return make_scoped_ptr(new ShellNetworkDelegate);
96 } 98 }
97 99
98 scoped_ptr<net::ProxyConfigService> 100 scoped_ptr<net::ProxyConfigService>
99 ShellURLRequestContextGetter::GetProxyConfigService() { 101 ShellURLRequestContextGetter::GetProxyConfigService() {
100 return net::ProxyService::CreateSystemProxyConfigService( 102 return net::ProxyService::CreateSystemProxyConfigService(
101 io_loop_->task_runner(), file_loop_->task_runner()); 103 io_loop_->task_runner(), file_loop_->task_runner());
102 } 104 }
103 105
104 scoped_ptr<net::ProxyService> ShellURLRequestContextGetter::GetProxyService() { 106 scoped_ptr<net::ProxyService> ShellURLRequestContextGetter::GetProxyService() {
105 // TODO(jam): use v8 if possible, look at chrome code. 107 // TODO(jam): use v8 if possible, look at chrome code.
106 return net::ProxyService::CreateUsingSystemProxyResolver( 108 return net::ProxyService::CreateUsingSystemProxyResolver(
107 proxy_config_service_.Pass(), 0, url_request_context_->net_log()); 109 std::move(proxy_config_service_), 0, url_request_context_->net_log());
108 } 110 }
109 111
110 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { 112 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
111 DCHECK_CURRENTLY_ON(BrowserThread::IO); 113 DCHECK_CURRENTLY_ON(BrowserThread::IO);
112 114
113 if (!url_request_context_) { 115 if (!url_request_context_) {
114 const base::CommandLine& command_line = 116 const base::CommandLine& command_line =
115 *base::CommandLine::ForCurrentProcess(); 117 *base::CommandLine::ForCurrentProcess();
116 118
117 url_request_context_.reset(new net::URLRequestContext()); 119 url_request_context_.reset(new net::URLRequestContext());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 network_session_params.testing_fixed_http_port = value; 186 network_session_params.testing_fixed_http_port = value;
185 } 187 }
186 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 188 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
187 int value; 189 int value;
188 base::StringToInt(command_line.GetSwitchValueASCII( 190 base::StringToInt(command_line.GetSwitchValueASCII(
189 switches::kTestingFixedHttpsPort), &value); 191 switches::kTestingFixedHttpsPort), &value);
190 network_session_params.testing_fixed_https_port = value; 192 network_session_params.testing_fixed_https_port = value;
191 } 193 }
192 if (command_line.HasSwitch(switches::kHostResolverRules)) { 194 if (command_line.HasSwitch(switches::kHostResolverRules)) {
193 scoped_ptr<net::MappedHostResolver> mapped_host_resolver( 195 scoped_ptr<net::MappedHostResolver> mapped_host_resolver(
194 new net::MappedHostResolver(host_resolver.Pass())); 196 new net::MappedHostResolver(std::move(host_resolver)));
195 mapped_host_resolver->SetRulesFromString( 197 mapped_host_resolver->SetRulesFromString(
196 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); 198 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
197 host_resolver = mapped_host_resolver.Pass(); 199 host_resolver = std::move(mapped_host_resolver);
198 } 200 }
199 201
200 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. 202 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|.
201 storage_->set_host_resolver(host_resolver.Pass()); 203 storage_->set_host_resolver(std::move(host_resolver));
202 network_session_params.host_resolver = 204 network_session_params.host_resolver =
203 url_request_context_->host_resolver(); 205 url_request_context_->host_resolver();
204 206
205 storage_->set_http_network_session( 207 storage_->set_http_network_session(
206 make_scoped_ptr(new net::HttpNetworkSession(network_session_params))); 208 make_scoped_ptr(new net::HttpNetworkSession(network_session_params)));
207 storage_->set_http_transaction_factory(make_scoped_ptr( 209 storage_->set_http_transaction_factory(make_scoped_ptr(new net::HttpCache(
208 new net::HttpCache(storage_->http_network_session(), 210 storage_->http_network_session(), std::move(main_backend),
209 main_backend.Pass(), 211 true /* set_up_quic_server_info */)));
210 true /* set_up_quic_server_info */)));
211 212
212 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 213 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
213 new net::URLRequestJobFactoryImpl()); 214 new net::URLRequestJobFactoryImpl());
214 // Keep ProtocolHandlers added in sync with 215 // Keep ProtocolHandlers added in sync with
215 // ShellContentBrowserClient::IsHandledURL(). 216 // ShellContentBrowserClient::IsHandledURL().
216 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); 217 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_);
217 bool set_protocol = job_factory->SetProtocolHandler( 218 bool set_protocol = job_factory->SetProtocolHandler(
218 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler)); 219 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler));
219 DCHECK(set_protocol); 220 DCHECK(set_protocol);
220 #if !defined(DISABLE_FILE_SUPPORT) 221 #if !defined(DISABLE_FILE_SUPPORT)
221 set_protocol = job_factory->SetProtocolHandler( 222 set_protocol = job_factory->SetProtocolHandler(
222 url::kFileScheme, 223 url::kFileScheme,
223 make_scoped_ptr(new net::FileProtocolHandler( 224 make_scoped_ptr(new net::FileProtocolHandler(
224 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 225 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
225 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); 226 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
226 DCHECK(set_protocol); 227 DCHECK(set_protocol);
227 #endif 228 #endif
228 229
229 // Set up interceptors in the reverse order. 230 // Set up interceptors in the reverse order.
230 scoped_ptr<net::URLRequestJobFactory> top_job_factory = 231 scoped_ptr<net::URLRequestJobFactory> top_job_factory =
231 job_factory.Pass(); 232 std::move(job_factory);
232 for (URLRequestInterceptorScopedVector::reverse_iterator i = 233 for (URLRequestInterceptorScopedVector::reverse_iterator i =
233 request_interceptors_.rbegin(); 234 request_interceptors_.rbegin();
234 i != request_interceptors_.rend(); 235 i != request_interceptors_.rend();
235 ++i) { 236 ++i) {
236 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( 237 top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
237 top_job_factory.Pass(), make_scoped_ptr(*i))); 238 std::move(top_job_factory), make_scoped_ptr(*i)));
238 } 239 }
239 request_interceptors_.weak_clear(); 240 request_interceptors_.weak_clear();
240 241
241 storage_->set_job_factory(top_job_factory.Pass()); 242 storage_->set_job_factory(std::move(top_job_factory));
242 } 243 }
243 244
244 return url_request_context_.get(); 245 return url_request_context_.get();
245 } 246 }
246 247
247 scoped_refptr<base::SingleThreadTaskRunner> 248 scoped_refptr<base::SingleThreadTaskRunner>
248 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 249 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
249 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 250 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
250 } 251 }
251 252
252 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 253 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
253 return url_request_context_->host_resolver(); 254 return url_request_context_->host_resolver();
254 } 255 }
255 256
256 } // namespace content 257 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_net_log.cc ('k') | content/shell/renderer/layout_test/blink_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698