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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 10834215: Remove static variables from HttpStreamFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/profiles/off_the_record_profile_io_data.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 (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 "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/net/proxy_service_factory.h" 32 #include "chrome/browser/net/proxy_service_factory.h"
33 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 33 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
34 #include "chrome/browser/prefs/pref_service.h" 34 #include "chrome/browser/prefs/pref_service.h"
35 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
37 #include "content/public/browser/browser_thread.h" 37 #include "content/public/browser/browser_thread.h"
38 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
39 #include "net/base/cert_verifier.h" 39 #include "net/base/cert_verifier.h"
40 #include "net/base/default_server_bound_cert_store.h" 40 #include "net/base/default_server_bound_cert_store.h"
41 #include "net/base/host_cache.h" 41 #include "net/base/host_cache.h"
42 #include "net/base/host_mapping_rules.h"
42 #include "net/base/host_resolver.h" 43 #include "net/base/host_resolver.h"
43 #include "net/base/mapped_host_resolver.h" 44 #include "net/base/mapped_host_resolver.h"
44 #include "net/base/net_util.h" 45 #include "net/base/net_util.h"
45 #include "net/base/sdch_manager.h" 46 #include "net/base/sdch_manager.h"
46 #include "net/base/server_bound_cert_service.h" 47 #include "net/base/server_bound_cert_service.h"
47 #include "net/cookies/cookie_monster.h" 48 #include "net/cookies/cookie_monster.h"
48 #include "net/ftp/ftp_network_layer.h" 49 #include "net/ftp/ftp_network_layer.h"
49 #include "net/http/http_auth_filter.h" 50 #include "net/http/http_auth_filter.h"
50 #include "net/http/http_auth_handler_factory.h" 51 #include "net/http/http_auth_handler_factory.h"
51 #include "net/http/http_network_layer.h" 52 #include "net/http/http_network_layer.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 316 }
316 317
317 IOThread::Globals:: 318 IOThread::Globals::
318 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { 319 SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() {
319 if (globals_->system_request_context.get()) 320 if (globals_->system_request_context.get())
320 globals_->system_request_context->AssertNoURLRequests(); 321 globals_->system_request_context->AssertNoURLRequests();
321 } 322 }
322 323
323 IOThread::Globals::Globals() 324 IOThread::Globals::Globals()
324 : ALLOW_THIS_IN_INITIALIZER_LIST( 325 : ALLOW_THIS_IN_INITIALIZER_LIST(
325 system_request_context_leak_checker(this)) {} 326 system_request_context_leak_checker(this)),
327 ignore_certificate_errors(false),
328 http_pipelining_enabled(false),
329 testing_fixed_http_port(0),
330 testing_fixed_https_port(0) {}
331
326 IOThread::Globals::~Globals() {} 332 IOThread::Globals::~Globals() {}
327 333
328 // |local_state| is passed in explicitly in order to (1) reduce implicit 334 // |local_state| is passed in explicitly in order to (1) reduce implicit
329 // dependencies and (2) make IOThread more flexible for testing. 335 // dependencies and (2) make IOThread more flexible for testing.
330 IOThread::IOThread( 336 IOThread::IOThread(
331 PrefService* local_state, 337 PrefService* local_state,
332 ChromeNetLog* net_log, 338 ChromeNetLog* net_log,
333 extensions::EventRouterForwarder* extension_event_router_forwarder) 339 extensions::EventRouterForwarder* extension_event_router_forwarder)
334 : net_log_(net_log), 340 : net_log_(net_log),
335 extension_event_router_forwarder_(extension_event_router_forwarder), 341 extension_event_router_forwarder_(extension_event_router_forwarder),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 return system_url_request_context_getter_; 400 return system_url_request_context_getter_;
395 } 401 }
396 402
397 void IOThread::Init() { 403 void IOThread::Init() {
398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
399 405
400 #if defined(USE_NSS) 406 #if defined(USE_NSS)
401 net::SetMessageLoopForNSSHttpIO(); 407 net::SetMessageLoopForNSSHttpIO();
402 #endif // defined(USE_NSS) 408 #endif // defined(USE_NSS)
403 409
410 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
411
404 DCHECK(!globals_); 412 DCHECK(!globals_);
405 globals_ = new Globals; 413 globals_ = new Globals;
406 414
407 // Add an observer that will emit network change events to the ChromeNetLog. 415 // Add an observer that will emit network change events to the ChromeNetLog.
408 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be 416 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be
409 // logging the network change before other IO thread consumers respond to it. 417 // logging the network change before other IO thread consumers respond to it.
410 network_change_observer_.reset( 418 network_change_observer_.reset(
411 new LoggingNetworkChangeObserver(net_log_)); 419 new LoggingNetworkChangeObserver(net_log_));
412 420
413 // Setup the HistogramWatcher to run on the IO thread. 421 // Setup the HistogramWatcher to run on the IO thread.
414 net::NetworkChangeNotifier::InitHistogramWatcher(); 422 net::NetworkChangeNotifier::InitHistogramWatcher();
415 423
416 globals_->extension_event_router_forwarder = 424 globals_->extension_event_router_forwarder =
417 extension_event_router_forwarder_; 425 extension_event_router_forwarder_;
418 ChromeNetworkDelegate* network_delegate = new ChromeNetworkDelegate( 426 ChromeNetworkDelegate* network_delegate = new ChromeNetworkDelegate(
419 extension_event_router_forwarder_, 427 extension_event_router_forwarder_,
420 NULL, 428 NULL,
421 NULL, 429 NULL,
422 NULL, 430 NULL,
423 NULL, 431 NULL,
424 NULL, 432 NULL,
425 &system_enable_referrers_, 433 &system_enable_referrers_,
426 NULL); 434 NULL);
427 if (CommandLine::ForCurrentProcess()->HasSwitch( 435 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling))
428 switches::kDisableExtensionsHttpThrottling)) {
429 network_delegate->NeverThrottleRequests(); 436 network_delegate->NeverThrottleRequests();
430 }
431 globals_->system_network_delegate.reset(network_delegate); 437 globals_->system_network_delegate.reset(network_delegate);
432 globals_->host_resolver.reset( 438 globals_->host_resolver.reset(
433 CreateGlobalHostResolver(net_log_)); 439 CreateGlobalHostResolver(net_log_));
434 globals_->cert_verifier.reset(net::CertVerifier::CreateDefault()); 440 globals_->cert_verifier.reset(net::CertVerifier::CreateDefault());
435 globals_->transport_security_state.reset(new net::TransportSecurityState()); 441 globals_->transport_security_state.reset(new net::TransportSecurityState());
436 globals_->ssl_config_service = GetSSLConfigService(); 442 globals_->ssl_config_service = GetSSLConfigService();
437 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( 443 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory(
438 globals_->host_resolver.get())); 444 globals_->host_resolver.get()));
439 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl); 445 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl);
440 // For the ProxyScriptFetcher, we use a direct ProxyService. 446 // For the ProxyScriptFetcher, we use a direct ProxyService.
441 globals_->proxy_script_fetcher_proxy_service.reset( 447 globals_->proxy_script_fetcher_proxy_service.reset(
442 net::ProxyService::CreateDirectWithNetLog(net_log_)); 448 net::ProxyService::CreateDirectWithNetLog(net_log_));
443 // In-memory cookie store. 449 // In-memory cookie store.
444 globals_->system_cookie_store = new net::CookieMonster(NULL, NULL); 450 globals_->system_cookie_store = new net::CookieMonster(NULL, NULL);
445 // In-memory server bound cert store. 451 // In-memory server bound cert store.
446 globals_->system_server_bound_cert_service.reset( 452 globals_->system_server_bound_cert_service.reset(
447 new net::ServerBoundCertService( 453 new net::ServerBoundCertService(
448 new net::DefaultServerBoundCertStore(NULL), 454 new net::DefaultServerBoundCertStore(NULL),
449 base::WorkerPool::GetTaskRunner(true))); 455 base::WorkerPool::GetTaskRunner(true)));
450 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); 456 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats());
457 globals_->host_mapping_rules.reset(new net::HostMappingRules());
458 if (command_line.HasSwitch(switches::kHostRules)) {
459 globals_->host_mapping_rules->SetRulesFromString(
460 command_line.GetSwitchValueASCII(switches::kHostRules));
461 }
462 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors))
463 globals_->ignore_certificate_errors = true;
464 if (command_line.HasSwitch(switches::kEnableHttpPipelining))
465 globals_->http_pipelining_enabled = true;
466 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
467 int value;
468 base::StringToInt(
469 command_line.GetSwitchValueASCII(
470 switches::kTestingFixedHttpPort),
471 &value);
472 globals_->testing_fixed_http_port = value;
473 }
474 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
475 int value;
476 base::StringToInt(
477 command_line.GetSwitchValueASCII(
478 switches::kTestingFixedHttpsPort),
479 &value);
480 globals_->testing_fixed_https_port = value;
481 }
482
451 net::HttpNetworkSession::Params session_params; 483 net::HttpNetworkSession::Params session_params;
452 session_params.host_resolver = globals_->host_resolver.get(); 484 session_params.host_resolver = globals_->host_resolver.get();
453 session_params.cert_verifier = globals_->cert_verifier.get(); 485 session_params.cert_verifier = globals_->cert_verifier.get();
454 session_params.server_bound_cert_service = 486 session_params.server_bound_cert_service =
455 globals_->system_server_bound_cert_service.get(); 487 globals_->system_server_bound_cert_service.get();
456 session_params.transport_security_state = 488 session_params.transport_security_state =
457 globals_->transport_security_state.get(); 489 globals_->transport_security_state.get();
458 session_params.proxy_service = 490 session_params.proxy_service =
459 globals_->proxy_script_fetcher_proxy_service.get(); 491 globals_->proxy_script_fetcher_proxy_service.get();
492 session_params.ssl_config_service = globals_->ssl_config_service.get();
460 session_params.http_auth_handler_factory = 493 session_params.http_auth_handler_factory =
461 globals_->http_auth_handler_factory.get(); 494 globals_->http_auth_handler_factory.get();
495 session_params.http_server_properties =
496 globals_->http_server_properties.get();
462 session_params.network_delegate = globals_->system_network_delegate.get(); 497 session_params.network_delegate = globals_->system_network_delegate.get();
463 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 498 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
464 // system URLRequestContext too. There's no reason this should be tied to a 499 // system URLRequestContext too. There's no reason this should be tied to a
465 // profile. 500 // profile.
466 session_params.http_server_properties =
467 globals_->http_server_properties.get();
468 session_params.net_log = net_log_; 501 session_params.net_log = net_log_;
469 session_params.ssl_config_service = globals_->ssl_config_service; 502 session_params.host_mapping_rules = globals_->host_mapping_rules.get();
503 session_params.ignore_certificate_errors =
504 globals_->ignore_certificate_errors;
505 session_params.http_pipelining_enabled = globals_->http_pipelining_enabled;
506 session_params.testing_fixed_http_port = globals_->testing_fixed_http_port;
507 session_params.testing_fixed_https_port = globals_->http_pipelining_enabled;
508
470 scoped_refptr<net::HttpNetworkSession> network_session( 509 scoped_refptr<net::HttpNetworkSession> network_session(
471 new net::HttpNetworkSession(session_params)); 510 new net::HttpNetworkSession(session_params));
472 globals_->proxy_script_fetcher_http_transaction_factory.reset( 511 globals_->proxy_script_fetcher_http_transaction_factory.reset(
473 new net::HttpNetworkLayer(network_session)); 512 new net::HttpNetworkLayer(network_session));
474 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( 513 globals_->proxy_script_fetcher_ftp_transaction_factory.reset(
475 new net::FtpNetworkLayer(globals_->host_resolver.get())); 514 new net::FtpNetworkLayer(globals_->host_resolver.get()));
476 515
477 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); 516 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager());
478 globals_->throttler_manager->set_net_log(net_log_); 517 globals_->throttler_manager->set_net_log(net_log_);
479 // Always done in production, disabled only for unit tests. 518 // Always done in production, disabled only for unit tests.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 DCHECK(!globals_->system_proxy_service.get()); 660 DCHECK(!globals_->system_proxy_service.get());
622 DCHECK(system_proxy_config_service_.get()); 661 DCHECK(system_proxy_config_service_.get());
623 662
624 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 663 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
625 globals_->system_proxy_service.reset( 664 globals_->system_proxy_service.reset(
626 ProxyServiceFactory::CreateProxyService( 665 ProxyServiceFactory::CreateProxyService(
627 net_log_, 666 net_log_,
628 globals_->proxy_script_fetcher_context.get(), 667 globals_->proxy_script_fetcher_context.get(),
629 system_proxy_config_service_.release(), 668 system_proxy_config_service_.release(),
630 command_line)); 669 command_line));
670
631 net::HttpNetworkSession::Params system_params; 671 net::HttpNetworkSession::Params system_params;
632 system_params.host_resolver = globals_->host_resolver.get(); 672 system_params.host_resolver = globals_->host_resolver.get();
633 system_params.cert_verifier = globals_->cert_verifier.get(); 673 system_params.cert_verifier = globals_->cert_verifier.get();
634 system_params.server_bound_cert_service = 674 system_params.server_bound_cert_service =
635 globals_->system_server_bound_cert_service.get(); 675 globals_->system_server_bound_cert_service.get();
636 system_params.transport_security_state = 676 system_params.transport_security_state =
637 globals_->transport_security_state.get(); 677 globals_->transport_security_state.get();
638 system_params.proxy_service = globals_->system_proxy_service.get(); 678 system_params.proxy_service = globals_->system_proxy_service.get();
639 system_params.ssl_config_service = globals_->ssl_config_service.get(); 679 system_params.ssl_config_service = globals_->ssl_config_service.get();
640 system_params.http_auth_handler_factory = 680 system_params.http_auth_handler_factory =
641 globals_->http_auth_handler_factory.get(); 681 globals_->http_auth_handler_factory.get();
642 system_params.http_server_properties = globals_->http_server_properties.get(); 682 system_params.http_server_properties = globals_->http_server_properties.get();
643 system_params.network_delegate = globals_->system_network_delegate.get(); 683 system_params.network_delegate = globals_->system_network_delegate.get();
644 system_params.net_log = net_log_; 684 system_params.net_log = net_log_;
685 system_params.host_mapping_rules = globals_->host_mapping_rules.get();
686 system_params.ignore_certificate_errors = globals_->ignore_certificate_errors;
687 system_params.http_pipelining_enabled = globals_->http_pipelining_enabled;
688 system_params.testing_fixed_http_port = globals_->testing_fixed_http_port;
689 system_params.testing_fixed_https_port = globals_->testing_fixed_https_port;
690
645 globals_->system_http_transaction_factory.reset( 691 globals_->system_http_transaction_factory.reset(
646 new net::HttpNetworkLayer( 692 new net::HttpNetworkLayer(
647 new net::HttpNetworkSession(system_params))); 693 new net::HttpNetworkSession(system_params)));
648 globals_->system_ftp_transaction_factory.reset( 694 globals_->system_ftp_transaction_factory.reset(
649 new net::FtpNetworkLayer(globals_->host_resolver.get())); 695 new net::FtpNetworkLayer(globals_->host_resolver.get()));
650 globals_->system_request_context.reset( 696 globals_->system_request_context.reset(
651 ConstructSystemRequestContext(globals_, net_log_)); 697 ConstructSystemRequestContext(globals_, net_log_));
652 698
653 sdch_manager_->set_sdch_fetcher( 699 sdch_manager_->set_sdch_fetcher(
654 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 700 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
655 } 701 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/profiles/off_the_record_profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698