Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: net/quic/platform/impl/quic_chromium_clock.cc

Issue 2871573009: Use clock_gettime instead of base::TimeTicks::Now() in QUIC (Closed)
Patch Set: Cleanup Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/platform/api/quic_clock.h ('k') | net/quic/platform/impl/quic_chromium_clock_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Use clock_gettime on iOS>
Zhongyi Shi 2017/05/09 23:30:57 IIRC, clock_gettime is supported and works fine on
ianswett 2017/05/10 00:44:56 +1
Ryan Hamilton 2017/05/10 03:06:04 *facepalm* Done.
9 #include <time.h>
10 #else
11 // Use base::TimeTicks::Now() elsewhere.
12 #include "base/time/time.h"
13 #endif
14
7 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
8 #include "base/time/time.h"
9 16
10 namespace net { 17 namespace net {
11 18
12 QuicChromiumClock* QuicChromiumClock::GetInstance() { 19 QuicChromiumClock* QuicChromiumClock::GetInstance() {
13 return base::Singleton<QuicChromiumClock>::get(); 20 return base::Singleton<QuicChromiumClock>::get();
14 } 21 }
15 QuicChromiumClock::QuicChromiumClock() {} 22 QuicChromiumClock::QuicChromiumClock() {}
16 23
17 QuicChromiumClock::~QuicChromiumClock() {} 24 QuicChromiumClock::~QuicChromiumClock() {}
18 25
19 QuicTime QuicChromiumClock::ApproximateNow() const { 26 QuicTime QuicChromiumClock::ApproximateNow() const {
20 // At the moment, Chrome does not have a distinct notion of ApproximateNow(). 27 // At the moment, Chrome does not have a distinct notion of ApproximateNow().
21 // We should consider implementing this using MessageLoop::recent_time_. 28 // We should consider implementing this using MessageLoop::recent_time_.
22 return Now(); 29 return Now();
23 } 30 }
24 31
25 QuicTime QuicChromiumClock::Now() const { 32 QuicTime QuicChromiumClock::Now() const {
26 return QuicTime(base::TimeTicks::Now()); 33 #if defined(OS_IOS)
34 struct timespec tp;
35 clock_gettime(CLOCK_MONOTONIC, &tp);
36 return MakeTime(tp.tv_nsec / 1000);
37 #else
38 return MakeTime(base::TimeTicks::Now().ToInternalValue());
39 #endif
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
OLDNEW
« no previous file with comments | « net/quic/platform/api/quic_clock.h ('k') | net/quic/platform/impl/quic_chromium_clock_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698