| 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_DEFAULT_H_ | 5 #ifndef BASE_MESSAGE_PUMP_DEFAULT_H_ |
| 6 #define BASE_MESSAGE_PUMP_DEFAULT_H_ | 6 #define BASE_MESSAGE_PUMP_DEFAULT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 class MessagePumpDefault : public MessagePump { | 15 class MessagePumpDefault : public MessagePump { |
| 16 public: | 16 public: |
| 17 MessagePumpDefault(); | 17 MessagePumpDefault(); |
| 18 virtual ~MessagePumpDefault() {} | |
| 19 | 18 |
| 20 // MessagePump methods: | 19 // MessagePump methods: |
| 21 virtual void Run(Delegate* delegate) OVERRIDE; | 20 virtual void Run(Delegate* delegate) OVERRIDE; |
| 22 virtual void Quit() OVERRIDE; | 21 virtual void Quit() OVERRIDE; |
| 23 virtual void ScheduleWork() OVERRIDE; | 22 virtual void ScheduleWork() OVERRIDE; |
| 24 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; | 23 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; |
| 25 | 24 |
| 25 protected: |
| 26 virtual ~MessagePumpDefault() {} |
| 27 |
| 26 private: | 28 private: |
| 27 // This flag is set to false when Run should return. | 29 // This flag is set to false when Run should return. |
| 28 bool keep_running_; | 30 bool keep_running_; |
| 29 | 31 |
| 30 // Used to sleep until there is more work to do. | 32 // Used to sleep until there is more work to do. |
| 31 WaitableEvent event_; | 33 WaitableEvent event_; |
| 32 | 34 |
| 33 // The time at which we should call DoDelayedWork. | 35 // The time at which we should call DoDelayedWork. |
| 34 TimeTicks delayed_work_time_; | 36 TimeTicks delayed_work_time_; |
| 35 | 37 |
| 36 DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault); | 38 DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault); |
| 37 }; | 39 }; |
| 38 | 40 |
| 39 } // namespace base | 41 } // namespace base |
| 40 | 42 |
| 41 #endif // BASE_MESSAGE_PUMP_DEFAULT_H_ | 43 #endif // BASE_MESSAGE_PUMP_DEFAULT_H_ |
| OLD | NEW |