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

Unified Diff: webkit/glue/webthread_impl.cc

Issue 9167034: Add support for Run + Quit to WebKit::WebThread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update with MessageLoop-agnostic API names Created 8 years, 11 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
« no previous file with comments | « webkit/glue/webthread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webthread_impl.cc
diff --git a/webkit/glue/webthread_impl.cc b/webkit/glue/webthread_impl.cc
index 439137fb380d5a34d2a3496aab6e4eeeab27ac69..170746f3ef7fe637ce4ae119614c78e5adcc10fb 100644
--- a/webkit/glue/webthread_impl.cc
+++ b/webkit/glue/webthread_impl.cc
@@ -70,6 +70,18 @@ void WebThreadImpl::postDelayedTask(
base::TimeDelta::FromMilliseconds(delay_ms));
}
+void WebThreadImpl::enterRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(!thread_->message_loop()->is_running()); // We don't support nesting.
+ thread_->message_loop()->Run();
+}
+
+void WebThreadImpl::exitRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(thread_->message_loop()->is_running());
+ thread_->message_loop()->Quit();
+}
+
bool WebThreadImpl::IsCurrentThread() const {
return thread_->thread_id() == base::PlatformThread::CurrentId();
}
@@ -79,8 +91,9 @@ WebThreadImpl::~WebThreadImpl() {
}
WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
- base::MessageLoopProxy* message_loop)
- : message_loop_(message_loop) {
+ MessageLoop* message_loop, base::PlatformThreadId thread_id)
+ : message_loop_(message_loop)
+ , thread_id_(thread_id) {
}
void WebThreadImplForMessageLoop::postTask(Task* task) {
@@ -96,8 +109,20 @@ void WebThreadImplForMessageLoop::postDelayedTask(
delay_ms);
}
+void WebThreadImplForMessageLoop::enterRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(!message_loop_->is_running()); // We don't support nesting.
+ message_loop_->Run();
darin (slow to review) 2012/01/19 17:57:36 you could also just use MessageLoop::current()->Ru
+}
+
+void WebThreadImplForMessageLoop::exitRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(message_loop_->is_running());
+ message_loop_->Quit();
+}
+
bool WebThreadImplForMessageLoop::IsCurrentThread() const {
- return message_loop_->BelongsToCurrentThread();
+ return thread_id_ == base::PlatformThread::CurrentId();
}
WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {
« no previous file with comments | « webkit/glue/webthread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698