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

Side by Side Diff: media/cast/test/skewed_single_thread_task_runner.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: s/base::ResetAndReturn/std::move/ Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/cast/test/skewed_single_thread_task_runner.h" 5 #include "media/cast/test/skewed_single_thread_task_runner.h"
6 6
7 #include <utility>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/time/tick_clock.h" 10 #include "base/time/tick_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 12
11 namespace media { 13 namespace media {
12 namespace cast { 14 namespace cast {
13 namespace test { 15 namespace test {
14 16
15 SkewedSingleThreadTaskRunner::SkewedSingleThreadTaskRunner( 17 SkewedSingleThreadTaskRunner::SkewedSingleThreadTaskRunner(
16 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) : 18 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) :
17 skew_(1.0), 19 skew_(1.0),
18 task_runner_(task_runner) { 20 task_runner_(task_runner) {
19 } 21 }
20 22
21 SkewedSingleThreadTaskRunner::~SkewedSingleThreadTaskRunner() {} 23 SkewedSingleThreadTaskRunner::~SkewedSingleThreadTaskRunner() {}
22 24
23 void SkewedSingleThreadTaskRunner::SetSkew(double skew) { 25 void SkewedSingleThreadTaskRunner::SetSkew(double skew) {
24 skew_ = skew; 26 skew_ = skew;
25 } 27 }
26 28
27 bool SkewedSingleThreadTaskRunner::PostDelayedTask( 29 bool SkewedSingleThreadTaskRunner::PostDelayedTask(
28 const tracked_objects::Location& from_here, 30 const tracked_objects::Location& from_here,
29 const base::Closure& task, 31 base::Closure task,
30 base::TimeDelta delay) { 32 base::TimeDelta delay) {
31 return task_runner_->PostDelayedTask( 33 return task_runner_->PostDelayedTask(
32 from_here, 34 from_here, std::move(task),
33 task,
34 base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_)); 35 base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_));
35 } 36 }
36 37
37 bool SkewedSingleThreadTaskRunner::RunsTasksOnCurrentThread() const { 38 bool SkewedSingleThreadTaskRunner::RunsTasksOnCurrentThread() const {
38 return task_runner_->RunsTasksOnCurrentThread(); 39 return task_runner_->RunsTasksOnCurrentThread();
39 } 40 }
40 41
41 bool SkewedSingleThreadTaskRunner::PostNonNestableDelayedTask( 42 bool SkewedSingleThreadTaskRunner::PostNonNestableDelayedTask(
42 const tracked_objects::Location& from_here, 43 const tracked_objects::Location& from_here,
43 const base::Closure& task, 44 base::Closure task,
44 base::TimeDelta delay) { 45 base::TimeDelta delay) {
45 return task_runner_->PostNonNestableDelayedTask( 46 return task_runner_->PostNonNestableDelayedTask(
46 from_here, 47 from_here, std::move(task),
47 task,
48 base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_)); 48 base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_));
49 } 49 }
50 50
51 } // namespace test 51 } // namespace test
52 } // namespace cast 52 } // namespace cast
53 } // namespace media 53 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698