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