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

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

Issue 149238: Change the lifetime of the WebKit thread to be a subset of the IO thread's li... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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/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();
-}
« no previous file with comments | « chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h ('k') | chrome/browser/in_process_webkit/webkit_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698