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

Unified Diff: net/quic/platform/impl/quic_chromium_clock.cc

Issue 2894173002: Use faster clock_gettime() instead of sysctl() to get current ticks on iOS10 (Closed)
Patch Set: Small fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/time/time_mac.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/platform/impl/quic_chromium_clock.cc
diff --git a/net/quic/platform/impl/quic_chromium_clock.cc b/net/quic/platform/impl/quic_chromium_clock.cc
index fb591f842feffedc69d6145f50771c62b7e1ac14..78ca26ec6861285bb4391e6f15e94c63a2c4156f 100644
--- a/net/quic/platform/impl/quic_chromium_clock.cc
+++ b/net/quic/platform/impl/quic_chromium_clock.cc
@@ -4,12 +4,6 @@
#include "net/quic/platform/impl/quic_chromium_clock.h"
-#if defined(OS_IOS)
-#include <time.h>
-
-#include "base/ios/ios_util.h"
-#endif
-
#include "base/memory/singleton.h"
#include "base/time/time.h"
@@ -29,21 +23,17 @@ QuicTime QuicChromiumClock::ApproximateNow() const {
}
QuicTime QuicChromiumClock::Now() const {
-#if defined(OS_IOS)
- if (base::ios::IsRunningOnIOS10OrLater()) {
- struct timespec tp;
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
- return CreateTimeFromMicroseconds(tp.tv_sec * 1000000 +
- tp.tv_nsec / 1000);
- }
- }
-#endif
- return CreateTimeFromMicroseconds(base::TimeTicks::Now().ToInternalValue());
+ int64_t ticks = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds();
+ DCHECK_GE(ticks, 0);
+ return CreateTimeFromMicroseconds(ticks);
}
QuicWallTime QuicChromiumClock::WallNow() const {
- return QuicWallTime::FromUNIXMicroseconds(base::Time::Now().ToJavaTime() *
- 1000);
+ const base::TimeDelta time_since_unix_epoch =
+ base::Time::Now() - base::Time::UnixEpoch();
+ int64_t time_since_unix_epoch_micro = time_since_unix_epoch.InMicroseconds();
+ DCHECK_GE(time_since_unix_epoch_micro, 0);
+ return QuicWallTime::FromUNIXMicroseconds(time_since_unix_epoch_micro);
}
} // namespace net
« no previous file with comments | « base/time/time_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698