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

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

Issue 2038213002: Revert of Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/base/signalthread_unittest.cc ('k') | webrtc/base/timeutils.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 /* 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
(...skipping 21 matching lines...) Expand all
32 // TODO(honghaiz): Define a type for the time value specifically. 32 // TODO(honghaiz): Define a type for the time value specifically.
33 33
34 class ClockInterface { 34 class ClockInterface {
35 public: 35 public:
36 virtual ~ClockInterface() {} 36 virtual ~ClockInterface() {}
37 virtual uint64_t TimeNanos() const = 0; 37 virtual uint64_t TimeNanos() const = 0;
38 }; 38 };
39 39
40 // Sets the global source of time. This is useful mainly for unit tests. 40 // Sets the global source of time. This is useful mainly for unit tests.
41 // 41 //
42 // Returns the previously set ClockInterface, or nullptr if none is set. 42 // Does not transfer ownership of the clock.
43 // 43 // SetClock(nullptr) should be called before the ClockInterface is deleted.
44 // Does not transfer ownership of the clock. SetClockForTesting(nullptr)
45 // should be called before the ClockInterface is deleted.
46 // 44 //
47 // This method is not thread-safe; it should only be used when no other thread 45 // This method is not thread-safe; it should only be used when no other thread
48 // is running (for example, at the start/end of a unit test, or start/end of 46 // is running (for example, at the start/end of a unit test, or start/end of
49 // main()). 47 // main()).
50 // 48 //
51 // TODO(deadbeef): Instead of having functions that access this global 49 // TODO(deadbeef): Instead of having functions that access this global
52 // ClockInterface, we may want to pass the ClockInterface into everything 50 // ClockInterface, we may want to pass the ClockInterface into everything
53 // that uses it, eliminating the need for a global variable and this function. 51 // that uses it, eliminating the need for a global variable and this function.
54 ClockInterface* SetClockForTesting(ClockInterface* clock); 52 void SetClock(ClockInterface* clock);
55 53
56 // Returns the current time in milliseconds in 32 bits. 54 // Returns the current time in milliseconds in 32 bits.
57 uint32_t Time32(); 55 uint32_t Time32();
58 56
59 // Returns the current time in milliseconds in 64 bits. 57 // Returns the current time in milliseconds in 64 bits.
60 int64_t TimeMillis(); 58 int64_t TimeMillis();
61 // Deprecated. Do not use this in any new code. 59 // Deprecated. Do not use this in any new code.
62 inline int64_t Time() { 60 inline int64_t Time() {
63 return TimeMillis(); 61 return TimeMillis();
64 } 62 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }; 97 };
100 98
101 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of 99 // Convert from std::tm, which is relative to 1900-01-01 00:00 to number of
102 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that 100 // seconds from 1970-01-01 00:00 ("epoch"). Don't return time_t since that
103 // is still 32 bits on many systems. 101 // is still 32 bits on many systems.
104 int64_t TmToSeconds(const std::tm& tm); 102 int64_t TmToSeconds(const std::tm& tm);
105 103
106 } // namespace rtc 104 } // namespace rtc
107 105
108 #endif // WEBRTC_BASE_TIMEUTILS_H_ 106 #endif // WEBRTC_BASE_TIMEUTILS_H_
OLDNEW
« no previous file with comments | « webrtc/base/signalthread_unittest.cc ('k') | webrtc/base/timeutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698