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

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

Issue 155845: DOM Storage: Add browser-process IPC code + tweak the WebKit Thread. (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/webkit_thread.cc
===================================================================
--- chrome/browser/in_process_webkit/webkit_thread.cc (revision 21342)
+++ chrome/browser/in_process_webkit/webkit_thread.cc (working copy)
@@ -10,15 +10,43 @@
#include "webkit/api/public/WebKit.h"
// This happens on the UI thread before the IO thread has been shut down.
-WebKitThread::WebKitThread() {
+WebKitThread::WebKitThread()
+ : io_message_loop_(ChromeThread::GetMessageLoop(ChromeThread::IO)) {
// 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.
DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::IO));
+ DCHECK(!io_message_loop_);
}
+void WebKitThread::Shutdown() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ DCHECK(io_message_loop_);
+
+ // TODO(jorlow): Start flushing LocalStorage?
+
+ AutoLock lock(io_message_loop_lock_);
+ io_message_loop_ = NULL;
+}
+
+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),
webkit_client_(NULL) {
@@ -29,13 +57,12 @@
webkit_client_ = new BrowserWebKitClientImpl;
DCHECK(webkit_client_);
WebKit::initialize(webkit_client_);
- // Don't do anything heavyweight here since this can block the IO thread from
- // executing (since InitializeThread() is called on the IO thread).
+ // If possible, post initialization tasks to this thread (rather than doing
+ // them now) so we don't block the IO thread any longer than we have to.
}
void WebKitThread::InternalWebKitThread::CleanUp() {
- // Don't do anything heavyweight here since this can block the IO thread from
- // executing (since the thread is shutdown from the IO thread).
+ // TODO(jorlow): Block on LocalStorage being 100% shut down.
DCHECK(webkit_client_);
WebKit::shutdown();
delete webkit_client_;
@@ -45,6 +72,7 @@
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();
« no previous file with comments | « chrome/browser/in_process_webkit/webkit_thread.h ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698