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