Commit 0c0ac6a1 authored by mithro's avatar mithro Committed by Commit bot

New features include;

 * Actually running the tasks in the ordered you asked!
 * Allow running only pending tasks, all tasks until idle, to a given time or
   for a given period.
 * Allow stopping of running tasks on *any* arbitrary condition. No longer will
   your tasks stop working when someone adds a new task or changes the task
   order!
 * Task runner intimately connected to time and controls Now().
   Supports both automatic management and manual control.

This change makes it possible for the scheduler_unit tests to be 100%
deterministic. It also allows them to be more flexible and less brittle.

BUG=380889

Review URL: https://codereview.chromium.org/387493002

Cr-Commit-Position: refs/heads/master@{#294059}
parent dc6bae3b
......@@ -599,6 +599,8 @@ source_set("test_support") {
"test/test_context_support.h",
"test/test_gles2_interface.cc",
"test/test_gles2_interface.h",
"test/test_now_source.cc",
"test/test_now_source.h",
"test/test_occlusion_tracker.h",
"test/test_shared_bitmap_manager.cc",
"test/test_shared_bitmap_manager.h",
......
......@@ -234,6 +234,8 @@
'test/test_context_support.h',
'test/test_gles2_interface.cc',
'test/test_gles2_interface.h',
'test/test_now_source.cc',
'test/test_now_source.h',
'test/test_occlusion_tracker.h',
'test/test_shared_bitmap_manager.cc',
'test/test_shared_bitmap_manager.h',
......
......@@ -19,15 +19,8 @@ namespace cc {
Scheduler::SyntheticBeginFrameSource::SyntheticBeginFrameSource(
Scheduler* scheduler,
base::SingleThreadTaskRunner* task_runner)
: scheduler_(scheduler) {
if (gfx::FrameTime::TimestampsAreHighRes()) {
time_source_ = DelayBasedTimeSourceHighRes::Create(
scheduler_->VSyncInterval(), task_runner);
} else {
time_source_ = DelayBasedTimeSource::Create(scheduler_->VSyncInterval(),
task_runner);
}
scoped_refptr<DelayBasedTimeSource> time_source)
: scheduler_(scheduler), time_source_(time_source) {
time_source_->SetClient(this);
}
......@@ -126,9 +119,21 @@ Scheduler::~Scheduler() {
}
void Scheduler::SetupSyntheticBeginFrames() {
scoped_refptr<DelayBasedTimeSource> time_source;
if (gfx::FrameTime::TimestampsAreHighRes()) {
time_source = DelayBasedTimeSourceHighRes::Create(VSyncInterval(),
task_runner_.get());
} else {
time_source =
DelayBasedTimeSource::Create(VSyncInterval(), task_runner_.get());
}
DCHECK(!synthetic_begin_frame_source_);
synthetic_begin_frame_source_.reset(
new SyntheticBeginFrameSource(this, task_runner_.get()));
new SyntheticBeginFrameSource(this, time_source));
}
base::TimeTicks Scheduler::Now() const {
return gfx::FrameTime::Now();
}
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
......@@ -262,7 +267,7 @@ base::TimeTicks Scheduler::AnticipatedDrawTime() const {
begin_impl_frame_args_.interval <= base::TimeDelta())
return base::TimeTicks();
base::TimeTicks now = gfx::FrameTime::Now();
base::TimeTicks now = Now();
base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
begin_impl_frame_args_.deadline);
int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
......@@ -340,7 +345,7 @@ void Scheduler::BeginUnthrottledFrame() {
DCHECK(!settings_.throttle_frame_production);
DCHECK(begin_retro_frame_args_.empty());
base::TimeTicks now = gfx::FrameTime::Now();
base::TimeTicks now = Now();
base::TimeTicks deadline = now + vsync_interval_;
BeginFrameArgs begin_frame_args =
......@@ -451,7 +456,7 @@ void Scheduler::BeginRetroFrame() {
// TODO(brianderson): In the future, long deadlines could result in us not
// draining the queue if we don't catch up. If we consistently can't catch
// up, our fallback should be to lower our frame rate.
base::TimeTicks now = gfx::FrameTime::Now();
base::TimeTicks now = Now();
base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate();
while (!begin_retro_frame_args_.empty() &&
now > AdjustedBeginImplFrameDeadline(begin_retro_frame_args_.front(),
......@@ -479,6 +484,10 @@ void Scheduler::BeginRetroFrame() {
// will check if there is a pending BeginRetroFrame to ensure we handle
// BeginFrames in FIFO order.
void Scheduler::PostBeginRetroFrameIfNeeded() {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
"Scheduler::PostBeginRetroFrameIfNeeded",
"state",
AsValue());
if (!last_set_needs_begin_frame_)
return;
......@@ -555,6 +564,8 @@ base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline(
}
void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
TRACE_EVENT1(
"cc", "Scheduler::ScheduleBeginImplFrameDeadline", "deadline", deadline);
if (settings_.using_synchronous_renderer_compositor) {
// The synchronous renderer compositor has to make its GL calls
// within this call.
......@@ -567,7 +578,7 @@ void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
begin_impl_frame_deadline_task_.Cancel();
begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_);
base::TimeDelta delta = deadline - gfx::FrameTime::Now();
base::TimeDelta delta = deadline - Now();
if (delta <= base::TimeDelta())
delta = base::TimeDelta();
task_runner_->PostDelayedTask(
......@@ -697,9 +708,8 @@ scoped_refptr<base::debug::ConvertableToTraceFormat> Scheduler::AsValue()
}
state->BeginDictionary("scheduler_state");
state->SetDouble(
"time_until_anticipated_draw_time_ms",
(AnticipatedDrawTime() - base::TimeTicks::Now()).InMillisecondsF());
state->SetDouble("time_until_anticipated_draw_time_ms",
(AnticipatedDrawTime() - Now()).InMillisecondsF());
state->SetDouble("vsync_interval_ms", vsync_interval_.InMillisecondsF());
state->SetDouble("estimated_parent_draw_time_ms",
estimated_parent_draw_time_.InMillisecondsF());
......
......@@ -137,7 +137,7 @@ class CC_EXPORT Scheduler {
class CC_EXPORT SyntheticBeginFrameSource : public TimeSourceClient {
public:
SyntheticBeginFrameSource(Scheduler* scheduler,
base::SingleThreadTaskRunner* task_runner);
scoped_refptr<DelayBasedTimeSource> time_source);
virtual ~SyntheticBeginFrameSource();
// Updates the phase and frequency of the timer.
......@@ -168,6 +168,8 @@ class CC_EXPORT Scheduler {
int layer_tree_host_id,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
virtual base::TimeTicks Now() const;
const SchedulerSettings settings_;
SchedulerClient* client_;
int layer_tree_host_id_;
......@@ -198,6 +200,8 @@ class CC_EXPORT Scheduler {
bool inside_process_scheduled_actions_;
SchedulerStateMachine::Action inside_action_;
base::TimeDelta VSyncInterval() { return vsync_interval_; }
private:
base::TimeTicks AdjustedBeginImplFrameDeadline(
const BeginFrameArgs& args,
......@@ -221,8 +225,6 @@ class CC_EXPORT Scheduler {
void PollForAnticipatedDrawTriggers();
void PollToAdvanceCommitState();
base::TimeDelta VSyncInterval() { return vsync_interval_; }
base::TimeDelta EstimatedParentDrawTime() {
return estimated_parent_draw_time_;
}
......
This diff is collapsed.
......@@ -36,6 +36,22 @@ BeginFrameArgs CreateExpiredBeginFrameArgsForTesting() {
BeginFrameArgs::DefaultInterval());
}
BeginFrameArgs CreateBeginFrameArgsForTesting(
scoped_refptr<TestNowSource> now_src) {
base::TimeTicks now = now_src->Now();
return BeginFrameArgs::Create(now,
now + (BeginFrameArgs::DefaultInterval() / 2),
BeginFrameArgs::DefaultInterval());
}
BeginFrameArgs CreateExpiredBeginFrameArgsForTesting(
scoped_refptr<TestNowSource> now_src) {
base::TimeTicks now = now_src->Now();
return BeginFrameArgs::Create(now,
now - BeginFrameArgs::DefaultInterval(),
BeginFrameArgs::DefaultInterval());
}
bool operator==(const BeginFrameArgs& lhs, const BeginFrameArgs& rhs) {
return (lhs.frame_time == rhs.frame_time) && (lhs.deadline == rhs.deadline) &&
(lhs.interval == rhs.interval);
......
......@@ -9,6 +9,7 @@
#include "base/time/time.h"
#include "cc/output/begin_frame_args.h"
#include "cc/test/test_now_source.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
......@@ -21,6 +22,13 @@ BeginFrameArgs CreateBeginFrameArgsForTesting(int64 frame_time,
int64 interval);
BeginFrameArgs CreateExpiredBeginFrameArgsForTesting();
// Creates a BeginFrameArgs using the fake Now value stored on the
// OrderSimpleTaskRunner.
BeginFrameArgs CreateBeginFrameArgsForTesting(
scoped_refptr<TestNowSource> now_src);
BeginFrameArgs CreateExpiredBeginFrameArgsForTesting(
scoped_refptr<TestNowSource> now_src);
// gtest helpers -- these *must* be in the same namespace as the types they
// operate on.
......
This diff is collapsed.
......@@ -5,24 +5,146 @@
#ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
#define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
#include <limits>
#include <set>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/test/test_simple_task_runner.h"
#include "cc/test/test_now_source.h"
namespace cc {
// Subclass of TestPendingTask which has a unique ID for every task, supports
// being used inside a std::set and has debug tracing support.
class TestOrderablePendingTask : public base::TestPendingTask {
public:
TestOrderablePendingTask();
TestOrderablePendingTask(const tracked_objects::Location& location,
const base::Closure& task,
base::TimeTicks post_time,
base::TimeDelta delay,
TestNestability nestability);
~TestOrderablePendingTask();
// operators needed by std::set and comparison
bool operator==(const TestOrderablePendingTask& other) const;
bool operator<(const TestOrderablePendingTask& other) const;
// debug tracing functions
scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
void AsValueInto(base::debug::TracedValue* state) const;
private:
static size_t task_id_counter;
const size_t task_id_;
};
// This runs pending tasks based on task's post_time + delay.
// We should not execute a delayed task sooner than some of the queued tasks
// which don't have a delay even though it is queued early.
class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner {
class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner {
public:
OrderedSimpleTaskRunner();
OrderedSimpleTaskRunner(scoped_refptr<TestNowSource> now_src,
bool advance_now);
// base::TestSimpleTaskRunner implementation:
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) OVERRIDE;
virtual bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) OVERRIDE;
virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
// Set a maximum number of tasks to run at once. Useful as a timeout to
// prevent infinite task loops.
static const size_t kAbsoluteMaxTasks;
void SetRunTaskLimit(size_t max_tasks) { max_tasks_ = max_tasks; }
void ClearRunTaskLimit() { max_tasks_ = kAbsoluteMaxTasks; }
// Allow task runner to advance now when running tasks.
void SetAutoAdvanceNowToPendingTasks(bool advance_now) {
advance_now_ = advance_now;
}
base::TimeTicks NextTaskTime();
base::TimeDelta DelayToNextTaskTime();
// Run tasks while the callback returns true or too many tasks have been run.
// Returns true if there are still pending tasks left.
bool RunTasksWhile(base::Callback<bool(void)> condition);
virtual void RunPendingTasks() OVERRIDE;
// Run tasks while *all* of the callbacks return true or too many tasks have
// been run. Exits on the *first* condition which returns false, skipping
// calling all remaining conditions. Conditions can have side effects,
// including modifying the task queue.
// Returns true if there are still pending tasks left.
bool RunTasksWhile(
const std::vector<base::Callback<bool(void)> >& conditions);
// Convenience functions to run tasks with common conditions.
// Run tasks which existed at the start of this call.
// Return code indicates tasks still exist to run.
bool RunPendingTasks();
// Keep running tasks until no tasks are left.
// Return code indicates tasks still exist to run which also indicates if
// runner reached idle.
bool RunUntilIdle();
// Keep running tasks until given time period.
// Return code indicates tasks still exist to run.
bool RunUntilTime(base::TimeTicks time);
bool RunForPeriod(base::TimeDelta period);
// base::debug tracing functionality
scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
virtual void AsValueInto(base::debug::TracedValue* state) const;
// Common conditions to run for, exposed publicly to allow external users to
// use their own combinations.
// -------------------------------------------------------------------------
// Keep running until the given number of tasks have run.
// You generally shouldn't use this check as it will cause your tests to fail
// when code is changed adding a new task. It is useful as a "timeout" type
// solution.
base::Callback<bool(void)> TaskRunCountBelow(size_t max_tasks);
// Keep running until a task which didn't exist initially would run.
base::Callback<bool(void)> TaskExistedInitially();
// Stop running tasks when NextTaskTime() >= stop_at
base::Callback<bool(void)> NowBefore(base::TimeTicks stop_at);
// Advance Now() to the next task to run.
base::Callback<bool(void)> AdvanceNow();
protected:
static bool TaskRunCountBelowCallback(size_t max_tasks, size_t* task_run);
bool TaskExistedInitiallyCallback(
const std::set<TestOrderablePendingTask>& existing_tasks);
bool NowBeforeCallback(base::TimeTicks stop_at);
bool AdvanceNowCallback();
virtual ~OrderedSimpleTaskRunner();
base::ThreadChecker thread_checker_;
bool advance_now_;
scoped_refptr<TestNowSource> now_src_;
size_t max_tasks_;
bool inside_run_tasks_until_;
std::set<TestOrderablePendingTask> pending_tasks_;
private:
DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner);
};
......
......@@ -4,6 +4,8 @@
#include "cc/test/scheduler_test_common.h"
#include <string>
#include "base/logging.h"
namespace cc {
......@@ -14,4 +16,50 @@ void FakeTimeSourceClient::OnTimerTick() {
base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
TestDelayBasedTimeSource::TestDelayBasedTimeSource(
scoped_refptr<TestNowSource> now_src,
base::TimeDelta interval,
OrderedSimpleTaskRunner* task_runner)
: DelayBasedTimeSource(interval, task_runner), now_src_(now_src) {
}
base::TimeTicks TestDelayBasedTimeSource::Now() const {
return now_src_->Now();
}
std::string TestDelayBasedTimeSource::TypeString() const {
return "TestDelayBasedTimeSource";
}
TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {
}
TestScheduler::TestScheduler(
scoped_refptr<TestNowSource> now_src,
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner)
: Scheduler(client,
scheduler_settings,
layer_tree_host_id,
test_task_runner),
now_src_(now_src),
test_task_runner_(test_task_runner.get()) {
if (!settings_.begin_frame_scheduling_enabled) {
scoped_refptr<DelayBasedTimeSource> time_source =
TestDelayBasedTimeSource::Create(
now_src, VSyncInterval(), test_task_runner_);
synthetic_begin_frame_source_.reset(
new SyntheticBeginFrameSource(this, time_source));
}
}
base::TimeTicks TestScheduler::Now() const {
return now_src_->Now();
}
TestScheduler::~TestScheduler() {
}
} // namespace cc
......@@ -5,10 +5,14 @@
#ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_
#define CC_TEST_SCHEDULER_TEST_COMMON_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "cc/scheduler/scheduler.h"
#include "cc/test/ordered_simple_task_runner.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
......@@ -46,6 +50,76 @@ class FakeDelayBasedTimeSource : public DelayBasedTimeSource {
base::TimeTicks now_;
};
class TestDelayBasedTimeSource : public DelayBasedTimeSource {
public:
static scoped_refptr<TestDelayBasedTimeSource> Create(
scoped_refptr<TestNowSource> now_src,
base::TimeDelta interval,
OrderedSimpleTaskRunner* task_runner) {
return make_scoped_refptr(
new TestDelayBasedTimeSource(now_src, interval, task_runner));
}
protected:
TestDelayBasedTimeSource(scoped_refptr<TestNowSource> now_src,
base::TimeDelta interval,
OrderedSimpleTaskRunner* task_runner);
// Overridden from DelayBasedTimeSource
virtual ~TestDelayBasedTimeSource();
virtual base::TimeTicks Now() const OVERRIDE;
virtual std::string TypeString() const OVERRIDE;
scoped_refptr<TestNowSource> now_src_;
};
class TestScheduler : public Scheduler {
public:
static scoped_ptr<TestScheduler> Create(
scoped_refptr<TestNowSource> now_src,
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id) {
// A bunch of tests require Now() to be > BeginFrameArgs::DefaultInterval()
now_src->AdvanceNow(base::TimeDelta::FromMilliseconds(100));
scoped_refptr<OrderedSimpleTaskRunner> test_task_runner =
new OrderedSimpleTaskRunner(now_src, true);
return make_scoped_ptr(new TestScheduler(now_src,
client,
scheduler_settings,
layer_tree_host_id,
test_task_runner));
}
// Extra test helper functionality
bool IsBeginRetroFrameArgsEmpty() const {
return begin_retro_frame_args_.empty();
}
bool IsSyntheticBeginFrameSourceActive() const {
return synthetic_begin_frame_source_->IsActive();
}
OrderedSimpleTaskRunner& task_runner() { return *test_task_runner_; }
virtual ~TestScheduler();
protected:
// Overridden from Scheduler.
virtual base::TimeTicks Now() const OVERRIDE;
private:
TestScheduler(scoped_refptr<TestNowSource> now_src,
SchedulerClient* client,
const SchedulerSettings& scheduler_settings,
int layer_tree_host_id,
const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner);
scoped_refptr<TestNowSource> now_src_;
OrderedSimpleTaskRunner* test_task_runner_;
};
} // namespace cc
#endif // CC_TEST_SCHEDULER_TEST_COMMON_H_
// 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 <limits>
#include <string>
#include "cc/test/test_now_source.h"
namespace cc {
// TestNowSource::Constructors
scoped_refptr<TestNowSource> TestNowSource::Create() {
return make_scoped_refptr(new TestNowSource());
}
scoped_refptr<TestNowSource> TestNowSource::Create(base::TimeTicks initial) {
return make_scoped_refptr(new TestNowSource(initial));
}
scoped_refptr<TestNowSource> TestNowSource::Create(int64_t initial) {
return make_scoped_refptr(new TestNowSource(initial));
}
TestNowSource::TestNowSource()
: initial_(base::TimeTicks::FromInternalValue(10000)), now_() {
Reset();
}
TestNowSource::TestNowSource(base::TimeTicks initial)
: initial_(initial), now_() {
Reset();
}
TestNowSource::TestNowSource(int64_t initial)
: initial_(base::TimeTicks::FromInternalValue(initial)), now_() {
Reset();
}
TestNowSource::~TestNowSource() {
}
// TestNowSource actual functionality
void TestNowSource::Reset() {
TRACE_EVENT_INSTANT2("cc",
"TestNowSource::Reset",
TRACE_EVENT_SCOPE_THREAD,
"previous",
now_,
"initial",
initial_);
now_ = initial_;
}
base::TimeTicks TestNowSource::Now() const {
return now_;
}
void TestNowSource::SetNow(base::TimeTicks time) {
TRACE_EVENT_INSTANT2("cc",
"TestNowSource::SetNow",
TRACE_EVENT_SCOPE_THREAD,
"previous",
now_,
"new",
time);
DCHECK(time >= now_); // Time should always go forward.
now_ = time;
}
void TestNowSource::AdvanceNow(base::TimeDelta period) {
TRACE_EVENT_INSTANT2("cc",
"TestNowSource::AdvanceNow",
TRACE_EVENT_SCOPE_THREAD,
"previous",
now_,
"by",
period.ToInternalValue());
DCHECK(now_ != kAbsoluteMaxNow);
DCHECK(period >= base::TimeDelta()); // Time should always go forward.
now_ += period;
}
const base::TimeTicks TestNowSource::kAbsoluteMaxNow =
base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max());
// TestNowSource::Convenience functions
void TestNowSource::AdvanceNowMicroseconds(int64_t period_in_microseconds) {
AdvanceNow(base::TimeDelta::FromMicroseconds(period_in_microseconds));
}
void TestNowSource::SetNowMicroseconds(int64_t time_in_microseconds) {
SetNow(base::TimeTicks::FromInternalValue(time_in_microseconds));
}
// TestNowSource::Tracing functions
void TestNowSource::AsValueInto(base::debug::TracedValue* state) const {
state->SetInteger("now_in_microseconds", now_.ToInternalValue());
}
scoped_refptr<base::debug::ConvertableToTraceFormat> TestNowSource::AsValue()
const {
scoped_refptr<base::debug::TracedValue> state =
new base::debug::TracedValue();
AsValueInto(state.get());
return state;
}
// TestNowSource::Pretty printing functions
std::string TestNowSource::ToString() const {
std::string output("TestNowSource(");
AsValue()->AppendAsTraceFormat(&output);
output += ")";
return output;
}
::std::ostream& operator<<(::std::ostream& os,
const scoped_refptr<TestNowSource>& src) {
os << src->ToString();
return os;
}
void PrintTo(const scoped_refptr<TestNowSource>& src, ::std::ostream* os) {
*os << src;
}
} // namespace cc
// 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.
#ifndef CC_TEST_TEST_NOW_SOURCE_H_
#define CC_TEST_TEST_NOW_SOURCE_H_
#include <string>
#include "base/basictypes.h"
#include "base/debug/trace_event.h"
#include "base/debug/trace_event_argument.h"
#include "base/logging.h"
namespace cc {
class TestNowSource : public base::RefCounted<TestNowSource> {
public:
static scoped_refptr<TestNowSource> Create();
static scoped_refptr<TestNowSource> Create(int64_t initial);
static scoped_refptr<TestNowSource> Create(base::TimeTicks initial);
virtual void Reset();
virtual base::TimeTicks Now() const;
virtual void SetNow(base::TimeTicks time);
virtual void AdvanceNow(base::TimeDelta period);
// Convenience functions to make it the now source easier to use in unit
// tests.
void AdvanceNowMicroseconds(int64_t period_in_microseconds);
void SetNowMicroseconds(int64_t time_in_microseconds);
static const base::TimeTicks kAbsoluteMaxNow;
// Tracing functions
scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
void AsValueInto(base::debug::TracedValue* state) const;
std::string ToString() const;
protected:
TestNowSource();
explicit TestNowSource(int64_t initial);
explicit TestNowSource(base::TimeTicks initial);
base::TimeTicks initial_;
base::TimeTicks now_;
private:
friend class base::RefCounted<TestNowSource>;
virtual ~TestNowSource();
};
// gtest pretty printing functions
void PrintTo(const scoped_refptr<TestNowSource>& src, ::std::ostream* os);
::std::ostream& operator<<(::std::ostream& os,
const scoped_refptr<TestNowSource>& src);
} // namespace cc
#endif // CC_TEST_TEST_NOW_SOURCE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment