v8_foreground_task_runner_base.h 967 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2017 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 GIN_V8_FOREGROUND_TASK_RUNNER_BASE_H_
  5. #define GIN_V8_FOREGROUND_TASK_RUNNER_BASE_H_
  6. #include "v8/include/v8-platform.h"
  7. #include "gin/gin_export.h"
  8. #include "gin/public/v8_idle_task_runner.h"
  9. namespace gin {
  10. // Base class for the V8ForegroundTaskRunners to share the capability of
  11. // enabling IdleTasks.
  12. class V8ForegroundTaskRunnerBase : public v8::TaskRunner {
  13. public:
  14. V8ForegroundTaskRunnerBase();
  15. ~V8ForegroundTaskRunnerBase() override;
  16. void EnableIdleTasks(std::unique_ptr<V8IdleTaskRunner> idle_task_runner);
  17. bool IdleTasksEnabled() override;
  18. protected:
  19. V8IdleTaskRunner* idle_task_runner() { return idle_task_runner_.get(); }
  20. private:
  21. std::unique_ptr<V8IdleTaskRunner> idle_task_runner_;
  22. };
  23. } // namespace gin
  24. #endif // GIN_V8_FOREGROUND_TASK_RUNNER_BASE_H_