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(); |