1// Copyright (c) 2012 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 "net/quic/test_tools/mock_clock.h" 6 7namespace net { 8 9MockClock::MockClock() : now_(QuicTime::Zero()) { 10} 11 12MockClock::~MockClock() { 13} 14 15void MockClock::AdvanceTime(QuicTime::Delta delta) { 16 now_ = now_.Add(delta); 17} 18 19QuicTime MockClock::Now() const { 20 return now_; 21} 22 23QuicTime MockClock::ApproximateNow() const { 24 return now_; 25} 26 27QuicWallTime MockClock::WallNow() const { 28 return QuicWallTime::FromUNIXSeconds( 29 now_.Subtract(QuicTime::Zero()).ToSeconds()); 30} 31 32base::TimeTicks MockClock::NowInTicks() const { 33 base::TimeTicks ticks; 34 return ticks + base::TimeDelta::FromMicroseconds( 35 now_.Subtract(QuicTime::Zero()).ToMicroseconds()); 36} 37 38} // namespace net 39