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> | |
9 | |
10 #include "base/ios/ios_util.h" | |
11 #endif | |
12 | |
13 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
14 #include "base/time/time.h" | 8 #include "base/time/time.h" |
15 | 9 |
16 namespace net { | 10 namespace net { |
17 | 11 |
18 QuicChromiumClock* QuicChromiumClock::GetInstance() { | 12 QuicChromiumClock* QuicChromiumClock::GetInstance() { |
19 return base::Singleton<QuicChromiumClock>::get(); | 13 return base::Singleton<QuicChromiumClock>::get(); |
20 } | 14 } |
21 QuicChromiumClock::QuicChromiumClock() {} | 15 QuicChromiumClock::QuicChromiumClock() {} |
22 | 16 |
23 QuicChromiumClock::~QuicChromiumClock() {} | 17 QuicChromiumClock::~QuicChromiumClock() {} |
24 | 18 |
25 QuicTime QuicChromiumClock::ApproximateNow() const { | 19 QuicTime QuicChromiumClock::ApproximateNow() const { |
26 // At the moment, Chrome does not have a distinct notion of ApproximateNow(). | 20 // At the moment, Chrome does not have a distinct notion of ApproximateNow(). |
27 // We should consider implementing this using MessageLoop::recent_time_. | 21 // We should consider implementing this using MessageLoop::recent_time_. |
28 return Now(); | 22 return Now(); |
29 } | 23 } |
30 | 24 |
31 QuicTime QuicChromiumClock::Now() const { | 25 QuicTime QuicChromiumClock::Now() const { |
32 #if defined(OS_IOS) | |
33 if (base::ios::IsRunningOnIOS10OrLater()) { | |
34 struct timespec tp; | |
35 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { | |
36 return CreateTimeFromMicroseconds(tp.tv_sec * 1000000 + | |
37 tp.tv_nsec / 1000); | |
38 } | |
39 } | |
40 #endif | |
41 return CreateTimeFromMicroseconds(base::TimeTicks::Now().ToInternalValue()); | 26 return CreateTimeFromMicroseconds(base::TimeTicks::Now().ToInternalValue()); |
miu
2017/05/22 22:16:14
Please fix: This is invalid use of ToInternalValue
kapishnikov
2017/05/23 17:56:51
Done.
| |
42 } | 27 } |
43 | 28 |
44 QuicWallTime QuicChromiumClock::WallNow() const { | 29 QuicWallTime QuicChromiumClock::WallNow() const { |
45 return QuicWallTime::FromUNIXMicroseconds(base::Time::Now().ToJavaTime() * | 30 return QuicWallTime::FromUNIXMicroseconds(base::Time::Now().ToJavaTime() * |
miu
2017/05/22 22:16:14
Please fix: You are using a platform conversion fu
kapishnikov
2017/05/23 17:56:51
Done. I think it was truncated to milliseconds bec
| |
46 1000); | 31 1000); |
47 } | 32 } |
48 | 33 |
49 } // namespace net | 34 } // namespace net |
OLD | NEW |