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

Side by Side Diff: third_party/WebKit/Source/platform/wtf/Time.h

Issue 2928833002: [CacheStorage] [DevTools] Added "Time Received" column to cache storage data grid (Closed)
Patch Set: Removed timestamp from tests Created 3 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef WTF_Time_h 5 #ifndef WTF_Time_h
6 #define WTF_Time_h 6 #define WTF_Time_h
7 7
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "platform/wtf/CurrentTime.h" 9 #include "platform/wtf/CurrentTime.h"
10 10
(...skipping 22 matching lines...) Expand all
33 static TimeWrapper Now() { 33 static TimeWrapper Now() {
34 if (WTF::GetTimeFunctionForTesting()) { 34 if (WTF::GetTimeFunctionForTesting()) {
35 double seconds = (WTF::GetTimeFunctionForTesting())(); 35 double seconds = (WTF::GetTimeFunctionForTesting())();
36 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); 36 return TimeWrapper() + TimeDelta::FromSecondsD(seconds);
37 } 37 }
38 return TimeWrapper(WrappedTimeType::Now()); 38 return TimeWrapper(WrappedTimeType::Now());
39 } 39 }
40 40
41 int64_t ToInternalValueForTesting() const { return value_.ToInternalValue(); } 41 int64_t ToInternalValueForTesting() const { return value_.ToInternalValue(); }
42 42
43 time_t ToDoubleT() const { return value_.ToDoubleT(); }
Yuta Kitamura 2017/06/09 06:26:03 WTF::Time is now an alias of base::Time (see line
kristipark 2017/06/09 17:37:13 You are correct, thanks for pointing that out. Rem
44
43 // Only use this conversion when interfacing with legacy code that represents 45 // Only use this conversion when interfacing with legacy code that represents
44 // time in double. Converting to double can lead to losing information for 46 // time in double. Converting to double can lead to losing information for
45 // large time values. 47 // large time values.
46 double InSeconds() const { return (value_ - WrappedTimeType()).InSecondsF(); } 48 double InSeconds() const { return (value_ - WrappedTimeType()).InSecondsF(); }
47 49
48 static TimeWrapper FromSeconds(double seconds) { 50 static TimeWrapper FromSeconds(double seconds) {
49 return WrappedTimeType() + TimeDelta::FromSecondsD(seconds); 51 return WrappedTimeType() + TimeDelta::FromSecondsD(seconds);
50 } 52 }
51 53
54 static TimeWrapper FromInternalValue(int64_t us) {
55 return Time::FromInternalValue(us);
56 }
57
52 TimeWrapper& operator=(TimeWrapper other) { 58 TimeWrapper& operator=(TimeWrapper other) {
53 value_ = other.value_; 59 value_ = other.value_;
54 return *this; 60 return *this;
55 } 61 }
56 62
57 TimeDelta operator-(TimeWrapper other) const { return value_ - other.value_; } 63 TimeDelta operator-(TimeWrapper other) const { return value_ - other.value_; }
58 64
59 TimeWrapper operator+(TimeDelta delta) const { 65 TimeWrapper operator+(TimeDelta delta) const {
60 return TimeWrapper(value_ + delta); 66 return TimeWrapper(value_ + delta);
61 } 67 }
(...skipping 26 matching lines...) Expand all
88 94
89 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; 95 using TimeTicks = internal::TimeWrapper<base::TimeTicks>;
90 96
91 } // namespace WTF 97 } // namespace WTF
92 98
93 using WTF::Time; 99 using WTF::Time;
94 using WTF::TimeDelta; 100 using WTF::TimeDelta;
95 using WTF::TimeTicks; 101 using WTF::TimeTicks;
96 102
97 #endif // Time_h 103 #endif // Time_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698