• 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/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   // Returns the task runner associated with |threadId|.
19   static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(
20       CefThreadId threadId);
21   // Returns the current task runner.
22   static scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
23 
24   // CefTaskRunner methods:
25   bool IsSame(CefRefPtr<CefTaskRunner> that) override;
26   bool BelongsToCurrentThread() override;
27   bool BelongsToThread(CefThreadId threadId) override;
28   bool PostTask(CefRefPtr<CefTask> task) override;
29   bool PostDelayedTask(CefRefPtr<CefTask> task, int64 delay_ms) override;
30 
31  private:
32   scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
33 
34   IMPLEMENT_REFCOUNTING(CefTaskRunnerImpl);
35   DISALLOW_COPY_AND_ASSIGN(CefTaskRunnerImpl);
36 };
37 
38 #endif  // CEF_LIBCEF_COMMON_TASK_RUNNER_IMPL_H_
39