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

Side by Side Diff: net/url_request/url_request_context_builder.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, 11 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_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 file_thread_.reset(new base::Thread("Network File Thread")); 146 file_thread_.reset(new base::Thread("Network File Thread"));
146 file_thread_->StartWithOptions( 147 file_thread_->StartWithOptions(
147 base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0)); 148 base::Thread::Options(base::MessageLoop::TYPE_DEFAULT, 0));
148 file_task_runner_ = file_thread_->task_runner(); 149 file_task_runner_ = file_thread_->task_runner();
149 } 150 }
150 return file_task_runner_; 151 return file_task_runner_;
151 } 152 }
152 153
153 void set_transport_security_persister( 154 void set_transport_security_persister(
154 scoped_ptr<TransportSecurityPersister> transport_security_persister) { 155 scoped_ptr<TransportSecurityPersister> transport_security_persister) {
155 transport_security_persister_ = transport_security_persister.Pass(); 156 transport_security_persister_ = std::move(transport_security_persister);
156 } 157 }
157 158
158 private: 159 private:
159 // The thread should be torn down last. 160 // The thread should be torn down last.
160 scoped_ptr<base::Thread> file_thread_; 161 scoped_ptr<base::Thread> file_thread_;
161 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 162 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
162 163
163 URLRequestContextStorage storage_; 164 URLRequestContextStorage storage_;
164 scoped_ptr<TransportSecurityPersister> transport_security_persister_; 165 scoped_ptr<TransportSecurityPersister> transport_security_persister_;
165 166
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 236
236 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled, 237 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled,
237 bool quic_enabled) { 238 bool quic_enabled) {
238 http_network_session_params_.next_protos = 239 http_network_session_params_.next_protos =
239 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled); 240 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled);
240 http_network_session_params_.enable_quic = quic_enabled; 241 http_network_session_params_.enable_quic = quic_enabled;
241 } 242 }
242 243
243 void URLRequestContextBuilder::SetCertVerifier( 244 void URLRequestContextBuilder::SetCertVerifier(
244 scoped_ptr<CertVerifier> cert_verifier) { 245 scoped_ptr<CertVerifier> cert_verifier) {
245 cert_verifier_ = cert_verifier.Pass(); 246 cert_verifier_ = std::move(cert_verifier);
246 } 247 }
247 248
248 void URLRequestContextBuilder::SetInterceptors( 249 void URLRequestContextBuilder::SetInterceptors(
249 std::vector<scoped_ptr<URLRequestInterceptor>> url_request_interceptors) { 250 std::vector<scoped_ptr<URLRequestInterceptor>> url_request_interceptors) {
250 url_request_interceptors_ = std::move(url_request_interceptors); 251 url_request_interceptors_ = std::move(url_request_interceptors);
251 } 252 }
252 253
253 void URLRequestContextBuilder::SetCookieAndChannelIdStores( 254 void URLRequestContextBuilder::SetCookieAndChannelIdStores(
254 const scoped_refptr<CookieStore>& cookie_store, 255 const scoped_refptr<CookieStore>& cookie_store,
255 scoped_ptr<ChannelIDService> channel_id_service) { 256 scoped_ptr<ChannelIDService> channel_id_service) {
256 DCHECK(cookie_store); 257 DCHECK(cookie_store);
257 cookie_store_ = cookie_store; 258 cookie_store_ = cookie_store;
258 channel_id_service_ = channel_id_service.Pass(); 259 channel_id_service_ = std::move(channel_id_service);
259 } 260 }
260 261
261 void URLRequestContextBuilder::SetFileTaskRunner( 262 void URLRequestContextBuilder::SetFileTaskRunner(
262 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 263 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
263 file_task_runner_ = task_runner; 264 file_task_runner_ = task_runner;
264 } 265 }
265 266
266 void URLRequestContextBuilder::SetHttpAuthHandlerFactory( 267 void URLRequestContextBuilder::SetHttpAuthHandlerFactory(
267 scoped_ptr<HttpAuthHandlerFactory> factory) { 268 scoped_ptr<HttpAuthHandlerFactory> factory) {
268 http_auth_handler_factory_ = factory.Pass(); 269 http_auth_handler_factory_ = std::move(factory);
269 } 270 }
270 271
271 void URLRequestContextBuilder::SetHttpServerProperties( 272 void URLRequestContextBuilder::SetHttpServerProperties(
272 scoped_ptr<HttpServerProperties> http_server_properties) { 273 scoped_ptr<HttpServerProperties> http_server_properties) {
273 http_server_properties_ = http_server_properties.Pass(); 274 http_server_properties_ = std::move(http_server_properties);
274 } 275 }
275 276
276 scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() { 277 scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
277 scoped_ptr<ContainerURLRequestContext> context( 278 scoped_ptr<ContainerURLRequestContext> context(
278 new ContainerURLRequestContext(file_task_runner_)); 279 new ContainerURLRequestContext(file_task_runner_));
279 URLRequestContextStorage* storage = context->storage(); 280 URLRequestContextStorage* storage = context->storage();
280 281
281 storage->set_http_user_agent_settings(make_scoped_ptr( 282 storage->set_http_user_agent_settings(make_scoped_ptr(
282 new StaticHttpUserAgentSettings(accept_language_, user_agent_))); 283 new StaticHttpUserAgentSettings(accept_language_, user_agent_)));
283 284
284 if (!network_delegate_) 285 if (!network_delegate_)
285 network_delegate_.reset(new BasicNetworkDelegate); 286 network_delegate_.reset(new BasicNetworkDelegate);
286 storage->set_network_delegate(network_delegate_.Pass()); 287 storage->set_network_delegate(std::move(network_delegate_));
287 288
288 if (net_log_) { 289 if (net_log_) {
289 // Unlike the other builder parameters, |net_log_| is not owned by the 290 // Unlike the other builder parameters, |net_log_| is not owned by the
290 // builder or resulting context. 291 // builder or resulting context.
291 context->set_net_log(net_log_); 292 context->set_net_log(net_log_);
292 } else { 293 } else {
293 storage->set_net_log(make_scoped_ptr(new NetLog)); 294 storage->set_net_log(make_scoped_ptr(new NetLog));
294 } 295 }
295 296
296 if (!host_resolver_) { 297 if (!host_resolver_) {
297 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log()); 298 host_resolver_ = HostResolver::CreateDefaultResolver(context->net_log());
298 } 299 }
299 storage->set_host_resolver(host_resolver_.Pass()); 300 storage->set_host_resolver(std::move(host_resolver_));
300 301
301 if (!proxy_service_) { 302 if (!proxy_service_) {
302 // TODO(willchan): Switch to using this code when 303 // TODO(willchan): Switch to using this code when
303 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck. 304 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
304 #if !defined(OS_LINUX) && !defined(OS_ANDROID) 305 #if !defined(OS_LINUX) && !defined(OS_ANDROID)
305 if (!proxy_config_service_) { 306 if (!proxy_config_service_) {
306 proxy_config_service_ = ProxyService::CreateSystemProxyConfigService( 307 proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
307 base::ThreadTaskRunnerHandle::Get().get(), 308 base::ThreadTaskRunnerHandle::Get().get(),
308 context->GetFileTaskRunner()); 309 context->GetFileTaskRunner());
309 } 310 }
310 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID) 311 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
311 proxy_service_ = ProxyService::CreateUsingSystemProxyResolver( 312 proxy_service_ = ProxyService::CreateUsingSystemProxyResolver(
312 proxy_config_service_.Pass(), 313 std::move(proxy_config_service_),
313 0, // This results in using the default value. 314 0, // This results in using the default value.
314 context->net_log()); 315 context->net_log());
315 } 316 }
316 storage->set_proxy_service(proxy_service_.Pass()); 317 storage->set_proxy_service(std::move(proxy_service_));
317 318
318 storage->set_ssl_config_service(new SSLConfigServiceDefaults); 319 storage->set_ssl_config_service(new SSLConfigServiceDefaults);
319 320
320 if (!http_auth_handler_factory_) { 321 if (!http_auth_handler_factory_) {
321 http_auth_handler_factory_ = 322 http_auth_handler_factory_ =
322 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver()); 323 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver());
323 } 324 }
324 325
325 storage->set_http_auth_handler_factory(http_auth_handler_factory_.Pass()); 326 storage->set_http_auth_handler_factory(std::move(http_auth_handler_factory_));
326 327
327 if (cookie_store_) { 328 if (cookie_store_) {
328 storage->set_cookie_store(cookie_store_.get()); 329 storage->set_cookie_store(cookie_store_.get());
329 storage->set_channel_id_service(channel_id_service_.Pass()); 330 storage->set_channel_id_service(std::move(channel_id_service_));
330 } else { 331 } else {
331 storage->set_cookie_store(new CookieMonster(NULL, NULL)); 332 storage->set_cookie_store(new CookieMonster(NULL, NULL));
332 // TODO(mmenke): This always creates a file thread, even when it ends up 333 // TODO(mmenke): This always creates a file thread, even when it ends up
333 // not being used. Consider lazily creating the thread. 334 // not being used. Consider lazily creating the thread.
334 storage->set_channel_id_service(make_scoped_ptr(new ChannelIDService( 335 storage->set_channel_id_service(make_scoped_ptr(new ChannelIDService(
335 new DefaultChannelIDStore(NULL), context->GetFileTaskRunner()))); 336 new DefaultChannelIDStore(NULL), context->GetFileTaskRunner())));
336 } 337 }
337 338
338 if (sdch_enabled_) { 339 if (sdch_enabled_) {
339 storage->set_sdch_manager( 340 storage->set_sdch_manager(scoped_ptr<net::SdchManager>(new SdchManager()));
340 scoped_ptr<net::SdchManager>(new SdchManager()).Pass());
341 } 341 }
342 342
343 storage->set_transport_security_state( 343 storage->set_transport_security_state(
344 make_scoped_ptr(new TransportSecurityState())); 344 make_scoped_ptr(new TransportSecurityState()));
345 if (!transport_security_persister_path_.empty()) { 345 if (!transport_security_persister_path_.empty()) {
346 context->set_transport_security_persister( 346 context->set_transport_security_persister(
347 make_scoped_ptr<TransportSecurityPersister>( 347 make_scoped_ptr<TransportSecurityPersister>(
348 new TransportSecurityPersister(context->transport_security_state(), 348 new TransportSecurityPersister(context->transport_security_state(),
349 transport_security_persister_path_, 349 transport_security_persister_path_,
350 context->GetFileTaskRunner(), 350 context->GetFileTaskRunner(),
351 false))); 351 false)));
352 } 352 }
353 353
354 if (http_server_properties_) { 354 if (http_server_properties_) {
355 storage->set_http_server_properties(http_server_properties_.Pass()); 355 storage->set_http_server_properties(std::move(http_server_properties_));
356 } else { 356 } else {
357 storage->set_http_server_properties( 357 storage->set_http_server_properties(
358 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); 358 scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl()));
359 } 359 }
360 360
361 if (cert_verifier_) { 361 if (cert_verifier_) {
362 storage->set_cert_verifier(cert_verifier_.Pass()); 362 storage->set_cert_verifier(std::move(cert_verifier_));
363 } else { 363 } else {
364 storage->set_cert_verifier(CertVerifier::CreateDefault()); 364 storage->set_cert_verifier(CertVerifier::CreateDefault());
365 } 365 }
366 366
367 if (throttling_enabled_) { 367 if (throttling_enabled_) {
368 storage->set_throttler_manager( 368 storage->set_throttler_manager(
369 make_scoped_ptr(new URLRequestThrottlerManager())); 369 make_scoped_ptr(new URLRequestThrottlerManager()));
370 } 370 }
371 371
372 if (backoff_enabled_) { 372 if (backoff_enabled_) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 : CACHE_BACKEND_SIMPLE; 417 : CACHE_BACKEND_SIMPLE;
418 http_cache_backend.reset(new HttpCache::DefaultBackend( 418 http_cache_backend.reset(new HttpCache::DefaultBackend(
419 DISK_CACHE, backend_type, http_cache_params_.path, 419 DISK_CACHE, backend_type, http_cache_params_.path,
420 http_cache_params_.max_size, context->GetFileTaskRunner())); 420 http_cache_params_.max_size, context->GetFileTaskRunner()));
421 } else { 421 } else {
422 http_cache_backend = 422 http_cache_backend =
423 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); 423 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size);
424 } 424 }
425 425
426 http_transaction_factory.reset(new HttpCache( 426 http_transaction_factory.reset(new HttpCache(
427 storage->http_network_session(), http_cache_backend.Pass(), true)); 427 storage->http_network_session(), std::move(http_cache_backend), true));
428 } else { 428 } else {
429 http_transaction_factory.reset( 429 http_transaction_factory.reset(
430 new HttpNetworkLayer(storage->http_network_session())); 430 new HttpNetworkLayer(storage->http_network_session()));
431 } 431 }
432 storage->set_http_transaction_factory(http_transaction_factory.Pass()); 432 storage->set_http_transaction_factory(std::move(http_transaction_factory));
433 433
434 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; 434 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl;
435 if (data_enabled_) 435 if (data_enabled_)
436 job_factory->SetProtocolHandler("data", 436 job_factory->SetProtocolHandler("data",
437 make_scoped_ptr(new DataProtocolHandler)); 437 make_scoped_ptr(new DataProtocolHandler));
438 438
439 #if !defined(DISABLE_FILE_SUPPORT) 439 #if !defined(DISABLE_FILE_SUPPORT)
440 if (file_enabled_) { 440 if (file_enabled_) {
441 job_factory->SetProtocolHandler( 441 job_factory->SetProtocolHandler(
442 "file", 442 "file",
(...skipping 22 matching lines...) Expand all
465 } 465 }
466 url_request_interceptors_.clear(); 466 url_request_interceptors_.clear();
467 } 467 }
468 storage->set_job_factory(std::move(top_job_factory)); 468 storage->set_job_factory(std::move(top_job_factory));
469 // TODO(willchan): Support sdch. 469 // TODO(willchan): Support sdch.
470 470
471 return std::move(context); 471 return std::move(context);
472 } 472 }
473 473
474 } // namespace net 474 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder.h ('k') | net/url_request/url_request_context_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698