Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_ | 5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_ |
| 6 #define BASE_MESSAGE_LOOP_PROXY_H_ | 6 #define BASE_MESSAGE_LOOP_PROXY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 struct MessageLoopProxyTraits; | 15 struct MessageLoopProxyTraits; |
| 16 | 16 |
| 17 // This class provides a thread-safe refcounted interface to the Post* methods | 17 // This class provides a thread-safe refcounted interface to the Post* methods |
| 18 // of a message loop. This class can outlive the target message loop. You can | 18 // of a message loop. This class can outlive the target message loop. You can |
| 19 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or | 19 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or |
| 20 // MessageLoopProxy::CreateForCurrentThread(). | 20 // MessageLoopProxy::CreateForCurrentThread(). |
| 21 class MessageLoopProxy | 21 class MessageLoopProxy |
| 22 : public base::RefCountedThreadSafe<MessageLoopProxy, | 22 : public base::RefCountedThreadSafe<MessageLoopProxy, |
| 23 MessageLoopProxyTraits> { | 23 MessageLoopProxyTraits> { |
|
brettw
2011/03/24 20:37:30
Revert this
| |
| 24 public: | 24 public: |
| 25 // These methods are the same as in message_loop.h, but are guaranteed to | 25 // These methods are the same as in message_loop.h, but are guaranteed to |
| 26 // either post the Task to the MessageLoop (if it's still alive), or to | 26 // either post the Task to the MessageLoop (if it's still alive), or to |
| 27 // delete the Task otherwise. | 27 // delete the Task otherwise. |
| 28 // They return true iff the thread existed and the task was posted. Note that | 28 // They return true iff the thread existed and the task was posted. Note that |
| 29 // even if the task is posted, there's no guarantee that it will run, since | 29 // even if the task is posted, there's no guarantee that it will run, since |
| 30 // the target thread may already have a Quit message in its queue. | 30 // the target thread may already have a Quit message in its queue. |
| 31 virtual bool PostTask(const tracked_objects::Location& from_here, | 31 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 32 Task* task) = 0; | 32 Task* task) = 0; |
| 33 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 33 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 struct MessageLoopProxyTraits { | 71 struct MessageLoopProxyTraits { |
| 72 static void Destruct(const MessageLoopProxy* proxy) { | 72 static void Destruct(const MessageLoopProxy* proxy) { |
| 73 proxy->OnDestruct(); | 73 proxy->OnDestruct(); |
| 74 } | 74 } |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace base | 77 } // namespace base |
| 78 | 78 |
| 79 #endif // BASE_MESSAGE_LOOP_PROXY_H_ | 79 #endif // BASE_MESSAGE_LOOP_PROXY_H_ |
| OLD | NEW |