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

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: cl feedback -- windows only 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_win_unittest.cc » ('j') | base/time/time_win_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 #if defined(OS_WIN)
246 // This works around crbug.com/635974
247 constexpr TimeDelta(const TimeDelta& other) : delta_(other.delta_) {}
248 #endif
249
245 private: 250 private:
246 friend int64_t time_internal::SaturatedAdd(TimeDelta delta, int64_t value); 251 friend int64_t time_internal::SaturatedAdd(TimeDelta delta, int64_t value);
247 friend int64_t time_internal::SaturatedSub(TimeDelta delta, int64_t value); 252 friend int64_t time_internal::SaturatedSub(TimeDelta delta, int64_t value);
248 253
249 // Constructs a delta given the duration in microseconds. This is private 254 // Constructs a delta given the duration in microseconds. This is private
250 // to avoid confusion by callers with an integer constructor. Use 255 // to avoid confusion by callers with an integer constructor. Use
251 // FromSeconds, FromMilliseconds, etc. instead. 256 // FromSeconds, FromMilliseconds, etc. instead.
252 constexpr explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {} 257 constexpr explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {}
253 258
254 // Private method to build a delta from a double. 259 // 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(); 835 static void WaitUntilInitializedWin();
831 #endif 836 #endif
832 }; 837 };
833 838
834 // For logging use only. 839 // For logging use only.
835 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); 840 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks);
836 841
837 } // namespace base 842 } // namespace base
838 843
839 #endif // BASE_TIME_TIME_H_ 844 #endif // BASE_TIME_TIME_H_
OLDNEW
« no previous file with comments | « no previous file | base/time/time_win_unittest.cc » ('j') | base/time/time_win_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698