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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates Created 4 years, 7 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 (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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Warning: Be careful when writing code that performs math on time values, 300 // Warning: Be careful when writing code that performs math on time values,
301 // since it's possible to produce a valid "zero" result that should not be 301 // since it's possible to produce a valid "zero" result that should not be
302 // interpreted as a "null" value. 302 // interpreted as a "null" value.
303 bool is_null() const { 303 bool is_null() const {
304 return us_ == 0; 304 return us_ == 0;
305 } 305 }
306 306
307 // Returns true if this object represents the maximum time. 307 // Returns true if this object represents the maximum time.
308 bool is_max() const { return us_ == std::numeric_limits<int64_t>::max(); } 308 bool is_max() const { return us_ == std::numeric_limits<int64_t>::max(); }
309 309
310 // Returns the maximum time, which should be greater than any reasonable time
311 // with which we might compare it.
312 static TimeClass Max() {
313 return TimeClass(std::numeric_limits<int64_t>::max());
314 }
majidvp 2016/05/16 12:49:50 Pulled up from Time so that it is applicate to all
315
310 // For serializing only. Use FromInternalValue() to reconstitute. Please don't 316 // For serializing only. Use FromInternalValue() to reconstitute. Please don't
311 // use this and do arithmetic on it, as it is more error prone than using the 317 // use this and do arithmetic on it, as it is more error prone than using the
312 // provided operators. 318 // provided operators.
313 int64_t ToInternalValue() const { return us_; } 319 int64_t ToInternalValue() const { return us_; }
314 320
315 TimeClass& operator=(TimeClass other) { 321 TimeClass& operator=(TimeClass other) {
316 us_ = other.us_; 322 us_ = other.us_;
317 return *(static_cast<TimeClass*>(this)); 323 return *(static_cast<TimeClass*>(this));
318 } 324 }
319 325
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 433 }
428 434
429 // Returns the time for epoch in Unix-like system (Jan 1, 1970). 435 // Returns the time for epoch in Unix-like system (Jan 1, 1970).
430 static Time UnixEpoch(); 436 static Time UnixEpoch();
431 437
432 // Returns the current time. Watch out, the system might adjust its clock 438 // Returns the current time. Watch out, the system might adjust its clock
433 // in which case time will actually go backwards. We don't guarantee that 439 // in which case time will actually go backwards. We don't guarantee that
434 // times are increasing, or that two calls to Now() won't be the same. 440 // times are increasing, or that two calls to Now() won't be the same.
435 static Time Now(); 441 static Time Now();
436 442
437 // Returns the maximum time, which should be greater than any reasonable time
438 // with which we might compare it.
439 static Time Max();
440
441 // Returns the current time. Same as Now() except that this function always 443 // Returns the current time. Same as Now() except that this function always
442 // uses system time so that there are no discrepancies between the returned 444 // uses system time so that there are no discrepancies between the returned
443 // time and system time even on virtual environments including our test bot. 445 // time and system time even on virtual environments including our test bot.
444 // For timing sensitive unittests, this function should be used. 446 // For timing sensitive unittests, this function should be used.
445 static Time NowFromSystemTime(); 447 static Time NowFromSystemTime();
446 448
447 // Converts to/from time_t in UTC and a Time class. 449 // Converts to/from time_t in UTC and a Time class.
448 // TODO(brettw) this should be removed once everybody starts using the |Time| 450 // TODO(brettw) this should be removed once everybody starts using the |Time|
449 // class. 451 // class.
450 static Time FromTimeT(time_t tt); 452 static Time FromTimeT(time_t tt);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 static void WaitUntilInitializedWin(); 778 static void WaitUntilInitializedWin();
777 #endif 779 #endif
778 }; 780 };
779 781
780 // For logging use only. 782 // For logging use only.
781 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); 783 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks);
782 784
783 } // namespace base 785 } // namespace base
784 786
785 #endif // BASE_TIME_TIME_H_ 787 #endif // BASE_TIME_TIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698