message_pump_default.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
  5. #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_
  6. #include "base/base_export.h"
  7. #include "base/message_loop/message_pump.h"
  8. #include "base/synchronization/waitable_event.h"
  9. #include "base/time/time.h"
  10. #include "build/build_config.h"
  11. namespace base {
  12. class BASE_EXPORT MessagePumpDefault : public MessagePump {
  13. public:
  14. MessagePumpDefault();
  15. MessagePumpDefault(const MessagePumpDefault&) = delete;
  16. MessagePumpDefault& operator=(const MessagePumpDefault&) = delete;
  17. ~MessagePumpDefault() override;
  18. // MessagePump methods:
  19. void Run(Delegate* delegate) override;
  20. void Quit() override;
  21. void ScheduleWork() override;
  22. void ScheduleDelayedWork(
  23. const Delegate::NextWorkInfo& next_work_info) override;
  24. #if BUILDFLAG(IS_APPLE)
  25. void SetTimerSlack(TimerSlack timer_slack) override;
  26. #endif
  27. private:
  28. // This flag is set to false when Run should return.
  29. bool keep_running_;
  30. // Used to sleep until there is more work to do.
  31. WaitableEvent event_;
  32. };
  33. } // namespace base
  34. #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_