Index: base/message_loop/message_loop_proxy_impl.h |
diff --git a/base/message_loop/message_loop_proxy_impl.h b/base/message_loop/message_loop_proxy_impl.h |
index 2269023ac2d19c0f9074fcadf181a3a9da1f3f51..575365101bc6e00351d49e6edd61cb5740e62941 100644 |
--- a/base/message_loop/message_loop_proxy_impl.h |
+++ b/base/message_loop/message_loop_proxy_impl.h |
@@ -37,6 +37,7 @@ class BASE_EXPORT MessageLoopProxyImpl : public MessageLoopProxy { |
private: |
// Allow the MessageLoop to create a MessageLoopProxyImpl. |
friend class MessageLoop; |
+ friend class MessageLoopLockTest; |
friend class DeleteHelper<MessageLoopProxyImpl>; |
MessageLoopProxyImpl(); |
@@ -44,11 +45,23 @@ class BASE_EXPORT MessageLoopProxyImpl : public MessageLoopProxy { |
// Called directly by MessageLoop::~MessageLoop. |
virtual void WillDestroyCurrentMessageLoop(); |
+ // Takes |message_loop_lock_| and posts a task to |target_message_loop_|. |
+ // Posting of all tasks is routed though one these functions ensuring that |
+ // |message_loop_lock_| is always while modifying the incoming queue. |
+ // |
+ // Returns true if the task was successfully added to the queue, otherwise |
+ // returns false. In all cases, the ownership of |task| is transferred to the |
+ // called method. |
+ bool AddToIncomingQueue(const tracked_objects::Location& from_here, |
+ const Closure& task, |
+ TimeDelta delay, |
+ bool nestable); |
- bool PostTaskHelper(const tracked_objects::Location& from_here, |
- const base::Closure& task, |
- base::TimeDelta delay, |
- bool nestable); |
+ // Same as AddToIncomingQueue() except that it will avoid blocking if the lock |
+ // is already held, and will in that case (when the lock is contended) fail to |
+ // add the task, and will return false. |
+ bool TryAddToIncomingQueue(const tracked_objects::Location& from_here, |
+ const Closure& task); |
// The lock that protects access to target_message_loop_. |
mutable base::Lock message_loop_lock_; |