OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PUMP_H_ | 5 #ifndef BASE_MESSAGE_PUMP_H_ |
6 #define BASE_MESSAGE_PUMP_H_ | 6 #define BASE_MESSAGE_PUMP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // future delayed work (timer events) is currently empty, and no additional | 36 // future delayed work (timer events) is currently empty, and no additional |
37 // calls to this function need to be scheduled. | 37 // calls to this function need to be scheduled. |
38 virtual bool DoDelayedWork(TimeTicks* next_delayed_work_time) = 0; | 38 virtual bool DoDelayedWork(TimeTicks* next_delayed_work_time) = 0; |
39 | 39 |
40 // Called from within Run just before the message pump goes to sleep. | 40 // Called from within Run just before the message pump goes to sleep. |
41 // Returns true to indicate that idle work was done. | 41 // Returns true to indicate that idle work was done. |
42 virtual bool DoIdleWork() = 0; | 42 virtual bool DoIdleWork() = 0; |
43 }; | 43 }; |
44 | 44 |
45 MessagePump(); | 45 MessagePump(); |
46 virtual ~MessagePump(); | |
47 | 46 |
48 // The Run method is called to enter the message pump's run loop. | 47 // The Run method is called to enter the message pump's run loop. |
49 // | 48 // |
50 // Within the method, the message pump is responsible for processing native | 49 // Within the method, the message pump is responsible for processing native |
51 // messages as well as for giving cycles to the delegate periodically. The | 50 // messages as well as for giving cycles to the delegate periodically. The |
52 // message pump should take care to mix delegate callbacks with native | 51 // message pump should take care to mix delegate callbacks with native |
53 // message processing so neither type of event starves the other of cycles. | 52 // message processing so neither type of event starves the other of cycles. |
54 // | 53 // |
55 // The anatomy of a typical run loop: | 54 // The anatomy of a typical run loop: |
56 // | 55 // |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Schedule a DoWork callback to happen reasonably soon. Does nothing if a | 112 // Schedule a DoWork callback to happen reasonably soon. Does nothing if a |
114 // DoWork callback is already scheduled. This method may be called from any | 113 // DoWork callback is already scheduled. This method may be called from any |
115 // thread. Once this call is made, DoWork should not be "starved" at least | 114 // thread. Once this call is made, DoWork should not be "starved" at least |
116 // until it returns a value of false. | 115 // until it returns a value of false. |
117 virtual void ScheduleWork() = 0; | 116 virtual void ScheduleWork() = 0; |
118 | 117 |
119 // Schedule a DoDelayedWork callback to happen at the specified time, | 118 // Schedule a DoDelayedWork callback to happen at the specified time, |
120 // cancelling any pending DoDelayedWork callback. This method may only be | 119 // cancelling any pending DoDelayedWork callback. This method may only be |
121 // used on the thread that called Run. | 120 // used on the thread that called Run. |
122 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) = 0; | 121 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) = 0; |
| 122 |
| 123 protected: |
| 124 virtual ~MessagePump(); |
| 125 friend class RefCountedThreadSafe<MessagePump>; |
123 }; | 126 }; |
124 | 127 |
125 } // namespace base | 128 } // namespace base |
126 | 129 |
127 #endif // BASE_MESSAGE_PUMP_H_ | 130 #endif // BASE_MESSAGE_PUMP_H_ |
OLD | NEW |