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

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

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: Add TimeTicks::{To,In}Seconds utility functions Created 4 years 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 | « third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "wtf/CurrentTime.h" 9 #include "wtf/CurrentTime.h"
10 10
(...skipping 25 matching lines...) Expand all
36 double seconds = (WTF::getTimeFunctionForTesting())(); 36 double seconds = (WTF::getTimeFunctionForTesting())();
37 return TimeWrapper() + TimeDelta::FromSecondsD(seconds); 37 return TimeWrapper() + TimeDelta::FromSecondsD(seconds);
38 } 38 }
39 return TimeWrapper(WrappedTimeType::Now()); 39 return TimeWrapper(WrappedTimeType::Now());
40 } 40 }
41 41
42 int64_t ToInternalValueForTesting() const { 42 int64_t ToInternalValueForTesting() const {
43 return m_value.ToInternalValue(); 43 return m_value.ToInternalValue();
44 } 44 }
45 45
46 // Only use this conversion when interfacing with legacy code that represents
47 // time in double. Converting to double can lead to losing information for
48 // large time values.
49 double InSeconds() { return (m_value - WrappedTimeType()).InSecondsF(); }
esprehn 2016/12/12 22:12:21 const
50
51 static TimeWrapper FromSeconds(double seconds) {
52 return WrappedTimeType() + TimeDelta::FromSecondsD(seconds);
53 }
54
46 TimeWrapper& operator=(TimeWrapper other) { 55 TimeWrapper& operator=(TimeWrapper other) {
47 m_value = other.m_value; 56 m_value = other.m_value;
48 return *this; 57 return *this;
49 } 58 }
50 59
51 TimeDelta operator-(TimeWrapper other) const { 60 TimeDelta operator-(TimeWrapper other) const {
52 return m_value - other.m_value; 61 return m_value - other.m_value;
53 } 62 }
54 63
55 TimeWrapper operator+(TimeDelta delta) const { 64 TimeWrapper operator+(TimeDelta delta) const {
(...skipping 29 matching lines...) Expand all
85 using Time = internal::TimeWrapper<base::Time>; 94 using Time = internal::TimeWrapper<base::Time>;
86 using TimeTicks = internal::TimeWrapper<base::TimeTicks>; 95 using TimeTicks = internal::TimeWrapper<base::TimeTicks>;
87 96
88 } // namespace WTF 97 } // namespace WTF
89 98
90 using WTF::Time; 99 using WTF::Time;
91 using WTF::TimeDelta; 100 using WTF::TimeDelta;
92 using WTF::TimeTicks; 101 using WTF::TimeTicks;
93 102
94 #endif // Time_h 103 #endif // Time_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebInputEventConversionTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698