blob: fd52322a964f13a3d4fb772804717787d8d282d4 [file] [log] [blame]
// Copyright 2015 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 COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_
#define COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_
#include "base/time/time.h"
namespace base {
class TickClock;
}
namespace scheduler {
namespace internal {
// Now() is somewhat expensive so it makes sense not to call Now() unless we
// really need to.
class LazyNow {
public:
explicit LazyNow(base::TimeTicks now) : tick_clock_(nullptr), now_(now) {
DCHECK(!now.is_null());
}
explicit LazyNow(base::TickClock* tick_clock) : tick_clock_(tick_clock) {}
base::TimeTicks Now();
private:
base::TickClock* tick_clock_; // NOT OWNED
base::TimeTicks now_;
};
} // namespace internal
} // namespace scheduler
#endif // COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_