summaryrefslogtreecommitdiffstats
path: root/base/message_loop_proxy_impl.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 18:25:16 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 18:25:16 +0000
commit180c85e3e3691042ab617fd0755dcde6e75d5fbd (patch)
treeb9d4fd7a77f7f54dce4463960326ef7b0cd7a270 /base/message_loop_proxy_impl.cc
parent324ab8e0d77303333f8ad7de3b54d248587687db (diff)
downloadchromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.zip
chromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.tar.gz
chromium_src-180c85e3e3691042ab617fd0755dcde6e75d5fbd.tar.bz2
Support Closure in ALL the loops!
Add an overload for PostTask into MessageLoopProxy, and WorkerPool. BUG=35223 TEST=unittests. Review URL: http://codereview.chromium.org/7316015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop_proxy_impl.cc')
-rw-r--r--base/message_loop_proxy_impl.cc42
1 files changed, 41 insertions, 1 deletions
diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc
index b47c934..af0d214 100644
--- a/base/message_loop_proxy_impl.cc
+++ b/base/message_loop_proxy_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -40,6 +40,30 @@ bool MessageLoopProxyImpl::PostNonNestableDelayedTask(
return PostTaskHelper(from_here, task, delay_ms, false);
}
+bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ return PostTaskHelper(from_here, task, 0, true);
+}
+
+bool MessageLoopProxyImpl::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) {
+ return PostTaskHelper(from_here, task, delay_ms, true);
+}
+
+bool MessageLoopProxyImpl::PostNonNestableTask(
+ const tracked_objects::Location& from_here, const base::Closure& task) {
+ return PostTaskHelper(from_here, task, 0, false);
+}
+
+bool MessageLoopProxyImpl::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) {
+ return PostTaskHelper(from_here, task, delay_ms, false);
+}
+
bool MessageLoopProxyImpl::BelongsToCurrentThread() {
// We shouldn't use MessageLoop::current() since it uses LazyInstance which
// may be deleted by ~AtExitManager when a WorkerPool thread calls this
@@ -102,6 +126,22 @@ bool MessageLoopProxyImpl::PostTaskHelper(
return ret;
}
+bool MessageLoopProxyImpl::PostTaskHelper(
+ const tracked_objects::Location& from_here, const base::Closure& task,
+ int64 delay_ms, bool nestable) {
+ AutoLock lock(message_loop_lock_);
+ if (target_message_loop_) {
+ if (nestable) {
+ target_message_loop_->PostDelayedTask(from_here, task, delay_ms);
+ } else {
+ target_message_loop_->PostNonNestableDelayedTask(from_here, task,
+ delay_ms);
+ }
+ return true;
+ }
+ return false;
+}
+
scoped_refptr<MessageLoopProxy>
MessageLoopProxy::CreateForCurrentThread() {
scoped_refptr<MessageLoopProxy> ret(new MessageLoopProxyImpl());