diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 20:58:01 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 20:58:01 +0000 |
commit | 875ee82945cfb42b16891c2aa5cca7101fc121e4 (patch) | |
tree | 87695916e983accc2f7ed06b1339728ffe6d6bb3 /chrome | |
parent | 03de43e619d7b65ec012e21fbcedd8041be5d776 (diff) | |
download | chromium_src-875ee82945cfb42b16891c2aa5cca7101fc121e4.zip chromium_src-875ee82945cfb42b16891c2aa5cca7101fc121e4.tar.gz chromium_src-875ee82945cfb42b16891c2aa5cca7101fc121e4.tar.bz2 |
Create a dedicated cache thread and use it to create the
Http cache.
BUG=26730
TEST=none
Review URL: http://codereview.chromium.org/1989014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main.cc | 1 | ||||
-rw-r--r-- | chrome/browser/browser_process.h | 3 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 17 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 11 | ||||
-rw-r--r-- | chrome/browser/chrome_thread.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chrome_thread.h | 3 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 12 | ||||
-rw-r--r-- | chrome/test/testing_browser_process.h | 4 |
8 files changed, 46 insertions, 6 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 75d74c4..c58fbd6 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -388,6 +388,7 @@ void CreateChildThreads(BrowserProcessImpl* process) { process->db_thread(); process->file_thread(); process->process_launcher_thread(); + process->cache_thread(); process->io_thread(); } diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index 91614b6..8e05348 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -94,6 +94,9 @@ class BrowserProcess { // database. History has its own thread since it has much higher traffic. virtual base::Thread* db_thread() = 0; + // Returns the thread that is used for background cache operations. + virtual base::Thread* cache_thread() = 0; + #if defined(USE_X11) // Returns the thread that is used to process UI requests in cases where // we can't route the request to the UI thread. Note that this thread diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 9c118bb..f630571 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -78,6 +78,7 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) created_file_thread_(false), created_db_thread_(false), created_process_launcher_thread_(false), + created_cache_thread_(false), created_profile_manager_(false), created_local_state_(false), created_icon_manager_(false), @@ -155,6 +156,9 @@ BrowserProcessImpl::~BrowserProcessImpl() { // request before going away. io_thread_.reset(); + // The IO thread was the only user of this thread. + cache_thread_.reset(); + // Stop the process launcher thread after the IO thread, in case the IO thread // posted a task to terminate a process on the process launcher thread. process_launcher_thread_.reset(); @@ -378,6 +382,19 @@ void BrowserProcessImpl::CreateProcessLauncherThread() { process_launcher_thread_.swap(thread); } +void BrowserProcessImpl::CreateCacheThread() { + DCHECK(!created_cache_thread_ && !cache_thread_.get()); + created_cache_thread_ = true; + + scoped_ptr<base::Thread> thread( + new BrowserProcessSubThread(ChromeThread::CACHE)); + base::Thread::Options options; + options.message_loop_type = MessageLoop::TYPE_IO; + if (!thread->StartWithOptions(options)) + return; + cache_thread_.swap(thread); +} + void BrowserProcessImpl::CreateProfileManager() { DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL); created_profile_manager_ = true; diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index d476b58..703d70c 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -76,6 +76,13 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { return process_launcher_thread_.get(); } + virtual base::Thread* cache_thread() { + DCHECK(CalledOnValidThread()); + if (!created_cache_thread_) + CreateCacheThread(); + return cache_thread_.get(); + } + #if defined(USE_X11) virtual base::Thread* background_x11_thread() { DCHECK(CalledOnValidThread()); @@ -221,6 +228,7 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { void CreateFileThread(); void CreateDBThread(); void CreateProcessLauncherThread(); + void CreateCacheThread(); void CreateTemplateURLModel(); void CreateProfileManager(); void CreateWebDataService(); @@ -260,6 +268,9 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { bool created_process_launcher_thread_; scoped_ptr<base::Thread> process_launcher_thread_; + bool created_cache_thread_; + scoped_ptr<base::Thread> cache_thread_; + bool created_profile_manager_; scoped_ptr<ProfileManager> profile_manager_; diff --git a/chrome/browser/chrome_thread.cc b/chrome/browser/chrome_thread.cc index a9c6092..984d188 100644 --- a/chrome/browser/chrome_thread.cc +++ b/chrome/browser/chrome_thread.cc @@ -14,6 +14,7 @@ static const char* chrome_thread_names[ChromeThread::ID_COUNT] = { "Chrome_WebKitThread", // WEBKIT "Chrome_FileThread", // FILE "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER + "Chrome_CacheThread", // CACHE "Chrome_IOThread", // IO #if defined(USE_X11) "Chrome_Background_X11Thread", // BACKGROUND_X11 diff --git a/chrome/browser/chrome_thread.h b/chrome/browser/chrome_thread.h index da7493f..5dbedfa 100644 --- a/chrome/browser/chrome_thread.h +++ b/chrome/browser/chrome_thread.h @@ -55,6 +55,9 @@ class ChromeThread : public base::Thread { // Used to launch and terminate processes. PROCESS_LAUNCHER, + // This is the thread to handle slow HTTP cache operations. + CACHE, + // This is the thread that processes IPC and network messages. IO, diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 061ee29..aff7ba3 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -247,9 +247,9 @@ ChromeURLRequestContext* FactoryForOriginal::Create() { command_line, MessageLoop::current() /*io_loop*/)); - net::HttpCache::DefaultBackend* backend = - new net::HttpCache::DefaultBackend(net::DISK_CACHE, disk_cache_path_, - cache_size_, NULL); + net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( + net::DISK_CACHE, disk_cache_path_, cache_size_, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::CACHE)); net::HttpCache* cache = new net::HttpCache(io_thread()->globals()->network_change_notifier.get(), context->host_resolver(), @@ -446,9 +446,9 @@ ChromeURLRequestContext* FactoryForMedia::Create() { // Create a media cache with default size. // TODO(hclam): make the maximum size of media cache configurable. - net::HttpCache::DefaultBackend* backend = - new net::HttpCache::DefaultBackend(net::MEDIA_CACHE, disk_cache_path_, - cache_size_, NULL); + net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( + net::MEDIA_CACHE, disk_cache_path_, cache_size_, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::CACHE)); net::HttpCache* main_cache = main_context->http_transaction_factory()->GetCache(); diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h index e704330..fdfe776 100644 --- a/chrome/test/testing_browser_process.h +++ b/chrome/test/testing_browser_process.h @@ -61,6 +61,10 @@ class TestingBrowserProcess : public BrowserProcess { return NULL; } + virtual base::Thread* cache_thread() { + return NULL; + } + virtual ProfileManager* profile_manager() { return NULL; } |