Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1153)

Unified Diff: chrome/browser/in_process_webkit/webkit_thread.cc

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/in_process_webkit/webkit_thread.cc
===================================================================
--- chrome/browser/in_process_webkit/webkit_thread.cc (revision 30037)
+++ chrome/browser/in_process_webkit/webkit_thread.cc (working copy)
@@ -10,41 +10,26 @@
#include "webkit/api/public/WebKit.h"
// This happens on the UI thread before the IO thread has been shut down.
-WebKitThread::WebKitThread()
- : io_message_loop_(ChromeThread::GetMessageLoop(ChromeThread::IO)) {
+WebKitThread::WebKitThread() {
// The thread is started lazily by InitializeThread() on the IO thread.
}
// This happens on the UI thread after the IO thread has been shut down.
WebKitThread::~WebKitThread() {
- // There's no good way to see if we're on the UI thread.
+ // We can't just check CurrentlyOn(ChromeThread::UI) because in unit tests,
+ // MessageLoop::Current is sometimes NULL and other times valid and there's
+ // no ChromeThread object. Can't check that CurrentlyOn is not IO since
+ // some unit tests set that ChromeThread for other checks.
DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::IO));
jorlow 2009/10/27 21:37:25 Why did you remove this?
- DCHECK(!io_message_loop_);
}
-void WebKitThread::Shutdown() {
+void WebKitThread::EnsureInitialized() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- DCHECK(io_message_loop_);
-
- AutoLock lock(io_message_loop_lock_);
- io_message_loop_ = NULL;
+ if (webkit_thread_.get())
+ return;
+ InitializeThread();
}
-bool WebKitThread::PostIOThreadTask(
- const tracked_objects::Location& from_here, Task* task) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- {
- AutoLock lock(io_message_loop_lock_);
- if (io_message_loop_) {
- io_message_loop_->PostTask(from_here, task);
- return true;
- }
- }
- delete task;
- return false;
-}
-
WebKitThread::InternalWebKitThread::InternalWebKitThread()
: ChromeThread(ChromeThread::WEBKIT) {
}
@@ -69,7 +54,6 @@
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return NULL;
- DCHECK(io_message_loop_);
DCHECK(!webkit_thread_.get());
webkit_thread_.reset(new InternalWebKitThread);
bool started = webkit_thread_->Start();

Powered by Google App Engine
This is Rietveld 408576698