OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base_api.h" | 9 #include "base/base_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 | 16 |
17 struct MessageLoopProxyTraits; | 17 struct MessageLoopProxyTraits; |
18 | 18 |
19 // This class provides a thread-safe refcounted interface to the Post* methods | 19 // This class provides a thread-safe refcounted interface to the Post* methods |
20 // of a message loop. This class can outlive the target message loop. You can | 20 // of a message loop. This class can outlive the target message loop. You can |
21 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or | 21 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or |
22 // MessageLoopProxy::CreateForCurrentThread(). | 22 // MessageLoopProxy::CreateForCurrentThread(). |
23 class BASE_API MessageLoopProxy | 23 class BASE_EXPORT MessageLoopProxy |
24 : public base::RefCountedThreadSafe<MessageLoopProxy, | 24 : public base::RefCountedThreadSafe<MessageLoopProxy, |
25 MessageLoopProxyTraits> { | 25 MessageLoopProxyTraits> { |
26 public: | 26 public: |
27 // These methods are the same as in message_loop.h, but are guaranteed to | 27 // These methods are the same as in message_loop.h, but are guaranteed to |
28 // either post the Task to the MessageLoop (if it's still alive), or to | 28 // either post the Task to the MessageLoop (if it's still alive), or to |
29 // delete the Task otherwise. | 29 // delete the Task otherwise. |
30 // They return true iff the thread existed and the task was posted. Note that | 30 // They return true iff the thread existed and the task was posted. Note that |
31 // even if the task is posted, there's no guarantee that it will run; for | 31 // even if the task is posted, there's no guarantee that it will run; for |
32 // example the target loop may already be quitting, or in the case of a | 32 // example the target loop may already be quitting, or in the case of a |
33 // delayed task a Quit message may preempt it in the message loop queue. | 33 // delayed task a Quit message may preempt it in the message loop queue. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 struct MessageLoopProxyTraits { | 97 struct MessageLoopProxyTraits { |
98 static void Destruct(const MessageLoopProxy* proxy) { | 98 static void Destruct(const MessageLoopProxy* proxy) { |
99 proxy->OnDestruct(); | 99 proxy->OnDestruct(); |
100 } | 100 } |
101 }; | 101 }; |
102 | 102 |
103 } // namespace base | 103 } // namespace base |
104 | 104 |
105 #endif // BASE_MESSAGE_LOOP_PROXY_H_ | 105 #endif // BASE_MESSAGE_LOOP_PROXY_H_ |
OLD | NEW |