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 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // The MessageLoop takes ownership of the Task, and deletes it after it has | 96 // The MessageLoop takes ownership of the Task, and deletes it after it has |
97 // been Run(). | 97 // been Run(). |
98 // | 98 // |
99 // NOTE: These methods may be called on any thread. The Task will be invoked | 99 // NOTE: These methods may be called on any thread. The Task will be invoked |
100 // on the thread that executes MessageLoop::Run(). | 100 // on the thread that executes MessageLoop::Run(). |
101 | 101 |
102 void PostTask( | 102 void PostTask( |
103 const tracked_objects::Location& from_here, Task* task); | 103 const tracked_objects::Location& from_here, Task* task); |
104 | 104 |
105 void PostDelayedTask( | 105 void PostDelayedTask( |
106 const tracked_objects::Location& from_here, Task* task, int delay_ms); | 106 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); |
107 | 107 |
108 void PostNonNestableTask( | 108 void PostNonNestableTask( |
109 const tracked_objects::Location& from_here, Task* task); | 109 const tracked_objects::Location& from_here, Task* task); |
110 | 110 |
111 void PostNonNestableDelayedTask( | 111 void PostNonNestableDelayedTask( |
112 const tracked_objects::Location& from_here, Task* task, int delay_ms); | 112 const tracked_objects::Location& from_here, Task* task, int64 delay_ms); |
113 | 113 |
114 // A variant on PostTask that deletes the given object. This is useful | 114 // A variant on PostTask that deletes the given object. This is useful |
115 // if the object needs to live until the next run of the MessageLoop (for | 115 // if the object needs to live until the next run of the MessageLoop (for |
116 // example, deleting a RenderProcessHost from within an IPC callback is not | 116 // example, deleting a RenderProcessHost from within an IPC callback is not |
117 // good). | 117 // good). |
118 // | 118 // |
119 // NOTE: This method may be called on any thread. The object will be deleted | 119 // NOTE: This method may be called on any thread. The object will be deleted |
120 // on the thread that executes MessageLoop::Run(). If this is not the same | 120 // on the thread that executes MessageLoop::Run(). If this is not the same |
121 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit | 121 // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit |
122 // from RefCountedThreadSafe<T>! | 122 // from RefCountedThreadSafe<T>! |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // accessible on this thread. | 324 // accessible on this thread. |
325 void ReloadWorkQueue(); | 325 void ReloadWorkQueue(); |
326 | 326 |
327 // Delete tasks that haven't run yet without running them. Used in the | 327 // Delete tasks that haven't run yet without running them. Used in the |
328 // destructor to make sure all the task's destructors get called. Returns | 328 // destructor to make sure all the task's destructors get called. Returns |
329 // true if some work was done. | 329 // true if some work was done. |
330 bool DeletePendingTasks(); | 330 bool DeletePendingTasks(); |
331 | 331 |
332 // Post a task to our incomming queue. | 332 // Post a task to our incomming queue. |
333 void PostTask_Helper(const tracked_objects::Location& from_here, Task* task, | 333 void PostTask_Helper(const tracked_objects::Location& from_here, Task* task, |
334 int delay_ms, bool nestable); | 334 int64 delay_ms, bool nestable); |
335 | 335 |
336 // base::MessagePump::Delegate methods: | 336 // base::MessagePump::Delegate methods: |
337 virtual bool DoWork(); | 337 virtual bool DoWork(); |
338 virtual bool DoDelayedWork(base::Time* next_delayed_work_time); | 338 virtual bool DoDelayedWork(base::Time* next_delayed_work_time); |
339 virtual bool DoIdleWork(); | 339 virtual bool DoIdleWork(); |
340 | 340 |
341 // Start recording histogram info about events and action IF it was enabled | 341 // Start recording histogram info about events and action IF it was enabled |
342 // and IF the statistics recorder can accept a registration of our histogram. | 342 // and IF the statistics recorder can accept a registration of our histogram. |
343 void StartHistogrammer(); | 343 void StartHistogrammer(); |
344 | 344 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 #endif // defined(OS_POSIX) | 502 #endif // defined(OS_POSIX) |
503 }; | 503 }; |
504 | 504 |
505 // Do not add any member variables to MessageLoopForIO! This is important b/c | 505 // Do not add any member variables to MessageLoopForIO! This is important b/c |
506 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 506 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
507 // data that you need should be stored on the MessageLoop's pump_ instance. | 507 // data that you need should be stored on the MessageLoop's pump_ instance. |
508 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 508 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
509 MessageLoopForIO_should_not_have_extra_member_variables); | 509 MessageLoopForIO_should_not_have_extra_member_variables); |
510 | 510 |
511 #endif // BASE_MESSAGE_LOOP_H_ | 511 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |