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

Unified Diff: base/message_loop_proxy.h

Issue 10278009: Merge MessageLoopProxy and MessageLoopProxyImpl Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « base/base.gypi ('k') | base/message_loop_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop_proxy.h
diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h
index 320ccfb079921e47d33d2b1c89f353960aefe56f..4e4a6c67cd1f0dd031c8c4542502f3a2a20245ae 100644
--- a/base/message_loop_proxy.h
+++ b/base/message_loop_proxy.h
@@ -10,6 +10,9 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
+#include "base/synchronization/lock.h"
+
+class MessageLoop;
namespace base {
@@ -20,18 +23,60 @@ namespace base {
// Thread::message_loop_proxy()
// MessageLoop::current()->message_loop_proxy()
// MessageLoopProxy::current()
-//
-// TODO(akalin): Now that we have the *TaskRunner interfaces, we can
-// merge this with MessageLoopProxyImpl.
class BASE_EXPORT MessageLoopProxy : public SingleThreadTaskRunner {
public:
// Gets the MessageLoopProxy for the current message loop, creating one if
// needed.
static scoped_refptr<MessageLoopProxy> current();
+ // TaskRunner implementation
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE;
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
+
+ // SequencedTaskRunner implementation
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE;
+
protected:
+ // TaskRunner implementation
+ //
+ // Override OnDestruct so that we can delete the object on the target message
+ // loop if it still exists.
+ virtual void OnDestruct() const OVERRIDE;
+
+ private:
+ // Allow the MessageLoop to create a MessageLoopProxy.
+ friend class ::MessageLoop;
+ friend class DeleteHelper<MessageLoopProxy>;
+
MessageLoopProxy();
virtual ~MessageLoopProxy();
+
+ // Called directly by MessageLoop::~MessageLoop.
+ void WillDestroyCurrentMessageLoop();
+
+
+ bool PostTaskHelper(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay,
+ bool nestable);
+
+ // The lock that protects access to target_message_loop_.
+ mutable base::Lock message_loop_lock_;
+ MessageLoop* target_message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopProxy);
};
} // namespace base
« no previous file with comments | « base/base.gypi ('k') | base/message_loop_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698