Index: base/memory/ref_counted_delete_on_message_loop.h |
diff --git a/base/memory/ref_counted_delete_on_message_loop.h b/base/memory/ref_counted_delete_on_message_loop.h |
index 7b898ac00dd015d6b8faa0bc0de665bad2346ca6..139a1edb24f422b879bf23490e39c3afa7e68c98 100644 |
--- a/base/memory/ref_counted_delete_on_message_loop.h |
+++ b/base/memory/ref_counted_delete_on_message_loop.h |
@@ -8,7 +8,9 @@ |
#include "base/location.h" |
#include "base/logging.h" |
#include "base/memory/ref_counted.h" |
+// TODO(ricea): Remove the following include once all callers have been fixed. |
#include "base/message_loop/message_loop_proxy.h" |
+#include "base/single_thread_task_runner.h" |
namespace base { |
@@ -18,7 +20,7 @@ namespace base { |
// Sample usage: |
// class Foo : public RefCountedDeleteOnMessageLoop<Foo> { |
// |
-// Foo(const scoped_refptr<MessageLoopProxy>& loop) |
+// Foo(const scoped_refptr<SingleThreadTaskRunner>& loop) |
// : RefCountedDeleteOnMessageLoop<Foo>(loop) { |
// ... |
// } |
@@ -33,9 +35,14 @@ namespace base { |
template <class T> |
class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase { |
public: |
+ // This constructor will accept a MessageL00pProxy object, but new code should |
+ // prefer a SingleThreadTaskRunner. A SingleThreadTaskRunner for the |
+ // MessageLoop on the current thread can be acquired by calling |
+ // MessageLoop::current()->task_runner(). |
RefCountedDeleteOnMessageLoop( |
- const scoped_refptr<MessageLoopProxy>& proxy) : proxy_(proxy) { |
- DCHECK(proxy_.get()); |
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner) |
+ : task_runner_(task_runner) { |
+ DCHECK(task_runner_.get()); |
} |
void AddRef() const { |
@@ -53,13 +60,13 @@ class RefCountedDeleteOnMessageLoop : public subtle::RefCountedThreadSafeBase { |
void DestructOnMessageLoop() const { |
const T* t = static_cast<const T*>(this); |
- if (proxy_->BelongsToCurrentThread()) |
+ if (task_runner_->BelongsToCurrentThread()) |
delete t; |
else |
- proxy_->DeleteSoon(FROM_HERE, t); |
+ task_runner_->DeleteSoon(FROM_HERE, t); |
} |
- scoped_refptr<MessageLoopProxy> proxy_; |
+ scoped_refptr<SingleThreadTaskRunner> task_runner_; |
private: |
DISALLOW_COPY_AND_ASSIGN(RefCountedDeleteOnMessageLoop); |