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

Side by Side Diff: base/message_loop_proxy.h

Issue 6736019: Base: A few more files using BASE_API (for base.dll) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/message_loop.h ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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/basictypes.h" 10 #include "base/basictypes.h"
10 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
11 #include "base/task.h" 12 #include "base/task.h"
12 13
13 namespace base { 14 namespace base {
14 15
15 struct MessageLoopProxyTraits; 16 struct MessageLoopProxyTraits;
16 17
17 // This class provides a thread-safe refcounted interface to the Post* methods 18 // 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 19 // of a message loop. This class can outlive the target message loop. You can
19 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or 20 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or
20 // MessageLoopProxy::CreateForCurrentThread(). 21 // MessageLoopProxy::CreateForCurrentThread().
21 class MessageLoopProxy 22 class BASE_API MessageLoopProxy
22 : public base::RefCountedThreadSafe<MessageLoopProxy, 23 : public base::RefCountedThreadSafe<MessageLoopProxy,
23 MessageLoopProxyTraits> { 24 MessageLoopProxyTraits> {
24 public: 25 public:
25 // These methods are the same as in message_loop.h, but are guaranteed to 26 // 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 27 // either post the Task to the MessageLoop (if it's still alive), or to
27 // delete the Task otherwise. 28 // delete the Task otherwise.
28 // They return true iff the thread existed and the task was posted. Note that 29 // 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 30 // 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. 31 // the target thread may already have a Quit message in its queue.
31 virtual bool PostTask(const tracked_objects::Location& from_here, 32 virtual bool PostTask(const tracked_objects::Location& from_here,
(...skipping 19 matching lines...) Expand all
51 bool ReleaseSoon(const tracked_objects::Location& from_here, 52 bool ReleaseSoon(const tracked_objects::Location& from_here,
52 T* object) { 53 T* object) {
53 return PostNonNestableTask(from_here, new ReleaseTask<T>(object)); 54 return PostNonNestableTask(from_here, new ReleaseTask<T>(object));
54 } 55 }
55 56
56 // Factory method for creating an implementation of MessageLoopProxy 57 // Factory method for creating an implementation of MessageLoopProxy
57 // for the current thread. 58 // for the current thread.
58 static scoped_refptr<MessageLoopProxy> CreateForCurrentThread(); 59 static scoped_refptr<MessageLoopProxy> CreateForCurrentThread();
59 60
60 protected: 61 protected:
62 friend class RefCountedThreadSafe<MessageLoopProxy, MessageLoopProxyTraits>;
61 friend struct MessageLoopProxyTraits; 63 friend struct MessageLoopProxyTraits;
62 64
63 MessageLoopProxy(); 65 MessageLoopProxy();
64 virtual ~MessageLoopProxy(); 66 virtual ~MessageLoopProxy();
65 67
66 // Called when the proxy is about to be deleted. Subclasses can override this 68 // Called when the proxy is about to be deleted. Subclasses can override this
67 // to provide deletion on specific threads. 69 // to provide deletion on specific threads.
68 virtual void OnDestruct() const; 70 virtual void OnDestruct() const;
69 }; 71 };
70 72
71 struct MessageLoopProxyTraits { 73 struct MessageLoopProxyTraits {
72 static void Destruct(const MessageLoopProxy* proxy) { 74 static void Destruct(const MessageLoopProxy* proxy) {
73 proxy->OnDestruct(); 75 proxy->OnDestruct();
74 } 76 }
75 }; 77 };
76 78
77 } // namespace base 79 } // namespace base
78 80
79 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 81 #endif // BASE_MESSAGE_LOOP_PROXY_H_
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | base/message_loop_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698