summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 12:51:39 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-28 12:51:39 +0000
commit042666f262a0c2ff601402e95f94fe9664a03f17 (patch)
tree508140a07a104fd3dd03b4c4c6548161de30f67f /content/shell
parent1d697f38d70b8edaca243a49f790b525c1c95a9d (diff)
downloadchromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.zip
chromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.tar.gz
chromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.tar.bz2
Have content/ create and destroy its own threads.
Change embedding API and embedders to allow for this. Push inheritance of base::Thread down to content::BrowserThreadImpl so that content::BrowserThread is just a namespace for API functions. This change temporarily disables chrome_frame_net_tests as agreed by the CF lead, see bug 105435. TBR=ben@chromium.org (IWYU change only) BUG=98716,104578,105435 Review URL: http://codereview.chromium.org/8477004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell_browser_context.cc7
-rw-r--r--content/shell/shell_browser_main.cc49
-rw-r--r--content/shell/shell_browser_main.h19
3 files changed, 29 insertions, 46 deletions
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index 0f75d89..f011b32 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/threading/thread.h"
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/chrome_blob_storage_context.h"
#include "content/browser/download/download_id_factory.h"
@@ -140,8 +141,10 @@ net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() {
if (!url_request_getter_) {
url_request_getter_ = new ShellURLRequestContextGetter(
GetPath(),
- shell_main_parts_->io_thread()->message_loop(),
- shell_main_parts_->file_thread()->message_loop());
+ BrowserThread::UnsafeGetBrowserThread(
+ BrowserThread::IO)->message_loop(),
+ BrowserThread::UnsafeGetBrowserThread(
+ BrowserThread::FILE)->message_loop());
}
return url_request_getter_;
}
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index a5f2fbe..324139e 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -40,41 +40,9 @@ ShellBrowserMainParts::ShellBrowserMainParts(
}
ShellBrowserMainParts::~ShellBrowserMainParts() {
- base::ThreadRestrictions::SetIOAllowed(true);
- io_thread()->message_loop()->PostTask(
- FROM_HERE, base::IgnoreReturn<bool>(
- base::Bind(&base::ThreadRestrictions::SetIOAllowed, true)));
-
- browser_context_.reset();
-
- resource_dispatcher_host_->download_file_manager()->Shutdown();
- resource_dispatcher_host_->save_file_manager()->Shutdown();
- resource_dispatcher_host_->Shutdown();
- io_thread_.reset();
- cache_thread_.reset();
- process_launcher_thread_.reset();
- file_thread_.reset();
- resource_dispatcher_host_.reset(); // Kills WebKit thread.
- db_thread_.reset();
}
-void ShellBrowserMainParts::PreMainMessageLoopRun() {
- db_thread_.reset(new BrowserProcessSubThread(BrowserThread::DB));
- db_thread_->Start();
- file_thread_.reset(new BrowserProcessSubThread(BrowserThread::FILE));
- file_thread_->Start();
- process_launcher_thread_.reset(
- new BrowserProcessSubThread(BrowserThread::PROCESS_LAUNCHER));
- process_launcher_thread_->Start();
-
- base::Thread::Options options;
- options.message_loop_type = MessageLoop::TYPE_IO;
-
- cache_thread_.reset(new BrowserProcessSubThread(BrowserThread::CACHE));
- cache_thread_->StartWithOptions(options);
- io_thread_.reset(new BrowserProcessSubThread(BrowserThread::IO));
- io_thread_->StartWithOptions(options);
-
+void ShellBrowserMainParts::PreCreateThreads() {
browser_context_.reset(new ShellBrowserContext(this));
Shell::PlatformInitialize();
@@ -85,7 +53,22 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
NULL,
MSG_ROUTING_NONE,
NULL);
+}
+
+void ShellBrowserMainParts::PostMainMessageLoopRun() {
+ browser_context_.reset();
+ resource_dispatcher_host_->download_file_manager()->Shutdown();
+ resource_dispatcher_host_->save_file_manager()->Shutdown();
+ resource_dispatcher_host_->Shutdown();
+}
+
+void ShellBrowserMainParts::PreStopThread(BrowserThread::ID id) {
+ if (id == BrowserThread::WEBKIT) {
+ // It remains the embedder's responsibility to kill the WebKit
+ // thread. This happens when RDH is destroyed.
+ resource_dispatcher_host_.reset();
+ }
}
bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
diff --git a/content/shell/shell_browser_main.h b/content/shell/shell_browser_main.h
index 0e617ca..ffa44e6 100644
--- a/content/shell/shell_browser_main.h
+++ b/content/shell/shell_browser_main.h
@@ -35,28 +35,25 @@ class ShellBrowserMainParts : public BrowserMainParts {
virtual void PreMainMessageLoopStart() OVERRIDE {}
virtual void ToolkitInitialized() OVERRIDE {}
virtual void PostMainMessageLoopStart() OVERRIDE {}
- virtual void PreMainMessageLoopRun() OVERRIDE;
+ virtual void PreCreateThreads() OVERRIDE;
+ virtual void PreStartThread(BrowserThread::ID id) OVERRIDE {}
+ virtual void PostStartThread(BrowserThread::ID id) OVERRIDE {}
+ virtual void PreMainMessageLoopRun() OVERRIDE {}
virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
- virtual void PostMainMessageLoopRun() OVERRIDE {}
+ virtual void PostMainMessageLoopRun() OVERRIDE;
+ virtual void PreStopThread(BrowserThread::ID id) OVERRIDE;
+ virtual void PostStopThread(BrowserThread::ID) OVERRIDE {}
+ virtual void PostDestroyThreads() OVERRIDE {}
ResourceDispatcherHost* GetResourceDispatcherHost();
ui::Clipboard* GetClipboard();
- base::Thread* io_thread() { return io_thread_.get(); }
- base::Thread* file_thread() { return file_thread_.get(); }
-
private:
scoped_ptr<ShellBrowserContext> browser_context_;
scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
scoped_ptr<ui::Clipboard> clipboard_;
- scoped_ptr<base::Thread> io_thread_;
- scoped_ptr<base::Thread> file_thread_;
- scoped_ptr<base::Thread> db_thread_;
- scoped_ptr<base::Thread> process_launcher_thread_;
- scoped_ptr<base::Thread> cache_thread_;
-
DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
};