Index: chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc |
=================================================================== |
--- chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc (revision 20100) |
+++ chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc (working copy) |
@@ -16,17 +16,12 @@ |
webkit_thread_(webkit_thread), |
message_sender_(message_sender) { |
DCHECK(webkit_context_.get()); |
- DCHECK(webkit_thread_.get()); |
+ DCHECK(webkit_thread_); |
DCHECK(message_sender_); |
} |
DOMStorageDispatcherHost::~DOMStorageDispatcherHost() { |
- DCHECK(!message_sender_); |
-} |
- |
-void DOMStorageDispatcherHost::Shutdown() { |
- DCHECK(IsOnIOThread()); |
- AutoLock lock(message_sender_lock_); |
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
message_sender_ = NULL; |
} |
@@ -37,34 +32,21 @@ |
} |
void DOMStorageDispatcherHost::Send(IPC::Message* message) { |
- if (IsOnIOThread()) { |
- if (message_sender_) |
- message_sender_->Send(message); |
- else |
- delete message; |
- } |
- |
- // If message_sender_ is NULL, the IO thread has either gone away |
- // or will do so soon. By holding this lock until we finish posting to the |
- // thread, we block the IO thread from completely shutting down benieth us. |
- AutoLock lock(message_sender_lock_); |
if (!message_sender_) { |
delete message; |
return; |
} |
+ if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { |
+ message_sender_->Send(message); |
+ return; |
+ } |
+ |
+ // The IO thread can't dissapear while the WebKit thread is still running. |
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); |
MessageLoop* io_loop = ChromeThread::GetMessageLoop(ChromeThread::IO); |
CancelableTask* task = NewRunnableMethod(this, |
&DOMStorageDispatcherHost::Send, |
message); |
io_loop->PostTask(FROM_HERE, task); |
} |
- |
-bool DOMStorageDispatcherHost::IsOnIOThread() const { |
- MessageLoop* io_loop = ChromeThread::GetMessageLoop(ChromeThread::IO); |
- return MessageLoop::current() == io_loop; |
-} |
- |
-bool DOMStorageDispatcherHost::IsOnWebKitThread() const { |
- return MessageLoop::current() == webkit_thread_->GetMessageLoop(); |
-} |