OLD | NEW |
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> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // been Run(). | 158 // been Run(). |
159 // | 159 // |
160 // NOTE: These methods may be called on any thread. The Task will be invoked | 160 // NOTE: These methods may be called on any thread. The Task will be invoked |
161 // on the thread that executes MessageLoop::Run(). | 161 // on the thread that executes MessageLoop::Run(). |
162 void PostTask( | 162 void PostTask( |
163 const tracked_objects::Location& from_here, | 163 const tracked_objects::Location& from_here, |
164 const base::Closure& task); | 164 const base::Closure& task); |
165 | 165 |
166 void PostDelayedTask( | 166 void PostDelayedTask( |
167 const tracked_objects::Location& from_here, | 167 const tracked_objects::Location& from_here, |
168 const base::Closure& task, int64 delay_ms); | |
169 | |
170 void PostDelayedTask( | |
171 const tracked_objects::Location& from_here, | |
172 const base::Closure& task, | 168 const base::Closure& task, |
173 base::TimeDelta delay); | 169 base::TimeDelta delay); |
174 | 170 |
175 void PostNonNestableTask( | 171 void PostNonNestableTask( |
176 const tracked_objects::Location& from_here, | 172 const tracked_objects::Location& from_here, |
177 const base::Closure& task); | 173 const base::Closure& task); |
178 | 174 |
179 void PostNonNestableDelayedTask( | 175 void PostNonNestableDelayedTask( |
180 const tracked_objects::Location& from_here, | 176 const tracked_objects::Location& from_here, |
181 const base::Closure& task, int64 delay_ms); | |
182 | |
183 void PostNonNestableDelayedTask( | |
184 const tracked_objects::Location& from_here, | |
185 const base::Closure& task, | 177 const base::Closure& task, |
186 base::TimeDelta delay); | 178 base::TimeDelta delay); |
187 | 179 |
188 // A variant on PostTask that deletes the given object. This is useful | 180 // A variant on PostTask that deletes the given object. This is useful |
189 // if the object needs to live until the next run of the MessageLoop (for | 181 // if the object needs to live until the next run of the MessageLoop (for |
190 // example, deleting a RenderProcessHost from within an IPC callback is not | 182 // example, deleting a RenderProcessHost from within an IPC callback is not |
191 // good). | 183 // good). |
192 // | 184 // |
193 // NOTE: This method may be called on any thread. The object will be deleted | 185 // NOTE: This method may be called on any thread. The object will be deleted |
194 // on the thread that executes MessageLoop::Run(). If this is not the same | 186 // on the thread that executes MessageLoop::Run(). If this is not the same |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // empty. The former requires a lock to access, while the latter is directly | 434 // empty. The former requires a lock to access, while the latter is directly |
443 // accessible on this thread. | 435 // accessible on this thread. |
444 void ReloadWorkQueue(); | 436 void ReloadWorkQueue(); |
445 | 437 |
446 // Delete tasks that haven't run yet without running them. Used in the | 438 // Delete tasks that haven't run yet without running them. Used in the |
447 // destructor to make sure all the task's destructors get called. Returns | 439 // destructor to make sure all the task's destructors get called. Returns |
448 // true if some work was done. | 440 // true if some work was done. |
449 bool DeletePendingTasks(); | 441 bool DeletePendingTasks(); |
450 | 442 |
451 // Calculates the time at which a PendingTask should run. | 443 // Calculates the time at which a PendingTask should run. |
452 base::TimeTicks CalculateDelayedRuntime(int64 delay_ms); | 444 base::TimeTicks CalculateDelayedRuntime(base::TimeDelta delay); |
453 | 445 |
454 // Start recording histogram info about events and action IF it was enabled | 446 // Start recording histogram info about events and action IF it was enabled |
455 // and IF the statistics recorder can accept a registration of our histogram. | 447 // and IF the statistics recorder can accept a registration of our histogram. |
456 void StartHistogrammer(); | 448 void StartHistogrammer(); |
457 | 449 |
458 // Add occurrence of event to our histogram, so that we can see what is being | 450 // Add occurrence of event to our histogram, so that we can see what is being |
459 // done in a specific MessageLoop instance (i.e., specific thread). | 451 // done in a specific MessageLoop instance (i.e., specific thread). |
460 // If message_histogram_ is NULL, this is a no-op. | 452 // If message_histogram_ is NULL, this is a no-op. |
461 void HistogramEvent(int event); | 453 void HistogramEvent(int event); |
462 | 454 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 #endif // defined(OS_POSIX) | 651 #endif // defined(OS_POSIX) |
660 }; | 652 }; |
661 | 653 |
662 // Do not add any member variables to MessageLoopForIO! This is important b/c | 654 // Do not add any member variables to MessageLoopForIO! This is important b/c |
663 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 655 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
664 // data that you need should be stored on the MessageLoop's pump_ instance. | 656 // data that you need should be stored on the MessageLoop's pump_ instance. |
665 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 657 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
666 MessageLoopForIO_should_not_have_extra_member_variables); | 658 MessageLoopForIO_should_not_have_extra_member_variables); |
667 | 659 |
668 #endif // BASE_MESSAGE_LOOP_H_ | 660 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |