Chromium Code Reviews| Index: remoting/client/plugin/pepper_main_thread_task_runner.cc |
| diff --git a/remoting/client/plugin/pepper_main_thread_task_runner.cc b/remoting/client/plugin/pepper_main_thread_task_runner.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c22701764ab1f026eea3ff9472cc506fc2ea52ee |
| --- /dev/null |
| +++ b/remoting/client/plugin/pepper_main_thread_task_runner.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "remoting/client/plugin/pepper_main_thread_task_runner.h" |
| + |
| +#include "base/bind.h" |
| +#include "ppapi/cpp/core.h" |
| + |
| +namespace remoting { |
| + |
| +PepperMainThreadTaskRunner::PepperMainThreadTaskRunner() |
| + : core_(pp::Module::Get()->core()), callback_factory_(this) {} |
| +PepperMainThreadTaskRunner::~PepperMainThreadTaskRunner() {} |
|
Wez
2015/10/20 23:43:52
nit: Move this to match the ordering in the header
Sergey Ulanov
2015/10/20 23:49:16
Done.
|
| + |
| +bool PepperMainThreadTaskRunner::PostDelayedTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task, |
| + base::TimeDelta delay) { |
| + core_->CallOnMainThread(delay.InMillisecondsRoundedUp(), |
| + callback_factory_.NewCallback( |
| + &PepperMainThreadTaskRunner::RunTask, task)); |
| + return true; |
| +} |
| + |
| +bool PepperMainThreadTaskRunner::PostNonNestableDelayedTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task, |
| + base::TimeDelta delay) { |
| + return PostDelayedTask(from_here, task, delay); |
| +} |
| + |
| +bool PepperMainThreadTaskRunner::RunsTasksOnCurrentThread() const { |
| + return core_->IsMainThread(); |
| +} |
| + |
| +void PepperMainThreadTaskRunner::RunTask(int32_t result, |
| + const base::Closure& task) { |
| + task.Run(); |
| +} |
| + |
| +} // namespace remoting |