Chromium Code Reviews| Index: remoting/client/plugin/main_plugin_thread_task_runner.cc |
| diff --git a/remoting/client/plugin/main_plugin_thread_task_runner.cc b/remoting/client/plugin/main_plugin_thread_task_runner.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35095ab29e1011cc5ab9258978e9b235dfc0cf33 |
| --- /dev/null |
| +++ b/remoting/client/plugin/main_plugin_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/main_plugin_thread_task_runner.h" |
| + |
| +#include "base/bind.h" |
| +#include "ppapi/cpp/core.h" |
| + |
| +namespace remoting { |
| + |
| +MainPluginThreadTaskRunner::MainPluginThreadTaskRunner() |
| + : core_(pp::Module::Get()->core()), callback_factory_(this) {} |
| +MainPluginThreadTaskRunner::~MainPluginThreadTaskRunner() {} |
| + |
| +bool MainPluginThreadTaskRunner::PostDelayedTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task, |
| + base::TimeDelta delay) { |
| + core_->CallOnMainThread(delay.InMilliseconds(), |
|
Wez
2015/10/20 23:05:48
Any risk of e.g. spinning due to this fine-grained
Sergey Ulanov
2015/10/20 23:28:05
Here CallOnMainThread() is guaranteed to be called
Wez
2015/10/20 23:43:52
Right - spinning callers are as bad as spinning in
|
| + callback_factory_.NewCallback( |
| + &MainPluginThreadTaskRunner::RunTask, task)); |
| + return true; |
| +} |
| + |
| +bool MainPluginThreadTaskRunner::PostNonNestableDelayedTask( |
| + const tracked_objects::Location& from_here, |
| + const base::Closure& task, |
| + base::TimeDelta delay) { |
| + return PostDelayedTask(from_here, task, delay); |
| +} |
| + |
| +bool MainPluginThreadTaskRunner::RunsTasksOnCurrentThread() const { |
| + return core_->IsMainThread(); |
| +} |
| + |
| +void MainPluginThreadTaskRunner::RunTask(int32_t result, |
| + const base::Closure& closure) { |
| + closure.Run(); |
| +} |
| + |
| +} // namespace remoting |