Index: base/message_loop/message_loop.h |
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h |
index e765cef6a3e0b51b574a0140794c026e2e8f45eb..fcc9eb1c77174fdacbaee0e9b1d69e5b6656b517 100644 |
--- a/base/message_loop/message_loop.h |
+++ b/base/message_loop/message_loop.h |
@@ -13,6 +13,7 @@ |
#include "base/callback_forward.h" |
#include "base/location.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/message_loop_proxy.h" |
#include "base/message_loop/message_pump.h" |
#include "base/observer_list.h" |
@@ -47,6 +48,7 @@ namespace base { |
class HistogramBase; |
class MessageLoopLockTest; |
+class MessageLoopProxyImpl; |
class RunLoop; |
class ThreadTaskRunnerHandle; |
#if defined(OS_ANDROID) |
@@ -282,9 +284,7 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
const std::string& thread_name() const { return thread_name_; } |
// Gets the message loop proxy associated with this message loop. |
- scoped_refptr<MessageLoopProxy> message_loop_proxy() { |
- return message_loop_proxy_.get(); |
- } |
+ scoped_refptr<MessageLoopProxy> message_loop_proxy(); |
// Enables or disables the recursive task processing. This happens in the case |
// of recursive message loops. Some unwanted message loop may occurs when |
@@ -402,11 +402,12 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
} |
#endif |
- scoped_refptr<MessagePump> pump_; |
+ scoped_ptr<MessagePump> pump_; |
private: |
friend class RunLoop; |
friend class MessageLoopLockTest; |
+ friend class MessageLoopProxyImpl; |
// A function to encapsulate all the exception handling capability in the |
// stacks around the running of a main message loop. It will run the message |
@@ -436,21 +437,15 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
// Adds the pending task to delayed_work_queue_. |
void AddToDelayedWorkQueue(const PendingTask& pending_task); |
- // This function attempts to add pending task to our incoming_queue_. |
- // The append can only possibly fail when |use_try_lock| is true. |
- // |
- // When |use_try_lock| is true, then this call will avoid blocking if |
- // the related lock is already held, and will in that case (when the |
- // lock is contended) fail to perform the append, and will return false. |
- // |
- // If the call succeeds to append to the queue, then this call |
- // will return true. |
+ // Adds a task to our incoming_queue_. This method can be called on any thread |
+ // and the caller is responsible for synchronizing calls to this method. |
+ // (Currently |message_loop_proxy_->message_loop_lock_| is used). |
// |
- // In all cases, the caller retains ownership of |pending_task|, but this |
- // function will reset the value of pending_task->task. This is needed to |
- // ensure that the posting call stack does not retain pending_task->task |
- // beyond this function call. |
- bool AddToIncomingQueue(PendingTask* pending_task, bool use_try_lock); |
+ // The method takes ownership of |task|. |
+ void AddToIncomingQueue(const tracked_objects::Location& from_here, |
+ const Closure& task, |
+ TimeDelta delay, |
+ bool nestable); |
// Load tasks from the incoming_queue_ into work_queue_ if the latter is |
// empty. The former requires a lock to access, while the latter is directly |
@@ -510,10 +505,9 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
// An incoming queue of tasks that are acquired under a mutex for processing |
// on this instance's thread. These tasks have not yet been sorted out into |
- // items for our work_queue_ vs delayed_work_queue_. |
+ // items for our work_queue_ vs delayed_work_queue_. Protected by |
+ // |message_loop_proxy_->message_loop_lock_|. |
rvargas (doing something else)
2013/06/28 03:00:51
I'm not really comfortable with this pattern of pr
alexeypa (please no reviews)
2013/06/28 17:00:57
Done.
|
TaskQueue incoming_queue_; |
- // Protect access to incoming_queue_. |
- mutable Lock incoming_queue_lock_; |
RunLoop* run_loop_; |
@@ -525,13 +519,13 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
#endif |
// The next sequence number to use for delayed tasks. Updating this counter is |
- // protected by incoming_queue_lock_. |
+ // protected by |message_loop_proxy_->message_loop_lock_|. |
int next_sequence_num_; |
ObserverList<TaskObserver> task_observers_; |
- // The message loop proxy associated with this message loop, if one exists. |
- scoped_refptr<MessageLoopProxy> message_loop_proxy_; |
+ // The message loop proxy associated with this message loop. |
+ scoped_refptr<MessageLoopProxyImpl> message_loop_proxy_; |
scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; |
template <class T, class R> friend class base::subtle::DeleteHelperInternal; |