Commit c2b77b23 authored by joi@chromium.org's avatar joi@chromium.org

Start/stop WebKitThread from BrowserMainLoop like other BrowserThreads.

Move WebKitThread to the content namespace.

Re-order thread objects in BrowserMainLoop declaration to match instantiation order.

BUG=98716


Review URL: http://codereview.chromium.org/8776007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112682 0039d316-1c4b-4281-b951-d872f2087c98
parent a92534e1
...@@ -274,9 +274,7 @@ void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) { ...@@ -274,9 +274,7 @@ void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) {
case BrowserThread::WEBKIT: case BrowserThread::WEBKIT:
// Need to destroy ResourceDispatcherHost before PluginService // Need to destroy ResourceDispatcherHost before PluginService
// and SafeBrowsingService, since it caches a pointer to // and SafeBrowsingService, since it caches a pointer to
// it. This also causes the webkit thread to terminate (which is // it.
// still the responsibility of the embedder, not of the content
// framework).
resource_dispatcher_host_.reset(); resource_dispatcher_host_.reset();
break; break;
default: default:
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/in_process_webkit/webkit_context.h"
#include "content/browser/in_process_webkit/webkit_thread.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread; using content::BrowserThread;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/browser/browser_thread_impl.h" #include "content/browser/browser_thread_impl.h"
#include "content/browser/in_process_webkit/webkit_thread.h"
#include "content/browser/trace_controller.h" #include "content/browser/trace_controller.h"
#include "content/common/hi_res_timer_manager.h" #include "content/common/hi_res_timer_manager.h"
#include "content/common/sandbox_policy.h" #include "content/common/sandbox_policy.h"
...@@ -320,10 +321,8 @@ void BrowserMainLoop::RunMainMessageLoopParts( ...@@ -320,10 +321,8 @@ void BrowserMainLoop::RunMainMessageLoopParts(
thread_to_start = &db_thread_; thread_to_start = &db_thread_;
break; break;
case BrowserThread::WEBKIT: case BrowserThread::WEBKIT:
// For now, the WebKit thread in the browser is owned by // Special case as WebKitThread is a separate
// ResourceDispatcherHost, not by the content framework. Until // type. |thread_to_start| is not used in this case.
// this is fixed, we don't start the thread but still call
// Pre/PostStartThread for the ID.
break; break;
case BrowserThread::FILE: case BrowserThread::FILE:
thread_to_start = &file_thread_; thread_to_start = &file_thread_;
...@@ -365,9 +364,14 @@ void BrowserMainLoop::RunMainMessageLoopParts( ...@@ -365,9 +364,14 @@ void BrowserMainLoop::RunMainMessageLoopParts(
if (parts_.get()) if (parts_.get())
parts_->PreStartThread(id); parts_->PreStartThread(id);
if (thread_to_start) { if (thread_id == BrowserThread::WEBKIT) {
webkit_thread_.reset(new WebKitThread);
webkit_thread_->Initialize();
} else if (thread_to_start) {
(*thread_to_start).reset(new BrowserProcessSubThread(id)); (*thread_to_start).reset(new BrowserProcessSubThread(id));
(*thread_to_start)->StartWithOptions(*options); (*thread_to_start)->StartWithOptions(*options);
} else {
NOTREACHED();
} }
if (parts_.get()) if (parts_.get())
...@@ -443,10 +447,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { ...@@ -443,10 +447,8 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
thread_to_stop = &db_thread_; thread_to_stop = &db_thread_;
break; break;
case BrowserThread::WEBKIT: case BrowserThread::WEBKIT:
// For now, the WebKit thread in the browser is owned by // Special case as WebKitThread is a separate
// ResourceDispatcherHost, not by the content framework. Until // type. |thread_to_stop| is not used in this case.
// this is fixed, we don't stop the thread but still call
// Pre/PostStopThread for the ID.
break; break;
case BrowserThread::FILE: case BrowserThread::FILE:
thread_to_stop = &file_thread_; thread_to_stop = &file_thread_;
...@@ -476,8 +478,15 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() { ...@@ -476,8 +478,15 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
if (parts_.get()) if (parts_.get())
parts_->PreStopThread(id); parts_->PreStopThread(id);
if (thread_to_stop)
if (id == BrowserThread::WEBKIT) {
webkit_thread_.reset();
} else if (thread_to_stop) {
thread_to_stop->reset(); thread_to_stop->reset();
} else {
NOTREACHED();
}
if (parts_.get()) if (parts_.get())
parts_->PostStopThread(id); parts_->PostStopThread(id);
} }
......
...@@ -29,6 +29,7 @@ class BrowserMainParts; ...@@ -29,6 +29,7 @@ class BrowserMainParts;
class BrowserShutdownImpl; class BrowserShutdownImpl;
class BrowserThreadImpl; class BrowserThreadImpl;
struct MainFunctionParams; struct MainFunctionParams;
class WebKitThread;
// Implements the main browser loop stages called from |BrowserMain()|. // Implements the main browser loop stages called from |BrowserMain()|.
// See comments in browser_main_parts.h for additional info. // See comments in browser_main_parts.h for additional info.
...@@ -78,11 +79,12 @@ class BrowserMainLoop { ...@@ -78,11 +79,12 @@ class BrowserMainLoop {
// Members initialized in |InitializeMainThread()| --------------------------- // Members initialized in |InitializeMainThread()| ---------------------------
// This must get destroyed before other threads that are created in parts_. // This must get destroyed before other threads that are created in parts_.
scoped_ptr<BrowserThreadImpl> main_thread_; scoped_ptr<BrowserThreadImpl> main_thread_;
scoped_ptr<BrowserProcessSubThread> io_thread_;
scoped_ptr<BrowserProcessSubThread> file_thread_;
scoped_ptr<BrowserProcessSubThread> db_thread_; scoped_ptr<BrowserProcessSubThread> db_thread_;
scoped_ptr<WebKitThread> webkit_thread_;
scoped_ptr<BrowserProcessSubThread> file_thread_;
scoped_ptr<BrowserProcessSubThread> process_launcher_thread_; scoped_ptr<BrowserProcessSubThread> process_launcher_thread_;
scoped_ptr<BrowserProcessSubThread> cache_thread_; scoped_ptr<BrowserProcessSubThread> cache_thread_;
scoped_ptr<BrowserProcessSubThread> io_thread_;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
scoped_ptr<BrowserProcessSubThread> web_socket_proxy_thread_; scoped_ptr<BrowserProcessSubThread> web_socket_proxy_thread_;
#endif #endif
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
using content::BrowserThread; namespace content {
WebKitThread::WebKitThread() { WebKitThread::WebKitThread() {
} }
...@@ -66,3 +66,5 @@ void WebKitThread::InternalWebKitThread::CleanUp() { ...@@ -66,3 +66,5 @@ void WebKitThread::InternalWebKitThread::CleanUp() {
DCHECK(webkit_platform_support_.get()); DCHECK(webkit_platform_support_.get());
WebKit::shutdown(); WebKit::shutdown();
} }
} // namespace content
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
class BrowserWebKitPlatformSupportImpl; class BrowserWebKitPlatformSupportImpl;
namespace content {
// This creates a WebKit main thread on instantiation (if not in // This creates a WebKit main thread on instantiation (if not in
// --single-process mode) on construction and kills it on deletion. // --single-process mode) on construction and kills it on deletion.
class CONTENT_EXPORT WebKitThread { class CONTENT_EXPORT WebKitThread {
...@@ -45,4 +47,6 @@ class CONTENT_EXPORT WebKitThread { ...@@ -45,4 +47,6 @@ class CONTENT_EXPORT WebKitThread {
DISALLOW_COPY_AND_ASSIGN(WebKitThread); DISALLOW_COPY_AND_ASSIGN(WebKitThread);
}; };
} // namespace content
#endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_THREAD_H_ #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_THREAD_H_
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "content/browser/in_process_webkit/webkit_thread.h" #include "content/browser/in_process_webkit/webkit_thread.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread; namespace content {
TEST(WebKitThreadTest, DISABLED_ExposedInBrowserThread) { TEST(WebKitThreadTest, DISABLED_ExposedInBrowserThread) {
int* null = NULL; // Help the template system out. int* null = NULL; // Help the template system out.
...@@ -22,3 +22,5 @@ TEST(WebKitThreadTest, DISABLED_ExposedInBrowserThread) { ...@@ -22,3 +22,5 @@ TEST(WebKitThreadTest, DISABLED_ExposedInBrowserThread) {
EXPECT_FALSE(BrowserThread::DeleteSoon(BrowserThread::WEBKIT, EXPECT_FALSE(BrowserThread::DeleteSoon(BrowserThread::WEBKIT,
FROM_HERE, null)); FROM_HERE, null));
} }
} // namespace content
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_resource_handler.h"
#include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_file_manager.h"
#include "content/browser/download/save_file_resource_handler.h" #include "content/browser/download/save_file_resource_handler.h"
#include "content/browser/in_process_webkit/webkit_thread.h"
#include "content/browser/plugin_service.h" #include "content/browser/plugin_service.h"
#include "content/browser/renderer_host/async_resource_handler.h" #include "content/browser/renderer_host/async_resource_handler.h"
#include "content/browser/renderer_host/buffered_resource_handler.h" #include "content/browser/renderer_host/buffered_resource_handler.h"
...@@ -296,7 +295,6 @@ ResourceDispatcherHost::ResourceDispatcherHost( ...@@ -296,7 +295,6 @@ ResourceDispatcherHost::ResourceDispatcherHost(
download_file_manager_(new DownloadFileManager(this))), download_file_manager_(new DownloadFileManager(this))),
ALLOW_THIS_IN_INITIALIZER_LIST( ALLOW_THIS_IN_INITIALIZER_LIST(
save_file_manager_(new SaveFileManager(this))), save_file_manager_(new SaveFileManager(this))),
webkit_thread_(new WebKitThread),
request_id_(-1), request_id_(-1),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
is_shutdown_(false), is_shutdown_(false),
...@@ -319,7 +317,6 @@ ResourceDispatcherHost::~ResourceDispatcherHost() { ...@@ -319,7 +317,6 @@ ResourceDispatcherHost::~ResourceDispatcherHost() {
void ResourceDispatcherHost::Initialize() { void ResourceDispatcherHost::Initialize() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
webkit_thread_->Initialize();
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered)); base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered));
......
...@@ -38,7 +38,6 @@ class ResourceHandler; ...@@ -38,7 +38,6 @@ class ResourceHandler;
class ResourceMessageFilter; class ResourceMessageFilter;
class SaveFileManager; class SaveFileManager;
class TabContents; class TabContents;
class WebKitThread;
struct DownloadSaveInfo; struct DownloadSaveInfo;
struct GlobalRequestID; struct GlobalRequestID;
struct ResourceHostMsg_Request; struct ResourceHostMsg_Request;
...@@ -151,10 +150,6 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { ...@@ -151,10 +150,6 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
return save_file_manager_; return save_file_manager_;
} }
WebKitThread* webkit_thread() const {
return webkit_thread_.get();
}
// Called when the unload handler for a cross-site request has finished. // Called when the unload handler for a cross-site request has finished.
void OnSwapOutACK(const ViewMsg_SwapOut_Params& params); void OnSwapOutACK(const ViewMsg_SwapOut_Params& params);
...@@ -457,9 +452,6 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { ...@@ -457,9 +452,6 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// We own the save file manager. // We own the save file manager.
scoped_refptr<SaveFileManager> save_file_manager_; scoped_refptr<SaveFileManager> save_file_manager_;
// We own the WebKit thread and see to its destruction.
scoped_ptr<WebKitThread> webkit_thread_;
// Request ID for browser initiated requests. request_ids generated by // Request ID for browser initiated requests. request_ids generated by
// child processes are counted up from 0, while browser created requests // child processes are counted up from 0, while browser created requests
// start at -2 and go down from there. (We need to start at -2 because -1 is // start at -2 and go down from there. (We need to start at -2 because -1 is
......
...@@ -67,8 +67,6 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() { ...@@ -67,8 +67,6 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
void ShellBrowserMainParts::PreStopThread(BrowserThread::ID id) { void ShellBrowserMainParts::PreStopThread(BrowserThread::ID id) {
if (id == BrowserThread::WEBKIT) { 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(); resource_dispatcher_host_.reset();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment