summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webthread_impl.cc24
-rw-r--r--webkit/glue/webthread_impl.h16
2 files changed, 35 insertions, 5 deletions
diff --git a/webkit/glue/webthread_impl.cc b/webkit/glue/webthread_impl.cc
index 439137f..5648be0 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();
}
@@ -96,6 +108,18 @@ void WebThreadImplForMessageLoop::postDelayedTask(
delay_ms);
}
+void WebThreadImplForMessageLoop::enterRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(!MessageLoop::current()->is_running()); // We don't support nesting.
+ MessageLoop::current()->Run();
+}
+
+void WebThreadImplForMessageLoop::exitRunLoop() {
+ CHECK(IsCurrentThread());
+ CHECK(MessageLoop::current()->is_running());
+ MessageLoop::current()->Quit();
+}
+
bool WebThreadImplForMessageLoop::IsCurrentThread() const {
return message_loop_->BelongsToCurrentThread();
}
diff --git a/webkit/glue/webthread_impl.h b/webkit/glue/webthread_impl.h
index e39d6bf..9873686 100644
--- a/webkit/glue/webthread_impl.h
+++ b/webkit/glue/webthread_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_WEBTHREAD_IMPL_H_
@@ -37,8 +37,11 @@ class WebThreadImpl : public WebThreadBase {
WEBKIT_GLUE_EXPORT explicit WebThreadImpl(const char* name);
WEBKIT_GLUE_EXPORT virtual ~WebThreadImpl();
- virtual void postTask(Task* task) OVERRIDE;
- virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE;
+ virtual void postTask(Task* task);
+ virtual void postDelayedTask(Task* task, long long delay_ms);
+
+ virtual void enterRunLoop();
+ virtual void exitRunLoop();
MessageLoop* message_loop() const { return thread_->message_loop(); }
@@ -52,8 +55,11 @@ class WebThreadImplForMessageLoop : public WebThreadBase {
explicit WebThreadImplForMessageLoop(base::MessageLoopProxy* message_loop);
virtual ~WebThreadImplForMessageLoop();
- virtual void postTask(Task* task) OVERRIDE;
- virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE;
+ virtual void postTask(Task* task);
+ virtual void postDelayedTask(Task* task, long long delay_ms);
+
+ virtual void enterRunLoop();
+ virtual void exitRunLoop();
private:
virtual bool IsCurrentThread() const OVERRIDE;