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

Side by Side Diff: webrtc/base/timeutils.h

Issue 2016863003: Implemented ScopedFakeTime, faking rtc::TimeNanos. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2005 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2005 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_TIMEUTILS_H_ 11 #ifndef WEBRTC_BASE_TIMEUTILS_H_
12 #define WEBRTC_BASE_TIMEUTILS_H_ 12 #define WEBRTC_BASE_TIMEUTILS_H_
13 13
14 #include <ctime> 14 #include <ctime>
15 #include <time.h> 15 #include <time.h>
16 16
17 #include "webrtc/base/basictypes.h" 17 #include "webrtc/base/basictypes.h"
18 18
19 namespace rtc { 19 namespace rtc {
20 20
21 namespace test {
22
23 class FakeTimeInterface {
24 public:
25 virtual uint64_t TimeNanos() = 0;
26 virtual ~FakeTimeInterface() {}
27 };
28
29 // Allows overriding the system clocks in tests, see faketime.h.
30 void SetFakeTime(FakeTimeInterface* f);
31
32 } // namespace test
33
21 static const int64_t kNumMillisecsPerSec = INT64_C(1000); 34 static const int64_t kNumMillisecsPerSec = INT64_C(1000);
22 static const int64_t kNumMicrosecsPerSec = INT64_C(1000000); 35 static const int64_t kNumMicrosecsPerSec = INT64_C(1000000);
23 static const int64_t kNumNanosecsPerSec = INT64_C(1000000000); 36 static const int64_t kNumNanosecsPerSec = INT64_C(1000000000);
24 37
25 static const int64_t kNumMicrosecsPerMillisec = 38 static const int64_t kNumMicrosecsPerMillisec =
26 kNumMicrosecsPerSec / kNumMillisecsPerSec; 39 kNumMicrosecsPerSec / kNumMillisecsPerSec;
27 static const int64_t kNumNanosecsPerMillisec = 40 static const int64_t kNumNanosecsPerMillisec =
28 kNumNanosecsPerSec / kNumMillisecsPerSec; 41 kNumNanosecsPerSec / kNumMillisecsPerSec;
29 static const int64_t kNumNanosecsPerMicrosec = 42 static const int64_t kNumNanosecsPerMicrosec =
30 kNumNanosecsPerSec / kNumMicrosecsPerSec; 43 kNumNanosecsPerSec / kNumMicrosecsPerSec;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }; 90 };
78 91
79 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of 92 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of
80 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that 93 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that
81 // is still 32 bits on many systems. 94 // is still 32 bits on many systems.
82 int64_t TmToSeconds(const std::tm& tm); 95 int64_t TmToSeconds(const std::tm& tm);
83 96
84 } // namespace rtc 97 } // namespace rtc
85 98
86 #endif // WEBRTC_BASE_TIMEUTILS_H_ 99 #endif // WEBRTC_BASE_TIMEUTILS_H_
OLDNEW
« webrtc/base/faketime.h ('K') | « webrtc/base/faketime.h ('k') | webrtc/base/timeutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698