OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/lock.h" | 13 #include "base/lock.h" |
14 #include "base/message_pump.h" | 14 #include "base/message_pump.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "base/closure.h" |
18 | 19 |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
20 // We need this to declare base::MessagePumpWin::Dispatcher, which we should | 21 // We need this to declare base::MessagePumpWin::Dispatcher, which we should |
21 // really just eliminate. | 22 // really just eliminate. |
22 #include "base/message_pump_win.h" | 23 #include "base/message_pump_win.h" |
23 #elif defined(OS_POSIX) | 24 #elif defined(OS_POSIX) |
24 #include "base/message_pump_libevent.h" | 25 #include "base/message_pump_libevent.h" |
25 #if !defined(OS_MACOSX) | 26 #if !defined(OS_MACOSX) |
26 #include "base/message_pump_glib.h" | 27 #include "base/message_pump_glib.h" |
27 #endif | 28 #endif |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // The NonNestable variants work similarly except that they promise never to | 121 // The NonNestable variants work similarly except that they promise never to |
121 // dispatch the task from a nested invocation of MessageLoop::Run. Instead, | 122 // dispatch the task from a nested invocation of MessageLoop::Run. Instead, |
122 // such tasks get deferred until the top-most MessageLoop::Run is executing. | 123 // such tasks get deferred until the top-most MessageLoop::Run is executing. |
123 // | 124 // |
124 // The MessageLoop takes ownership of the Task, and deletes it after it has | 125 // The MessageLoop takes ownership of the Task, and deletes it after it has |
125 // been Run(). | 126 // been Run(). |
126 // | 127 // |
127 // NOTE: These methods may be called on any thread. The Task will be invoked | 128 // NOTE: These methods may be called on any thread. The Task will be invoked |
128 // on the thread that executes MessageLoop::Run(). | 129 // on the thread that executes MessageLoop::Run(). |
129 | 130 |
| 131 void PostClosure( |
| 132 const tracked_objects::Location& from_here, base::Closure closure); |
| 133 |
130 void PostTask( | 134 void PostTask( |
131 const tracked_objects::Location& from_here, Task* task); | 135 const tracked_objects::Location& from_here, Task* task); |
132 | 136 |
133 void PostDelayedTask( | 137 void PostDelayedTask( |
134 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); | 138 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); |
135 | 139 |
| 140 void PostDelayedClosure( |
| 141 const tracked_objects::Location& from_here, base::Closure closure, |
| 142 int64 delay_ms); |
| 143 |
136 void PostNonNestableTask( | 144 void PostNonNestableTask( |
137 const tracked_objects::Location& from_here, Task* task); | 145 const tracked_objects::Location& from_here, Task* task); |
138 | 146 |
139 void PostNonNestableDelayedTask( | 147 void PostNonNestableDelayedTask( |
140 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); | 148 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); |
141 | 149 |
142 // A variant on PostTask that deletes the given object. This is useful | 150 // A variant on PostTask that deletes the given object. This is useful |
143 // if the object needs to live until the next run of the MessageLoop (for | 151 // if the object needs to live until the next run of the MessageLoop (for |
144 // example, deleting a RenderProcessHost from within an IPC callback is not | 152 // example, deleting a RenderProcessHost from within an IPC callback is not |
145 // good). | 153 // good). |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 #endif // defined(OS_POSIX) | 617 #endif // defined(OS_POSIX) |
610 }; | 618 }; |
611 | 619 |
612 // Do not add any member variables to MessageLoopForIO! This is important b/c | 620 // Do not add any member variables to MessageLoopForIO! This is important b/c |
613 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 621 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
614 // data that you need should be stored on the MessageLoop's pump_ instance. | 622 // data that you need should be stored on the MessageLoop's pump_ instance. |
615 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 623 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
616 MessageLoopForIO_should_not_have_extra_member_variables); | 624 MessageLoopForIO_should_not_have_extra_member_variables); |
617 | 625 |
618 #endif // BASE_MESSAGE_LOOP_H_ | 626 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |