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

Unified Diff: webrtc/base/timeutils.cc

Issue 1859413002: Delete unused code in rtc timeutils. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Deleted a TODO comment. Created 4 years, 8 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 | « webrtc/base/timeutils.h ('k') | webrtc/base/timeutils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/timeutils.cc
diff --git a/webrtc/base/timeutils.cc b/webrtc/base/timeutils.cc
index 0c40c5286ea43d0b209c0c54179ed52de9c5871e..de3e6afb28d824ecb9dfc26f1029dd0d0958fd24 100644
--- a/webrtc/base/timeutils.cc
+++ b/webrtc/base/timeutils.cc
@@ -28,8 +28,6 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/timeutils.h"
-#define EFFICIENT_IMPLEMENTATION 1
-
namespace rtc {
const uint32_t HALF = 0x80000000;
@@ -92,108 +90,24 @@ uint64_t TimeMicros() {
return static_cast<uint64_t>(TimeNanos() / kNumNanosecsPerMicrosec);
}
-#if defined(WEBRTC_WIN)
-static const uint64_t kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL;
-
-struct timeval {
- long tv_sec, tv_usec; // NOLINT
-};
-
-// Emulate POSIX gettimeofday().
-// Based on breakpad/src/third_party/glog/src/utilities.cc
-static int gettimeofday(struct timeval *tv, void *tz) {
- // FILETIME is measured in tens of microseconds since 1601-01-01 UTC.
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
-
- LARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
-
- // Convert to seconds and microseconds since Unix time Epoch.
- int64_t micros = (li.QuadPart - kFileTimeToUnixTimeEpochOffset) / 10;
- tv->tv_sec = static_cast<long>(micros / kNumMicrosecsPerSec); // NOLINT
- tv->tv_usec = static_cast<long>(micros % kNumMicrosecsPerSec); // NOLINT
-
- return 0;
-}
-
-// Emulate POSIX gmtime_r().
-static struct tm *gmtime_r(const time_t *timep, struct tm *result) {
- // On Windows, gmtime is thread safe.
- struct tm *tm = gmtime(timep); // NOLINT
- if (tm == NULL) {
- return NULL;
- }
- *result = *tm;
- return result;
-}
-#endif // WEBRTC_WIN
-
-void CurrentTmTime(struct tm *tm, int *microseconds) {
- struct timeval timeval;
- if (gettimeofday(&timeval, NULL) < 0) {
- // Incredibly unlikely code path.
- timeval.tv_sec = timeval.tv_usec = 0;
- }
- time_t secs = timeval.tv_sec;
- gmtime_r(&secs, tm);
- *microseconds = timeval.tv_usec;
-}
-
uint32_t TimeAfter(int32_t elapsed) {
RTC_DCHECK_GE(elapsed, 0);
RTC_DCHECK_LT(static_cast<uint32_t>(elapsed), HALF);
return Time() + elapsed;
}
-bool TimeIsBetween(uint32_t earlier, uint32_t middle, uint32_t later) {
- if (earlier <= later) {
- return ((earlier <= middle) && (middle <= later));
- } else {
- return !((later < middle) && (middle < earlier));
- }
-}
-
bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later) {
-#if EFFICIENT_IMPLEMENTATION
int32_t diff = later - earlier;
return (diff >= 0 && static_cast<uint32_t>(diff) < HALF);
-#else
- const bool later_or_equal = TimeIsBetween(earlier, later, earlier + HALF);
- return later_or_equal;
-#endif
}
bool TimeIsLater(uint32_t earlier, uint32_t later) {
-#if EFFICIENT_IMPLEMENTATION
int32_t diff = later - earlier;
return (diff > 0 && static_cast<uint32_t>(diff) < HALF);
-#else
- const bool earlier_or_equal = TimeIsBetween(later, earlier, later + HALF);
- return !earlier_or_equal;
-#endif
}
int32_t TimeDiff(uint32_t later, uint32_t earlier) {
-#if EFFICIENT_IMPLEMENTATION
return later - earlier;
-#else
- const bool later_or_equal = TimeIsBetween(earlier, later, earlier + HALF);
- if (later_or_equal) {
- if (earlier <= later) {
- return static_cast<long>(later - earlier);
- } else {
- return static_cast<long>(later + (UINT32_MAX - earlier) + 1);
- }
- } else {
- if (later <= earlier) {
- return -static_cast<long>(earlier - later);
- } else {
- return -static_cast<long>(earlier + (UINT32_MAX - later) + 1);
- }
- }
-#endif
}
int64_t TimeDiff64(int64_t later, int64_t earlier) {
« no previous file with comments | « webrtc/base/timeutils.h ('k') | webrtc/base/timeutils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698