• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_
6 #define CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_
7 #pragma once
8 
9 #include "include/cef_task.h"
10 
11 #include "base/task/single_thread_task_runner.h"
12 
13 class CefTaskRunnerImpl : public CefTaskRunner {
14  public:
15   explicit CefTaskRunnerImpl(
16       scoped_refptr<base::SingleThreadTaskRunner> task_runner);
17 
18   CefTaskRunnerImpl(const CefTaskRunnerImpl&) = delete;
19   CefTaskRunnerImpl& operator=(const CefTaskRunnerImpl&) = delete;
20 
21   // Returns the task runner associated with |threadId|.
22   static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(
23       CefThreadId threadId);
24   // Returns the current task runner.
25   static scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
26 
27   // CefTaskRunner methods:
28   bool IsSame(CefRefPtr<CefTaskRunner> that) override;
29   bool BelongsToCurrentThread() override;
30   bool BelongsToThread(CefThreadId threadId) override;
31   bool PostTask(CefRefPtr<CefTask> task) override;
32   bool PostDelayedTask(CefRefPtr<CefTask> task, int64 delay_ms) override;
33 
34  private:
35   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
36 
37   IMPLEMENT_REFCOUNTING(CefTaskRunnerImpl);
38 };
39 
40 #endif  // CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_
41