• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_COMMON_THREAD_IMPL_H_
6 #define CEF_LIBCEF_COMMON_THREAD_IMPL_H_
7 #pragma once
8 
9 #include "include/cef_thread.h"
10 
11 #include "base/threading/thread.h"
12 
13 class CefThreadImpl : public CefThread {
14  public:
15   CefThreadImpl();
16 
17   CefThreadImpl(const CefThreadImpl&) = delete;
18   CefThreadImpl& operator=(const CefThreadImpl&) = delete;
19 
20   ~CefThreadImpl();
21 
22   bool Create(const CefString& display_name,
23               cef_thread_priority_t priority,
24               cef_message_loop_type_t message_loop_type,
25               bool stoppable,
26               cef_com_init_mode_t com_init_mode);
27 
28   // CefThread methods:
29   CefRefPtr<CefTaskRunner> GetTaskRunner() override;
30   cef_platform_thread_id_t GetPlatformThreadId() override;
31   void Stop() override;
32   bool IsRunning() override;
33 
34  private:
35   std::unique_ptr<base::Thread> thread_;
36   cef_platform_thread_id_t thread_id_;
37   CefRefPtr<CefTaskRunner> thread_task_runner_;
38 
39   // TaskRunner for the owner thread.
40   scoped_refptr<base::SequencedTaskRunner> owner_task_runner_;
41 
42   IMPLEMENT_REFCOUNTING(CefThreadImpl);
43 };
44 
45 #endif  // CEF_LIBCEF_COMMON_THREAD_IMPL_H_
46