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

Side by Side Diff: base/message_loop.h

Issue 9169037: Make new TaskRunner, SequencedTaskRunner, and SingleThreadTaskRunner interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/sequenced_task_runner_helpers.h"
willchan no longer on Chromium 2012/02/09 20:50:50 sort
akalin 2012/02/10 22:48:59 Done.
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/message_loop_helpers.h"
18 #include "base/message_loop_proxy.h" 18 #include "base/message_loop_proxy.h"
19 #include "base/message_pump.h" 19 #include "base/message_pump.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/pending_task.h" 21 #include "base/pending_task.h"
22 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "base/tracking_info.h" 23 #include "base/tracking_info.h"
24 #include "base/time.h" 24 #include "base/time.h"
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 // We need this to declare base::MessagePumpWin::Dispatcher, which we should 27 // We need this to declare base::MessagePumpWin::Dispatcher, which we should
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // if the object needs to live until the next run of the MessageLoop (for 191 // if the object needs to live until the next run of the MessageLoop (for
192 // example, deleting a RenderProcessHost from within an IPC callback is not 192 // example, deleting a RenderProcessHost from within an IPC callback is not
193 // good). 193 // good).
194 // 194 //
195 // NOTE: This method may be called on any thread. The object will be deleted 195 // NOTE: This method may be called on any thread. The object will be deleted
196 // on the thread that executes MessageLoop::Run(). If this is not the same 196 // on the thread that executes MessageLoop::Run(). If this is not the same
197 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit 197 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit
198 // from RefCountedThreadSafe<T>! 198 // from RefCountedThreadSafe<T>!
199 template <class T> 199 template <class T>
200 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) { 200 void DeleteSoon(const tracked_objects::Location& from_here, const T* object) {
201 base::subtle::DeleteHelperInternal<T, void>::DeleteOnMessageLoop( 201 base::subtle::DeleteHelperInternal<T, void>::DeleteViaSequencedTaskRunner(
202 this, from_here, object); 202 this, from_here, object);
203 } 203 }
204 204
205 // A variant on PostTask that releases the given reference counted object 205 // A variant on PostTask that releases the given reference counted object
206 // (by calling its Release method). This is useful if the object needs to 206 // (by calling its Release method). This is useful if the object needs to
207 // live until the next run of the MessageLoop, or if the object needs to be 207 // live until the next run of the MessageLoop, or if the object needs to be
208 // released on a particular thread. 208 // released on a particular thread.
209 // 209 //
210 // NOTE: This method may be called on any thread. The object will be 210 // NOTE: This method may be called on any thread. The object will be
211 // released (and thus possibly deleted) on the thread that executes 211 // released (and thus possibly deleted) on the thread that executes
212 // MessageLoop::Run(). If this is not the same as the thread that calls 212 // MessageLoop::Run(). If this is not the same as the thread that calls
213 // PostDelayedTask(FROM_HERE, ), then T MUST inherit from 213 // PostDelayedTask(FROM_HERE, ), then T MUST inherit from
214 // RefCountedThreadSafe<T>! 214 // RefCountedThreadSafe<T>!
215 template <class T> 215 template <class T>
216 void ReleaseSoon(const tracked_objects::Location& from_here, 216 void ReleaseSoon(const tracked_objects::Location& from_here,
217 const T* object) { 217 const T* object) {
218 base::subtle::ReleaseHelperInternal<T, void>::ReleaseOnMessageLoop( 218 base::subtle::ReleaseHelperInternal<T, void>::ReleaseViaSequencedTaskRunner(
219 this, from_here, object); 219 this, from_here, object);
220 } 220 }
221 221
222 // Run the message loop. 222 // Run the message loop.
223 void Run(); 223 void Run();
224 224
225 // Process all pending tasks, windows messages, etc., but don't wait/sleep. 225 // Process all pending tasks, windows messages, etc., but don't wait/sleep.
226 // Return as soon as all items that can be run are taken care of. 226 // Return as soon as all items that can be run are taken care of.
227 void RunAllPending(); 227 void RunAllPending();
228 228
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 #endif // defined(OS_POSIX) 659 #endif // defined(OS_POSIX)
660 }; 660 };
661 661
662 // Do not add any member variables to MessageLoopForIO! This is important b/c 662 // Do not add any member variables to MessageLoopForIO! This is important b/c
663 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 663 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
664 // data that you need should be stored on the MessageLoop's pump_ instance. 664 // data that you need should be stored on the MessageLoop's pump_ instance.
665 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 665 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
666 MessageLoopForIO_should_not_have_extra_member_variables); 666 MessageLoopForIO_should_not_have_extra_member_variables);
667 667
668 #endif // BASE_MESSAGE_LOOP_H_ 668 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/message_loop_helpers.h » ('j') | base/sequenced_task_runner.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698