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

Side by Side Diff: base/message_loop_proxy.h

Issue 1800008: Created a MessageLoopProxy interface. This provides a thread-safe refcounted ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | chrome/browser/chrome_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_MESSAGE_LOOP_PROXY_H_
6 #define BASE_MESSAGE_LOOP_PROXY_H_
7
8 #include "base/basictypes.h"
9 #include "base/ref_counted.h"
10 #include "base/task.h"
11
12 // This class provides a thread-safe refcounted interface to the Post* methods
13 // of a message loop. This class can outlive the target message loop.
14 class MessageLoopProxy : public base::RefCountedThreadSafe<MessageLoopProxy> {
15 public:
16 // These are the same methods in message_loop.h, but are guaranteed to either
17 // get posted to the MessageLoop if it's still alive, or be deleted otherwise.
18 // They return true iff the thread existed and the task was posted. Note that
19 // even if the task is posted, there's no guarantee that it will run, since
20 // the target thread may already have a Quit message in its queue.
21 virtual bool PostTask(const tracked_objects::Location& from_here,
22 Task* task) = 0;
23 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
24 Task* task, int64 delay_ms) = 0;
25 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
26 Task* task) = 0;
27 virtual bool PostNonNestableDelayedTask(
28 const tracked_objects::Location& from_here,
29 Task* task,
30 int64 delay_ms) = 0;
31
32 template <class T>
33 bool DeleteSoon(const tracked_objects::Location& from_here,
34 T* object) {
35 return PostNonNestableTask(from_here, new DeleteTask<T>(object));
36 }
37 template <class T>
38 bool ReleaseSoon(const tracked_objects::Location& from_here,
39 T* object) {
40 return PostNonNestableTask(from_here, new ReleaseTask<T>(object));
41 }
42 };
43
44 #endif // BASE_MESSAGE_LOOP_PROXY_H_
45
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | chrome/browser/chrome_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698