1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ 7 8 #include "base/base_export.h" 9 #include "base/message_loop/message_pump.h" 10 #include "base/synchronization/waitable_event.h" 11 #include "base/time/time.h" 12 #include "build/build_config.h" 13 14 namespace base { 15 16 class BASE_EXPORT MessagePumpDefault : public MessagePump { 17 public: 18 MessagePumpDefault(); 19 20 MessagePumpDefault(const MessagePumpDefault&) = delete; 21 MessagePumpDefault& operator=(const MessagePumpDefault&) = delete; 22 23 ~MessagePumpDefault() override; 24 25 // MessagePump methods: 26 void Run(Delegate* delegate) override; 27 void Quit() override; 28 void ScheduleWork() override; 29 void ScheduleDelayedWork( 30 const Delegate::NextWorkInfo& next_work_info) override; 31 32 private: 33 // This flag is set to false when Run should return. 34 bool keep_running_; 35 36 // Used to sleep until there is more work to do. 37 WaitableEvent event_; 38 }; 39 40 } // namespace base 41 42 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ 43