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

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

Issue 1288383002: Use common code to set HttpNetworkSession::Param pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to r345348. Created 5 years, 3 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/url_request/url_request_context_builder.h ('k') | 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 (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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "net/base/cache_type.h" 16 #include "net/base/cache_type.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/network_delegate_impl.h" 18 #include "net/base/network_delegate_impl.h"
19 #include "net/base/sdch_manager.h" 19 #include "net/base/sdch_manager.h"
20 #include "net/cert/cert_verifier.h" 20 #include "net/cert/cert_verifier.h"
21 #include "net/cookies/cookie_monster.h" 21 #include "net/cookies/cookie_monster.h"
22 #include "net/dns/host_resolver.h" 22 #include "net/dns/host_resolver.h"
23 #include "net/ftp/ftp_network_layer.h" 23 #include "net/ftp/ftp_network_layer.h"
24 #include "net/http/http_auth_handler_factory.h" 24 #include "net/http/http_auth_handler_factory.h"
25 #include "net/http/http_cache.h" 25 #include "net/http/http_cache.h"
26 #include "net/http/http_network_layer.h" 26 #include "net/http/http_network_layer.h"
27 #include "net/http/http_network_session.h"
28 #include "net/http/http_server_properties_impl.h" 27 #include "net/http/http_server_properties_impl.h"
29 #include "net/http/http_server_properties_manager.h" 28 #include "net/http/http_server_properties_manager.h"
30 #include "net/http/transport_security_persister.h" 29 #include "net/http/transport_security_persister.h"
31 #include "net/http/transport_security_state.h" 30 #include "net/http/transport_security_state.h"
32 #include "net/ssl/channel_id_service.h" 31 #include "net/ssl/channel_id_service.h"
33 #include "net/ssl/default_channel_id_store.h" 32 #include "net/ssl/default_channel_id_store.h"
34 #include "net/ssl/ssl_config_service_defaults.h" 33 #include "net/ssl/ssl_config_service_defaults.h"
35 #include "net/url_request/data_protocol_handler.h" 34 #include "net/url_request/data_protocol_handler.h"
36 #include "net/url_request/static_http_user_agent_settings.h" 35 #include "net/url_request/static_http_user_agent_settings.h"
37 #include "net/url_request/url_request_backoff_manager.h" 36 #include "net/url_request/url_request_backoff_manager.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ftp_enabled_(false), 203 ftp_enabled_(false),
205 #endif 204 #endif
206 http_cache_enabled_(true), 205 http_cache_enabled_(true),
207 throttling_enabled_(false), 206 throttling_enabled_(false),
208 backoff_enabled_(false), 207 backoff_enabled_(false),
209 sdch_enabled_(false) { 208 sdch_enabled_(false) {
210 } 209 }
211 210
212 URLRequestContextBuilder::~URLRequestContextBuilder() {} 211 URLRequestContextBuilder::~URLRequestContextBuilder() {}
213 212
213 void URLRequestContextBuilder::SetHttpNetworkSessionComponents(
214 const URLRequestContext* context,
215 HttpNetworkSession::Params* params) {
216 params->host_resolver = context->host_resolver();
217 params->cert_verifier = context->cert_verifier();
218 params->transport_security_state = context->transport_security_state();
219 params->cert_transparency_verifier = context->cert_transparency_verifier();
220 params->proxy_service = context->proxy_service();
221 params->ssl_config_service = context->ssl_config_service();
222 params->http_auth_handler_factory = context->http_auth_handler_factory();
223 params->network_delegate = context->network_delegate();
224 params->http_server_properties = context->http_server_properties();
225 params->net_log = context->net_log();
226 params->channel_id_service = context->channel_id_service();
227 }
228
214 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) { 229 void URLRequestContextBuilder::EnableHttpCache(const HttpCacheParams& params) {
215 http_cache_enabled_ = true; 230 http_cache_enabled_ = true;
216 http_cache_params_ = params; 231 http_cache_params_ = params;
217 } 232 }
218 233
219 void URLRequestContextBuilder::DisableHttpCache() { 234 void URLRequestContextBuilder::DisableHttpCache() {
220 http_cache_enabled_ = false; 235 http_cache_enabled_ = false;
221 http_cache_params_ = HttpCacheParams(); 236 http_cache_params_ = HttpCacheParams();
222 } 237 }
223 238
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 358
344 storage->set_cert_verifier(CertVerifier::CreateDefault()); 359 storage->set_cert_verifier(CertVerifier::CreateDefault());
345 360
346 if (throttling_enabled_) 361 if (throttling_enabled_)
347 storage->set_throttler_manager(new URLRequestThrottlerManager()); 362 storage->set_throttler_manager(new URLRequestThrottlerManager());
348 363
349 if (backoff_enabled_) 364 if (backoff_enabled_)
350 storage->set_backoff_manager(new URLRequestBackoffManager()); 365 storage->set_backoff_manager(new URLRequestBackoffManager());
351 366
352 HttpNetworkSession::Params network_session_params; 367 HttpNetworkSession::Params network_session_params;
353 network_session_params.host_resolver = context->host_resolver(); 368 SetHttpNetworkSessionComponents(context, &network_session_params);
354 network_session_params.cert_verifier = context->cert_verifier();
355 network_session_params.transport_security_state =
356 context->transport_security_state();
357 network_session_params.proxy_service = context->proxy_service();
358 network_session_params.ssl_config_service =
359 context->ssl_config_service();
360 network_session_params.http_auth_handler_factory =
361 context->http_auth_handler_factory();
362 network_session_params.network_delegate = network_delegate;
363 network_session_params.http_server_properties =
364 context->http_server_properties();
365 network_session_params.net_log = context->net_log();
366 369
367 network_session_params.ignore_certificate_errors = 370 network_session_params.ignore_certificate_errors =
368 http_network_session_params_.ignore_certificate_errors; 371 http_network_session_params_.ignore_certificate_errors;
369 network_session_params.host_mapping_rules = 372 network_session_params.host_mapping_rules =
370 http_network_session_params_.host_mapping_rules; 373 http_network_session_params_.host_mapping_rules;
371 network_session_params.testing_fixed_http_port = 374 network_session_params.testing_fixed_http_port =
372 http_network_session_params_.testing_fixed_http_port; 375 http_network_session_params_.testing_fixed_http_port;
373 network_session_params.testing_fixed_https_port = 376 network_session_params.testing_fixed_https_port =
374 http_network_session_params_.testing_fixed_https_port; 377 http_network_session_params_.testing_fixed_https_port;
375 network_session_params.use_alternative_services = 378 network_session_params.use_alternative_services =
376 http_network_session_params_.use_alternative_services; 379 http_network_session_params_.use_alternative_services;
377 network_session_params.trusted_spdy_proxy = 380 network_session_params.trusted_spdy_proxy =
378 http_network_session_params_.trusted_spdy_proxy; 381 http_network_session_params_.trusted_spdy_proxy;
379 network_session_params.next_protos = http_network_session_params_.next_protos; 382 network_session_params.next_protos = http_network_session_params_.next_protos;
380 network_session_params.enable_quic = http_network_session_params_.enable_quic; 383 network_session_params.enable_quic = http_network_session_params_.enable_quic;
381 network_session_params.enable_insecure_quic = 384 network_session_params.enable_insecure_quic =
382 http_network_session_params_.enable_insecure_quic; 385 http_network_session_params_.enable_insecure_quic;
383 network_session_params.quic_connection_options = 386 network_session_params.quic_connection_options =
384 http_network_session_params_.quic_connection_options; 387 http_network_session_params_.quic_connection_options;
385 388
386 HttpTransactionFactory* http_transaction_factory = NULL; 389 HttpTransactionFactory* http_transaction_factory = NULL;
387 if (http_cache_enabled_) { 390 if (http_cache_enabled_) {
388 network_session_params.channel_id_service =
389 context->channel_id_service();
390 HttpCache::BackendFactory* http_cache_backend = NULL; 391 HttpCache::BackendFactory* http_cache_backend = NULL;
391 if (http_cache_params_.type == HttpCacheParams::DISK) { 392 if (http_cache_params_.type == HttpCacheParams::DISK) {
392 http_cache_backend = new HttpCache::DefaultBackend( 393 http_cache_backend = new HttpCache::DefaultBackend(
393 DISK_CACHE, CACHE_BACKEND_DEFAULT, http_cache_params_.path, 394 DISK_CACHE, CACHE_BACKEND_DEFAULT, http_cache_params_.path,
394 http_cache_params_.max_size, context->GetFileTaskRunner()); 395 http_cache_params_.max_size, context->GetFileTaskRunner());
395 } else { 396 } else {
396 http_cache_backend = 397 http_cache_backend =
397 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); 398 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size);
398 } 399 }
399 400
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 443 }
443 url_request_interceptors_.weak_clear(); 444 url_request_interceptors_.weak_clear();
444 } 445 }
445 storage->set_job_factory(top_job_factory.release()); 446 storage->set_job_factory(top_job_factory.release());
446 // TODO(willchan): Support sdch. 447 // TODO(willchan): Support sdch.
447 448
448 return context; 449 return context;
449 } 450 }
450 451
451 } // namespace net 452 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698