1 // Copyright 2020 The Chromium Embedded Framework 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 CEF_LIBCEF_COMMON_TASK_RUNNER_MANAGER_H_ 6 #define CEF_LIBCEF_COMMON_TASK_RUNNER_MANAGER_H_ 7 #pragma once 8 9 #include "base/single_thread_task_runner.h" 10 11 // Exposes global sequenced task runners in the main and render processes. 12 // Prefer using base::ThreadPool for tasks that do not need to be globally 13 // sequenced and CefTaskRunner for retrieving named CefThreadId runners. 14 class CefTaskRunnerManager { 15 public: 16 // Returns the singleton instance that is scoped to CEF lifespan. 17 static CefTaskRunnerManager* Get(); 18 19 // Available in the main process: 20 virtual scoped_refptr<base::SingleThreadTaskRunner> 21 GetBackgroundTaskRunner() = 0; 22 virtual scoped_refptr<base::SingleThreadTaskRunner> 23 GetUserVisibleTaskRunner() = 0; 24 virtual scoped_refptr<base::SingleThreadTaskRunner> 25 GetUserBlockingTaskRunner() = 0; 26 27 // Available in the render process: 28 virtual scoped_refptr<base::SingleThreadTaskRunner> GetRenderTaskRunner() = 0; 29 virtual scoped_refptr<base::SingleThreadTaskRunner> 30 GetWebWorkerTaskRunner() = 0; 31 32 protected: 33 CefTaskRunnerManager(); 34 virtual ~CefTaskRunnerManager(); 35 }; 36 37 #endif // CEF_LIBCEF_COMMON_TASK_RUNNER_MANAGER_H_ 38