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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // are stable and accessible before calling SetNestableTasksAllowed(true). | 58 // are stable and accessible before calling SetNestableTasksAllowed(true). |
59 // | 59 // |
60 class MessageLoop : public base::MessagePump::Delegate { | 60 class MessageLoop : public base::MessagePump::Delegate { |
61 public: | 61 public: |
62 // A TaskObserver is an object that receives task notifications from the | 62 // A TaskObserver is an object that receives task notifications from the |
63 // MessageLoop. | 63 // MessageLoop. |
64 // | 64 // |
65 // NOTE: A TaskObserver implementation should be extremely fast! | 65 // NOTE: A TaskObserver implementation should be extremely fast! |
66 class TaskObserver { | 66 class TaskObserver { |
67 public: | 67 public: |
68 TaskObserver() {} | 68 TaskObserver(); |
69 | 69 |
70 // This method is called before processing a task. | 70 // This method is called before processing a task. |
71 virtual void WillProcessTask(base::TimeTicks birth_time) = 0; | 71 virtual void WillProcessTask(base::TimeTicks birth_time) = 0; |
72 | 72 |
73 // This method is called after processing a task. | 73 // This method is called after processing a task. |
74 virtual void DidProcessTask() = 0; | 74 virtual void DidProcessTask() = 0; |
75 | 75 |
76 protected: | 76 protected: |
77 virtual ~TaskObserver() {} | 77 virtual ~TaskObserver(); |
78 }; | 78 }; |
79 | 79 |
80 static void EnableHistogrammer(bool enable_histogrammer); | 80 static void EnableHistogrammer(bool enable_histogrammer); |
81 | 81 |
82 // A DestructionObserver is notified when the current MessageLoop is being | 82 // A DestructionObserver is notified when the current MessageLoop is being |
83 // destroyed. These obsevers are notified prior to MessageLoop::current() | 83 // destroyed. These obsevers are notified prior to MessageLoop::current() |
84 // being changed to return NULL. This gives interested parties the chance to | 84 // being changed to return NULL. This gives interested parties the chance to |
85 // do final cleanup that depends on the MessageLoop. | 85 // do final cleanup that depends on the MessageLoop. |
86 // | 86 // |
87 // NOTE: Any tasks posted to the MessageLoop during this notification will | 87 // NOTE: Any tasks posted to the MessageLoop during this notification will |
88 // not be run. Instead, they will be deleted. | 88 // not be run. Instead, they will be deleted. |
89 // | 89 // |
90 class DestructionObserver { | 90 class DestructionObserver { |
91 public: | 91 public: |
92 virtual ~DestructionObserver() {} | 92 virtual ~DestructionObserver(); |
93 virtual void WillDestroyCurrentMessageLoop() = 0; | 93 virtual void WillDestroyCurrentMessageLoop() = 0; |
94 }; | 94 }; |
95 | 95 |
96 // Add a DestructionObserver, which will start receiving notifications | 96 // Add a DestructionObserver, which will start receiving notifications |
97 // immediately. | 97 // immediately. |
98 void AddDestructionObserver(DestructionObserver* destruction_observer); | 98 void AddDestructionObserver(DestructionObserver* destruction_observer); |
99 | 99 |
100 // Remove a DestructionObserver. It is safe to call this method while a | 100 // Remove a DestructionObserver. It is safe to call this method while a |
101 // DestructionObserver is receiving a notification callback. | 101 // DestructionObserver is receiving a notification callback. |
102 void RemoveDestructionObserver(DestructionObserver* destruction_observer); | 102 void RemoveDestructionObserver(DestructionObserver* destruction_observer); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 #endif // defined(OS_POSIX) | 595 #endif // defined(OS_POSIX) |
596 }; | 596 }; |
597 | 597 |
598 // Do not add any member variables to MessageLoopForIO! This is important b/c | 598 // Do not add any member variables to MessageLoopForIO! This is important b/c |
599 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 599 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
600 // data that you need should be stored on the MessageLoop's pump_ instance. | 600 // data that you need should be stored on the MessageLoop's pump_ instance. |
601 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 601 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
602 MessageLoopForIO_should_not_have_extra_member_variables); | 602 MessageLoopForIO_should_not_have_extra_member_variables); |
603 | 603 |
604 #endif // BASE_MESSAGE_LOOP_H_ | 604 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |