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

Side by Side Diff: base/time/time.h

Issue 2241603002: Add explicit TimeDelta constexpr copy constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | base/time/time_unittest.cc » ('j') | base/time/time_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Time represents an absolute point in coordinated universal time (UTC), 5 // Time represents an absolute point in coordinated universal time (UTC),
6 // internally represented as microseconds (s/1,000,000) since the Windows epoch 6 // internally represented as microseconds (s/1,000,000) since the Windows epoch
7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are 7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are
8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump 8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump
9 // around as the operating system makes adjustments to synchronize (e.g., with 9 // around as the operating system makes adjustments to synchronize (e.g., with
10 // NTP servers). Thus, client code that uses the Time class must account for 10 // NTP servers). Thus, client code that uses the Time class must account for
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 constexpr bool operator<=(TimeDelta other) const { 235 constexpr bool operator<=(TimeDelta other) const {
236 return delta_ <= other.delta_; 236 return delta_ <= other.delta_;
237 } 237 }
238 constexpr bool operator>(TimeDelta other) const { 238 constexpr bool operator>(TimeDelta other) const {
239 return delta_ > other.delta_; 239 return delta_ > other.delta_;
240 } 240 }
241 constexpr bool operator>=(TimeDelta other) const { 241 constexpr bool operator>=(TimeDelta other) const {
242 return delta_ >= other.delta_; 242 return delta_ >= other.delta_;
243 } 243 }
244 244
245 // This works around crbug.com/635974
246 constexpr TimeDelta(const TimeDelta& other) : delta_(other.delta_) {}
miu 2016/08/11 21:48:56 Since the bug is Windows-specific, please surround
liberato (no reviews please) 2016/08/11 22:10:35 Done.
247
245 private: 248 private:
246 friend int64_t time_internal::SaturatedAdd(TimeDelta delta, int64_t value); 249 friend int64_t time_internal::SaturatedAdd(TimeDelta delta, int64_t value);
247 friend int64_t time_internal::SaturatedSub(TimeDelta delta, int64_t value); 250 friend int64_t time_internal::SaturatedSub(TimeDelta delta, int64_t value);
248 251
249 // Constructs a delta given the duration in microseconds. This is private 252 // Constructs a delta given the duration in microseconds. This is private
250 // to avoid confusion by callers with an integer constructor. Use 253 // to avoid confusion by callers with an integer constructor. Use
251 // FromSeconds, FromMilliseconds, etc. instead. 254 // FromSeconds, FromMilliseconds, etc. instead.
252 constexpr explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {} 255 constexpr explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {}
253 256
254 // Private method to build a delta from a double. 257 // Private method to build a delta from a double.
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 static void WaitUntilInitializedWin(); 833 static void WaitUntilInitializedWin();
831 #endif 834 #endif
832 }; 835 };
833 836
834 // For logging use only. 837 // For logging use only.
835 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); 838 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks);
836 839
837 } // namespace base 840 } // namespace base
838 841
839 #endif // BASE_TIME_TIME_H_ 842 #endif // BASE_TIME_TIME_H_
OLDNEW
« no previous file with comments | « no previous file | base/time/time_unittest.cc » ('j') | base/time/time_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698