OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ | 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ |
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ | 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 | 16 |
17 namespace pp { | 17 namespace pp { |
18 class Core; | 18 class Core; |
19 } // namespace pp | 19 } // namespace pp |
20 | 20 |
21 namespace remoting { | 21 namespace remoting { |
22 | 22 |
23 // SingleThreadTaskRunner implementation for the main plugin thread. | 23 // SingleThreadTaskRunner implementation for the main plugin thread. |
24 class PepperMainThreadTaskRunner : public base::SingleThreadTaskRunner { | 24 class PepperMainThreadTaskRunner : public base::SingleThreadTaskRunner { |
25 public: | 25 public: |
26 PepperMainThreadTaskRunner(); | 26 PepperMainThreadTaskRunner(); |
27 | 27 |
28 // base::SingleThreadTaskRunner interface. | 28 // base::SingleThreadTaskRunner interface. |
29 bool PostDelayedTask(const tracked_objects::Location& from_here, | 29 bool PostDelayedTask(const tracked_objects::Location& from_here, |
30 const base::Closure& task, | 30 base::Closure task, |
31 base::TimeDelta delay) override; | 31 base::TimeDelta delay) override; |
32 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 32 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
33 const base::Closure& task, | 33 base::Closure task, |
34 base::TimeDelta delay) override; | 34 base::TimeDelta delay) override; |
35 bool RunsTasksOnCurrentThread() const override; | 35 bool RunsTasksOnCurrentThread() const override; |
36 | 36 |
37 protected: | 37 protected: |
38 ~PepperMainThreadTaskRunner() override; | 38 ~PepperMainThreadTaskRunner() override; |
39 | 39 |
40 private: | 40 private: |
41 // Helper that allows a base::Closure to be used as a pp::CompletionCallback, | 41 // Helper that allows a base::Closure to be used as a pp::CompletionCallback, |
42 // by ignoring the completion result. | 42 // by ignoring the completion result. |
43 void RunTask(const base::Closure& task); | 43 void RunTask(base::Closure task); |
44 | 44 |
45 pp::Core* core_; | 45 pp::Core* core_; |
46 | 46 |
47 base::WeakPtr<PepperMainThreadTaskRunner> weak_ptr_; | 47 base::WeakPtr<PepperMainThreadTaskRunner> weak_ptr_; |
48 base::WeakPtrFactory<PepperMainThreadTaskRunner> weak_ptr_factory_; | 48 base::WeakPtrFactory<PepperMainThreadTaskRunner> weak_ptr_factory_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(PepperMainThreadTaskRunner); | 50 DISALLOW_COPY_AND_ASSIGN(PepperMainThreadTaskRunner); |
51 }; | 51 }; |
52 | 52 |
53 } // namespace remoting | 53 } // namespace remoting |
54 | 54 |
55 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ | 55 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_MAIN_THREAD_TASK_RUNNER_H_ |
OLD | NEW |