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> |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // A variant on PostTask that deletes the given object. This is useful | 139 // A variant on PostTask that deletes the given object. This is useful |
140 // if the object needs to live until the next run of the MessageLoop (for | 140 // if the object needs to live until the next run of the MessageLoop (for |
141 // example, deleting a RenderProcessHost from within an IPC callback is not | 141 // example, deleting a RenderProcessHost from within an IPC callback is not |
142 // good). | 142 // good). |
143 // | 143 // |
144 // NOTE: This method may be called on any thread. The object will be deleted | 144 // NOTE: This method may be called on any thread. The object will be deleted |
145 // on the thread that executes MessageLoop::Run(). If this is not the same | 145 // on the thread that executes MessageLoop::Run(). If this is not the same |
146 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit | 146 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit |
147 // from RefCountedThreadSafe<T>! | 147 // from RefCountedThreadSafe<T>! |
148 template <class T> | 148 template <class T> |
149 void DeleteSoon(const tracked_objects::Location& from_here, T* object) { | 149 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) { |
150 PostNonNestableTask(from_here, new DeleteTask<T>(object)); | 150 PostNonNestableTask(from_here, new DeleteTask<T>(object)); |
151 } | 151 } |
152 | 152 |
153 // A variant on PostTask that releases the given reference counted object | 153 // A variant on PostTask that releases the given reference counted object |
154 // (by calling its Release method). This is useful if the object needs to | 154 // (by calling its Release method). This is useful if the object needs to |
155 // live until the next run of the MessageLoop, or if the object needs to be | 155 // live until the next run of the MessageLoop, or if the object needs to be |
156 // released on a particular thread. | 156 // released on a particular thread. |
157 // | 157 // |
158 // NOTE: This method may be called on any thread. The object will be | 158 // NOTE: This method may be called on any thread. The object will be |
159 // released (and thus possibly deleted) on the thread that executes | 159 // released (and thus possibly deleted) on the thread that executes |
160 // MessageLoop::Run(). If this is not the same as the thread that calls | 160 // MessageLoop::Run(). If this is not the same as the thread that calls |
161 // PostDelayedTask(FROM_HERE, ), then T MUST inherit from | 161 // PostDelayedTask(FROM_HERE, ), then T MUST inherit from |
162 // RefCountedThreadSafe<T>! | 162 // RefCountedThreadSafe<T>! |
163 template <class T> | 163 template <class T> |
164 void ReleaseSoon(const tracked_objects::Location& from_here, T* object) { | 164 void ReleaseSoon(const tracked_objects::Location& from_here, |
| 165 const T* object) { |
165 PostNonNestableTask(from_here, new ReleaseTask<T>(object)); | 166 PostNonNestableTask(from_here, new ReleaseTask<T>(object)); |
166 } | 167 } |
167 | 168 |
168 // Run the message loop. | 169 // Run the message loop. |
169 void Run(); | 170 void Run(); |
170 | 171 |
171 // Process all pending tasks, windows messages, etc., but don't wait/sleep. | 172 // Process all pending tasks, windows messages, etc., but don't wait/sleep. |
172 // Return as soon as all items that can be run are taken care of. | 173 // Return as soon as all items that can be run are taken care of. |
173 void RunAllPending(); | 174 void RunAllPending(); |
174 | 175 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 #endif // defined(OS_POSIX) | 599 #endif // defined(OS_POSIX) |
599 }; | 600 }; |
600 | 601 |
601 // Do not add any member variables to MessageLoopForIO! This is important b/c | 602 // Do not add any member variables to MessageLoopForIO! This is important b/c |
602 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 603 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
603 // data that you need should be stored on the MessageLoop's pump_ instance. | 604 // data that you need should be stored on the MessageLoop's pump_ instance. |
604 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 605 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
605 MessageLoopForIO_should_not_have_extra_member_variables); | 606 MessageLoopForIO_should_not_have_extra_member_variables); |
606 | 607 |
607 #endif // BASE_MESSAGE_LOOP_H_ | 608 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |