blob: 84eb96abb2656e2a295d07c1fee2d9b79823fe0f [file] [log] [blame]
// Copyright 2014 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 <map>
#include "base/callback.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/test_pending_task.h"
namespace media {
namespace cast {
namespace test {
// This class wraps a SingleThreadTaskRunner, and allows you to scale
// the delay for any posted task by a factor. The factor is changed by
// calling SetSkew(). A skew of 2.0 means that all delayed task will
// have to wait twice as long.
class SkewedSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
explicit SkewedSingleThreadTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// Set the delay multiplier to |skew|.
void SetSkew(double skew);
// base::SingleThreadTaskRunner implementation.
bool PostDelayedTask(const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) final;
bool RunsTasksInCurrentSequence() const final;
// This function is currently not used, and will return false.
bool PostNonNestableDelayedTask(const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) final;
~SkewedSingleThreadTaskRunner() final;
double skew_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
} // namespace test
} // namespace cast
} // namespace media