Chromium Code Reviews| 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 |
| 11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/debug/task_annotator.h" | |
| 14 #include "base/location.h" | 15 #include "base/location.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop/incoming_task_queue.h" | 18 #include "base/message_loop/incoming_task_queue.h" |
| 18 #include "base/message_loop/message_loop_proxy.h" | 19 #include "base/message_loop/message_loop_proxy.h" |
| 19 #include "base/message_loop/message_loop_proxy_impl.h" | 20 #include "base/message_loop/message_loop_proxy_impl.h" |
| 20 #include "base/message_loop/message_pump.h" | 21 #include "base/message_loop/message_pump.h" |
| 21 #include "base/message_loop/timer_slack.h" | 22 #include "base/message_loop/timer_slack.h" |
| 22 #include "base/observer_list.h" | 23 #include "base/observer_list.h" |
| 23 #include "base/pending_task.h" | 24 #include "base/pending_task.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 bool DeferOrRunPendingTask(const PendingTask& pending_task); | 420 bool DeferOrRunPendingTask(const PendingTask& pending_task); |
| 420 | 421 |
| 421 // Adds the pending task to delayed_work_queue_. | 422 // Adds the pending task to delayed_work_queue_. |
| 422 void AddToDelayedWorkQueue(const PendingTask& pending_task); | 423 void AddToDelayedWorkQueue(const PendingTask& pending_task); |
| 423 | 424 |
| 424 // Delete tasks that haven't run yet without running them. Used in the | 425 // Delete tasks that haven't run yet without running them. Used in the |
| 425 // destructor to make sure all the task's destructors get called. Returns | 426 // destructor to make sure all the task's destructors get called. Returns |
| 426 // true if some work was done. | 427 // true if some work was done. |
| 427 bool DeletePendingTasks(); | 428 bool DeletePendingTasks(); |
| 428 | 429 |
| 429 // Creates a process-wide unique ID to represent this task in trace events. | 430 // Returns the TaskAnnotator which is used to add debug information to posted |
| 430 // This will be mangled with a Process ID hash to reduce the likelyhood of | 431 // tasks. |
| 431 // colliding with MessageLoop pointers on other processes. | 432 debug::TaskAnnotator* task_annotator() { return &task_annotator_; } |
|
eseidel
2014/08/12 16:18:49
Does Chromium use 'const' here?
Sami
2014/08/12 16:58:00
Making the method const would require a const_cast
| |
| 432 uint64 GetTaskTraceID(const PendingTask& task); | |
| 433 | 433 |
| 434 // Loads tasks from the incoming queue to |work_queue_| if the latter is | 434 // Loads tasks from the incoming queue to |work_queue_| if the latter is |
| 435 // empty. | 435 // empty. |
| 436 void ReloadWorkQueue(); | 436 void ReloadWorkQueue(); |
| 437 | 437 |
| 438 // Wakes up the message pump. Can be called on any thread. The caller is | 438 // Wakes up the message pump. Can be called on any thread. The caller is |
| 439 // responsible for synchronizing ScheduleWork() calls. | 439 // responsible for synchronizing ScheduleWork() calls. |
| 440 void ScheduleWork(bool was_empty); | 440 void ScheduleWork(bool was_empty); |
| 441 | 441 |
| 442 // Start recording histogram info about events and action IF it was enabled | 442 // Start recording histogram info about events and action IF it was enabled |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 #endif | 483 #endif |
| 484 | 484 |
| 485 std::string thread_name_; | 485 std::string thread_name_; |
| 486 // A profiling histogram showing the counts of various messages and events. | 486 // A profiling histogram showing the counts of various messages and events. |
| 487 HistogramBase* message_histogram_; | 487 HistogramBase* message_histogram_; |
| 488 | 488 |
| 489 RunLoop* run_loop_; | 489 RunLoop* run_loop_; |
| 490 | 490 |
| 491 ObserverList<TaskObserver> task_observers_; | 491 ObserverList<TaskObserver> task_observers_; |
| 492 | 492 |
| 493 debug::TaskAnnotator task_annotator_; | |
| 494 | |
| 493 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; | 495 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; |
| 494 | 496 |
| 495 // The message loop proxy associated with this message loop. | 497 // The message loop proxy associated with this message loop. |
| 496 scoped_refptr<internal::MessageLoopProxyImpl> message_loop_proxy_; | 498 scoped_refptr<internal::MessageLoopProxyImpl> message_loop_proxy_; |
| 497 scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; | 499 scoped_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; |
| 498 | 500 |
| 499 template <class T, class R> friend class base::subtle::DeleteHelperInternal; | 501 template <class T, class R> friend class base::subtle::DeleteHelperInternal; |
| 500 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; | 502 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; |
| 501 | 503 |
| 502 void DeleteSoonInternal(const tracked_objects::Location& from_here, | 504 void DeleteSoonInternal(const tracked_objects::Location& from_here, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 | 646 |
| 645 // Do not add any member variables to MessageLoopForIO! This is important b/c | 647 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 646 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 648 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 647 // data that you need should be stored on the MessageLoop's pump_ instance. | 649 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 648 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 650 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 649 MessageLoopForIO_should_not_have_extra_member_variables); | 651 MessageLoopForIO_should_not_have_extra_member_variables); |
| 650 | 652 |
| 651 } // namespace base | 653 } // namespace base |
| 652 | 654 |
| 653 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 655 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| OLD | NEW |