• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "media/cast/test/skewed_single_thread_task_runner.h"
6 
7 #include "base/logging.h"
8 #include "base/time/tick_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 
11 namespace media {
12 namespace cast {
13 namespace test {
14 
SkewedSingleThreadTaskRunner(const scoped_refptr<base::SingleThreadTaskRunner> & task_runner)15 SkewedSingleThreadTaskRunner::SkewedSingleThreadTaskRunner(
16     const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) :
17     skew_(1.0),
18     task_runner_(task_runner) {
19 }
20 
~SkewedSingleThreadTaskRunner()21 SkewedSingleThreadTaskRunner::~SkewedSingleThreadTaskRunner() {}
22 
SetSkew(double skew)23 void SkewedSingleThreadTaskRunner::SetSkew(double skew) {
24   skew_ = skew;
25 }
26 
PostDelayedTask(const tracked_objects::Location & from_here,const base::Closure & task,base::TimeDelta delay)27 bool SkewedSingleThreadTaskRunner::PostDelayedTask(
28     const tracked_objects::Location& from_here,
29     const base::Closure& task,
30     base::TimeDelta delay) {
31   return task_runner_->PostDelayedTask(
32       from_here,
33       task,
34       base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_));
35 }
36 
RunsTasksOnCurrentThread() const37 bool SkewedSingleThreadTaskRunner::RunsTasksOnCurrentThread() const {
38   return task_runner_->RunsTasksOnCurrentThread();
39 }
40 
PostNonNestableDelayedTask(const tracked_objects::Location & from_here,const base::Closure & task,base::TimeDelta delay)41 bool SkewedSingleThreadTaskRunner::PostNonNestableDelayedTask(
42     const tracked_objects::Location& from_here,
43     const base::Closure& task,
44     base::TimeDelta delay) {
45   return task_runner_->PostNonNestableDelayedTask(
46       from_here,
47       task,
48       base::TimeDelta::FromMicroseconds(delay.InMicroseconds() * skew_));
49 }
50 
51 }  // namespace test
52 }  // namespace cast
53 }  // namespace media
54