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

Unified Diff: base/message_loop/message_loop_proxy_impl.h

Issue 17567007: Made MessagePump a non-thread safe class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 7 years, 6 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: 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_;

Powered by Google App Engine
This is Rietveld 408576698