1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
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/macros.h"
10 #include "base/message_loop/message_pump.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "base/time/time.h"
13 #include "build/build_config.h"
14 
15 namespace base {
16 
17 class BASE_EXPORT MessagePumpDefault : public MessagePump {
18  public:
19   MessagePumpDefault();
20   ~MessagePumpDefault() override;
21 
22   // MessagePump methods:
23   void Run(Delegate* delegate) override;
24   void Quit() override;
25   void ScheduleWork() override;
26   void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
27 #if defined(OS_MACOSX)
28   void SetTimerSlack(TimerSlack timer_slack) override;
29 #endif
30 
31  private:
32   // This flag is set to false when Run should return.
33   bool keep_running_;
34 
35   // Used to sleep until there is more work to do.
36   WaitableEvent event_;
37 
38   // The time at which we should call DoDelayedWork.
39   TimeTicks delayed_work_time_;
40 
41   DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault);
42 };
43 
44 }  // namespace base
45 
46 #endif  // BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
47