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 7 namespace net { 8 MockClock()9MockClock::MockClock() : now_(QuicTime::Zero()) { 10 } 11 ~MockClock()12MockClock::~MockClock() { 13 } 14 AdvanceTime(QuicTime::Delta delta)15void MockClock::AdvanceTime(QuicTime::Delta delta) { 16 now_ = now_.Add(delta); 17 } 18 Now() const19QuicTime MockClock::Now() const { 20 return now_; 21 } 22 ApproximateNow() const23QuicTime MockClock::ApproximateNow() const { 24 return now_; 25 } 26 WallNow() const27QuicWallTime MockClock::WallNow() const { 28 return QuicWallTime::FromUNIXSeconds( 29 now_.Subtract(QuicTime::Zero()).ToSeconds()); 30 } 31 NowInTicks() const32base::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