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

Side by Side Diff: base/message_loop_proxy.h

Issue 7316015: Support Closure in ALL the loops! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 9 years, 5 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
OLDNEW
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_api.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/task.h" 13 #include "base/task.h"
13 14
14 namespace base { 15 namespace base {
15 16
16 struct MessageLoopProxyTraits; 17 struct MessageLoopProxyTraits;
17 18
18 // 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
19 // 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
20 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or 21 // obtain a MessageLoopProxy via Thread::message_loop_proxy() or
(...skipping 13 matching lines...) Expand all
34 virtual bool PostTask(const tracked_objects::Location& from_here, 35 virtual bool PostTask(const tracked_objects::Location& from_here,
35 Task* task) = 0; 36 Task* task) = 0;
36 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 37 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
37 Task* task, int64 delay_ms) = 0; 38 Task* task, int64 delay_ms) = 0;
38 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, 39 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
39 Task* task) = 0; 40 Task* task) = 0;
40 virtual bool PostNonNestableDelayedTask( 41 virtual bool PostNonNestableDelayedTask(
41 const tracked_objects::Location& from_here, 42 const tracked_objects::Location& from_here,
42 Task* task, 43 Task* task,
43 int64 delay_ms) = 0; 44 int64 delay_ms) = 0;
45
46 // TODO(ajwong): Remove the functions above once the Task -> Closure migration
47 // is complete.
48 //
49 // There are 2 sets of Post*Task functions, one which takes the older Task*
50 // function object representation, and one that takes the newer base::Closure.
51 // We have this overload to allow a staged transition between the two systems.
52 // Once the transition is done, the functions above should be deleted.
53 virtual bool PostTask(const tracked_objects::Location& from_here,
54 const base::Closure& task) = 0;
55 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
56 const base::Closure& task, int64 delay_ms) = 0;
willchan no longer on Chromium 2011/07/08 12:04:21 Move |delay_ms| to the next line a la Chromium sty
awong 2011/07/08 18:36:51 Done.
57 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
58 const base::Closure& task) = 0;
59 virtual bool PostNonNestableDelayedTask(
60 const tracked_objects::Location& from_here,
61 const base::Closure& task,
62 int64 delay_ms) = 0;
63
44 // A method which checks if the caller is currently running in the thread that 64 // A method which checks if the caller is currently running in the thread that
45 // this proxy represents. 65 // this proxy represents.
46 virtual bool BelongsToCurrentThread() = 0; 66 virtual bool BelongsToCurrentThread() = 0;
47 67
48 template <class T> 68 template <class T>
49 bool DeleteSoon(const tracked_objects::Location& from_here, 69 bool DeleteSoon(const tracked_objects::Location& from_here,
50 T* object) { 70 T* object) {
51 return PostNonNestableTask(from_here, new DeleteTask<T>(object)); 71 return PostNonNestableTask(from_here, new DeleteTask<T>(object));
52 } 72 }
53 template <class T> 73 template <class T>
(...skipping 20 matching lines...) Expand all
74 94
75 struct MessageLoopProxyTraits { 95 struct MessageLoopProxyTraits {
76 static void Destruct(const MessageLoopProxy* proxy) { 96 static void Destruct(const MessageLoopProxy* proxy) {
77 proxy->OnDestruct(); 97 proxy->OnDestruct();
78 } 98 }
79 }; 99 };
80 100
81 } // namespace base 101 } // namespace base
82 102
83 #endif // BASE_MESSAGE_LOOP_PROXY_H_ 103 #endif // BASE_MESSAGE_LOOP_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698