Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: remoting/client/plugin/pepper_main_thread_task_runner.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "remoting/client/plugin/pepper_main_thread_task_runner.h" 5 #include "remoting/client/plugin/pepper_main_thread_task_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ppapi/cpp/core.h" 8 #include "ppapi/cpp/core.h"
9 9
10 namespace remoting { 10 namespace remoting {
11 11
12 PepperMainThreadTaskRunner::PepperMainThreadTaskRunner() 12 PepperMainThreadTaskRunner::PepperMainThreadTaskRunner()
13 : core_(pp::Module::Get()->core()), callback_factory_(this) {} 13 : core_(pp::Module::Get()->core()), callback_factory_(this) {}
14 14
15 bool PepperMainThreadTaskRunner::PostDelayedTask( 15 bool PepperMainThreadTaskRunner::PostDelayedTask(
16 const tracked_objects::Location& from_here, 16 const tracked_objects::Location& from_here,
17 const base::Closure& task, 17 base::OnceClosure task,
18 base::TimeDelta delay) { 18 base::TimeDelta delay) {
19 core_->CallOnMainThread(delay.InMillisecondsRoundedUp(), 19 core_->CallOnMainThread(
20 callback_factory_.NewCallback( 20 delay.InMillisecondsRoundedUp(),
21 &PepperMainThreadTaskRunner::RunTask, task)); 21 callback_factory_.NewCallback(
22 &PepperMainThreadTaskRunner::RunTask,
23 base::Bind([](base::OnceClosure cb) { std::move(cb).Run(); },
24 base::Passed(&task))));
22 return true; 25 return true;
23 } 26 }
24 27
25 bool PepperMainThreadTaskRunner::PostNonNestableDelayedTask( 28 bool PepperMainThreadTaskRunner::PostNonNestableDelayedTask(
26 const tracked_objects::Location& from_here, 29 const tracked_objects::Location& from_here,
27 const base::Closure& task, 30 base::OnceClosure task,
28 base::TimeDelta delay) { 31 base::TimeDelta delay) {
29 return PostDelayedTask(from_here, task, delay); 32 return PostDelayedTask(from_here, std::move(task), delay);
30 } 33 }
31 34
32 bool PepperMainThreadTaskRunner::RunsTasksOnCurrentThread() const { 35 bool PepperMainThreadTaskRunner::RunsTasksOnCurrentThread() const {
33 return core_->IsMainThread(); 36 return core_->IsMainThread();
34 } 37 }
35 38
36 PepperMainThreadTaskRunner::~PepperMainThreadTaskRunner() {} 39 PepperMainThreadTaskRunner::~PepperMainThreadTaskRunner() {}
37 40
38 void PepperMainThreadTaskRunner::RunTask(int32_t result, 41 void PepperMainThreadTaskRunner::RunTask(int32_t result,
39 const base::Closure& task) { 42 const base::Closure& task) {
40 task.Run(); 43 task.Run();
41 } 44 }
42 45
43 } // namespace remoting 46 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698