OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_LOOP_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // Provided for testing. | 367 // Provided for testing. |
368 bool IsHighResolutionTimerEnabledForTesting(); | 368 bool IsHighResolutionTimerEnabledForTesting(); |
369 | 369 |
370 // Returns true if the message loop is "idle". Provided for testing. | 370 // Returns true if the message loop is "idle". Provided for testing. |
371 bool IsIdleForTesting(); | 371 bool IsIdleForTesting(); |
372 | 372 |
373 //---------------------------------------------------------------------------- | 373 //---------------------------------------------------------------------------- |
374 protected: | 374 protected: |
375 scoped_ptr<MessagePump> pump_; | 375 scoped_ptr<MessagePump> pump_; |
376 | 376 |
| 377 // Loads tasks from the incoming queue to |work_queue_| if the latter is |
| 378 // empty. |
| 379 virtual void ReloadWorkQueue(); |
| 380 |
| 381 virtual TaskQueue& SelectNextWorkQueue(); |
| 382 |
377 private: | 383 private: |
378 friend class internal::IncomingTaskQueue; | 384 friend class internal::IncomingTaskQueue; |
379 friend class RunLoop; | 385 friend class RunLoop; |
380 | 386 |
381 // Configures various members for the two constructors. | 387 // Configures various members for the two constructors. |
382 void Init(); | 388 void Init(); |
383 | 389 |
384 // Invokes the actual run loop using the message pump. | 390 // Invokes the actual run loop using the message pump. |
385 void RunHandler(); | 391 void RunHandler(); |
386 | 392 |
(...skipping 13 matching lines...) Expand all Loading... |
400 // Delete tasks that haven't run yet without running them. Used in the | 406 // Delete tasks that haven't run yet without running them. Used in the |
401 // destructor to make sure all the task's destructors get called. Returns | 407 // destructor to make sure all the task's destructors get called. Returns |
402 // true if some work was done. | 408 // true if some work was done. |
403 bool DeletePendingTasks(); | 409 bool DeletePendingTasks(); |
404 | 410 |
405 // Creates a process-wide unique ID to represent this task in trace events. | 411 // Creates a process-wide unique ID to represent this task in trace events. |
406 // This will be mangled with a Process ID hash to reduce the likelyhood of | 412 // This will be mangled with a Process ID hash to reduce the likelyhood of |
407 // colliding with MessageLoop pointers on other processes. | 413 // colliding with MessageLoop pointers on other processes. |
408 uint64 GetTaskTraceID(const PendingTask& task); | 414 uint64 GetTaskTraceID(const PendingTask& task); |
409 | 415 |
410 // Loads tasks from the incoming queue to |work_queue_| if the latter is | |
411 // empty. | |
412 void ReloadWorkQueue(); | |
413 | |
414 // Wakes up the message pump. Can be called on any thread. The caller is | 416 // Wakes up the message pump. Can be called on any thread. The caller is |
415 // responsible for synchronizing ScheduleWork() calls. | 417 // responsible for synchronizing ScheduleWork() calls. |
416 void ScheduleWork(bool was_empty); | 418 void ScheduleWork(bool was_empty); |
417 | 419 |
418 // Start recording histogram info about events and action IF it was enabled | 420 // Start recording histogram info about events and action IF it was enabled |
419 // and IF the statistics recorder can accept a registration of our histogram. | 421 // and IF the statistics recorder can accept a registration of our histogram. |
420 void StartHistogrammer(); | 422 void StartHistogrammer(); |
421 | 423 |
422 // Add occurrence of event to our histogram, so that we can see what is being | 424 // Add occurrence of event to our histogram, so that we can see what is being |
423 // done in a specific MessageLoop instance (i.e., specific thread). | 425 // done in a specific MessageLoop instance (i.e., specific thread). |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 632 |
631 // Do not add any member variables to MessageLoopForIO! This is important b/c | 633 // Do not add any member variables to MessageLoopForIO! This is important b/c |
632 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 634 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
633 // data that you need should be stored on the MessageLoop's pump_ instance. | 635 // data that you need should be stored on the MessageLoop's pump_ instance. |
634 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 636 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
635 MessageLoopForIO_should_not_have_extra_member_variables); | 637 MessageLoopForIO_should_not_have_extra_member_variables); |
636 | 638 |
637 } // namespace base | 639 } // namespace base |
638 | 640 |
639 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 641 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |