Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/platform/impl/quic_chromium_clock.h" | 5 #include "net/quic/platform/impl/quic_chromium_clock.h" |
| 6 | 6 |
| 7 #if defined(OS_IOS) | |
| 8 #include <time.h> | |
|
ianswett
2017/05/10 10:44:13
nit: Should this be indented, like it is below?
Ryan Hamilton
2017/05/10 13:17:27
I don't think so, because #includes are not indent
| |
| 9 | |
| 10 #include "base/ios/ios_util.h" | |
| 11 #endif | |
| 12 | |
| 7 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 8 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 9 | 15 |
| 10 namespace net { | 16 namespace net { |
| 11 | 17 |
| 12 QuicChromiumClock* QuicChromiumClock::GetInstance() { | 18 QuicChromiumClock* QuicChromiumClock::GetInstance() { |
| 13 return base::Singleton<QuicChromiumClock>::get(); | 19 return base::Singleton<QuicChromiumClock>::get(); |
| 14 } | 20 } |
| 15 QuicChromiumClock::QuicChromiumClock() {} | 21 QuicChromiumClock::QuicChromiumClock() {} |
| 16 | 22 |
| 17 QuicChromiumClock::~QuicChromiumClock() {} | 23 QuicChromiumClock::~QuicChromiumClock() {} |
| 18 | 24 |
| 19 QuicTime QuicChromiumClock::ApproximateNow() const { | 25 QuicTime QuicChromiumClock::ApproximateNow() const { |
| 20 // At the moment, Chrome does not have a distinct notion of ApproximateNow(). | 26 // At the moment, Chrome does not have a distinct notion of ApproximateNow(). |
| 21 // We should consider implementing this using MessageLoop::recent_time_. | 27 // We should consider implementing this using MessageLoop::recent_time_. |
| 22 return Now(); | 28 return Now(); |
| 23 } | 29 } |
| 24 | 30 |
| 25 QuicTime QuicChromiumClock::Now() const { | 31 QuicTime QuicChromiumClock::Now() const { |
| 26 return QuicTime(base::TimeTicks::Now()); | 32 #if defined(OS_IOS) |
| 33 if (base::ios::IsRunningOnIOS10OrLater()) { | |
| 34 struct timespec tp; | |
| 35 clock_gettime(CLOCK_MONOTONIC, &tp); | |
| 36 return CreateTimeFromMicroseconds(tp.tv_nsec / 1000); | |
|
kapishnikov
2017/05/10 15:25:38
Should it be:
return CreateTimeFromMicroseconds(tp
Ryan Hamilton
2017/05/10 17:05:56
Done.
| |
| 37 } | |
| 38 #endif | |
| 39 return CreateTimeFromMicroseconds(base::TimeTicks::Now().ToInternalValue()); | |
|
ianswett
2017/05/10 11:40:36
As mentioned in the thread, Ideally we'd update ba
Ryan Hamilton
2017/05/10 13:17:27
That's beyond the scope of this CL, but I'll talk
| |
| 27 } | 40 } |
| 28 | 41 |
| 29 QuicWallTime QuicChromiumClock::WallNow() const { | 42 QuicWallTime QuicChromiumClock::WallNow() const { |
| 30 return QuicWallTime::FromUNIXMicroseconds(base::Time::Now().ToJavaTime() * | 43 return QuicWallTime::FromUNIXMicroseconds(base::Time::Now().ToJavaTime() * |
| 31 1000); | 44 1000); |
| 32 } | 45 } |
| 33 | 46 |
| 34 } // namespace net | 47 } // namespace net |
| OLD | NEW |