diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-13 21:39:16 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-13 21:39:16 +0000 |
commit | addb3240a6f92131d41b318ed2d880920f30d1c1 (patch) | |
tree | ce67aa4621400a52e8c192f0f2186c689e1e5ee4 /chrome | |
parent | c44a832d5958439c080aed45600ed8b5a4feb846 (diff) | |
download | chromium_src-addb3240a6f92131d41b318ed2d880920f30d1c1.zip chromium_src-addb3240a6f92131d41b318ed2d880920f30d1c1.tar.gz chromium_src-addb3240a6f92131d41b318ed2d880920f30d1c1.tar.bz2 |
Eagerly initialize SystemURLRequestContext.
This makes sure OCSP will have the SURC set for it before the first needed use.
BUG=85653
TEST=builds
Review URL: http://codereview.chromium.org/7129060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/io_thread.cc | 32 | ||||
-rw-r--r-- | chrome/browser/io_thread.h | 7 |
2 files changed, 29 insertions, 10 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index fba8719..aa22c105 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -15,6 +15,7 @@ #include "base/string_split.h" #include "base/string_util.h" #include "base/threading/thread_restrictions.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_event_router_forwarder.h" #include "chrome/browser/net/chrome_network_delegate.h" @@ -289,9 +290,7 @@ SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (!io_thread_->globals()->system_request_context) - io_thread_->InitSystemRequestContext(); + DCHECK(io_thread_->globals()->system_request_context); return io_thread_->globals()->system_request_context; } @@ -320,7 +319,8 @@ IOThread::IOThread( extension_event_router_forwarder_(extension_event_router_forwarder), globals_(NULL), speculative_interceptor_(NULL), - predictor_(NULL) { + predictor_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make // sure that everything is initialized in the right order. RegisterPrefs(local_state); @@ -338,6 +338,9 @@ IOThread::IOThread( local_state); ssl_config_service_manager_.reset( SSLConfigServiceManager::CreateDefaultManager(local_state)); + MessageLoop::current()->PostTask(FROM_HERE, + method_factory_.NewRunnableMethod( + &IOThread::InitSystemRequestContext)); } IOThread::~IOThread() { @@ -412,11 +415,7 @@ void IOThread::ChangedToOnTheRecord() { net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!system_url_request_context_getter_) { - system_proxy_config_service_.reset( - ProxyServiceFactory::CreateProxyConfigService( - pref_proxy_config_tracker_)); - system_url_request_context_getter_ = - new SystemURLRequestContextGetter(this); + InitSystemRequestContext(); } return system_url_request_context_getter_; } @@ -668,6 +667,21 @@ net::SSLConfigService* IOThread::GetSSLConfigService() { } void IOThread::InitSystemRequestContext() { + if (system_url_request_context_getter_) + return; + system_proxy_config_service_.reset( + ProxyServiceFactory::CreateProxyConfigService( + pref_proxy_config_tracker_)); + system_url_request_context_getter_ = + new SystemURLRequestContextGetter(this); + message_loop()->PostTask( + FROM_HERE, + NewRunnableMethod( + this, + &IOThread::InitSystemRequestContextOnIOThread)); +} + +void IOThread::InitSystemRequestContextOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(!globals_->system_proxy_service.get()); DCHECK(system_proxy_config_service_.get()); diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index 1522cfa..1843cdf 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/task.h" #include "chrome/browser/browser_process_sub_thread.h" #include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/prefs/pref_member.h" @@ -145,9 +146,11 @@ class IOThread : public BrowserProcessSubThread { net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( net::HostResolver* resolver); + void InitSystemRequestContext(); + // Lazy initialization of system request context for // SystemURLRequestContextGetter. To be called on IO thread. - void InitSystemRequestContext(); + void InitSystemRequestContextOnIOThread(); void InitNetworkPredictorOnIOThread( bool prefetching_enabled, @@ -225,6 +228,8 @@ class IOThread : public BrowserProcessSubThread { // IOThread::CleanUp(). std::list<ChromeURLRequestContextGetter*> url_request_context_getters_; + ScopedRunnableMethodFactory<IOThread> method_factory_; + DISALLOW_COPY_AND_ASSIGN(IOThread); }; |