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

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

Issue 949613002: [Android] Add animation frame time histogram class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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) (See http://crbug.com/14734). System-dependent 7 // (1601-01-01 00:00:00 UTC) (See http://crbug.com/14734). System-dependent
8 // clock interface routines are defined in time_PLATFORM.cc. 8 // clock interface routines are defined in time_PLATFORM.cc.
9 // 9 //
10 // TimeDelta represents a duration of time, internally represented in 10 // TimeDelta represents a duration of time, internally represented in
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // Converts units of time to TimeDeltas. 69 // Converts units of time to TimeDeltas.
70 static TimeDelta FromDays(int days); 70 static TimeDelta FromDays(int days);
71 static TimeDelta FromHours(int hours); 71 static TimeDelta FromHours(int hours);
72 static TimeDelta FromMinutes(int minutes); 72 static TimeDelta FromMinutes(int minutes);
73 static TimeDelta FromSeconds(int64 secs); 73 static TimeDelta FromSeconds(int64 secs);
74 static TimeDelta FromMilliseconds(int64 ms); 74 static TimeDelta FromMilliseconds(int64 ms);
75 static TimeDelta FromSecondsD(double secs); 75 static TimeDelta FromSecondsD(double secs);
76 static TimeDelta FromMillisecondsD(double ms); 76 static TimeDelta FromMillisecondsD(double ms);
77 static TimeDelta FromMicroseconds(int64 us); 77 static TimeDelta FromMicroseconds(int64 us);
78 static TimeDelta FromNanoseconds(int64 ns);
78 #if defined(OS_WIN) 79 #if defined(OS_WIN)
79 static TimeDelta FromQPCValue(LONGLONG qpc_value); 80 static TimeDelta FromQPCValue(LONGLONG qpc_value);
80 #endif 81 #endif
81 82
82 // Converts an integer value representing TimeDelta to a class. This is used 83 // Converts an integer value representing TimeDelta to a class. This is used
83 // when deserializing a |TimeDelta| structure, using a value known to be 84 // when deserializing a |TimeDelta| structure, using a value known to be
84 // compatible. It is not provided as a constructor because the integer type 85 // compatible. It is not provided as a constructor because the integer type
85 // may be unclear from the perspective of a caller. 86 // may be unclear from the perspective of a caller.
86 static TimeDelta FromInternalValue(int64 delta) { 87 static TimeDelta FromInternalValue(int64 delta) {
87 return TimeDelta(delta); 88 return TimeDelta(delta);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 569 }
569 570
570 // static 571 // static
571 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) { 572 inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
572 // Preserve max to prevent overflow. 573 // Preserve max to prevent overflow.
573 if (us == std::numeric_limits<int64>::max()) 574 if (us == std::numeric_limits<int64>::max())
574 return Max(); 575 return Max();
575 return TimeDelta(us); 576 return TimeDelta(us);
576 } 577 }
577 578
579 // static
580 inline TimeDelta TimeDelta::FromNanoseconds(int64 ns) {
581 // Preserve max to prevent overflow.
582 if (ns == std::numeric_limits<int64>::max())
583 return Max();
584 return TimeDelta(ns / Time::kNanosecondsPerMicrosecond);
585 }
586
578 inline Time TimeDelta::operator+(Time t) const { 587 inline Time TimeDelta::operator+(Time t) const {
579 return Time(t.us_ + delta_); 588 return Time(t.us_ + delta_);
580 } 589 }
581 590
582 // For logging use only. 591 // For logging use only.
583 BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time); 592 BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time);
584 593
585 // TimeTicks ------------------------------------------------------------------ 594 // TimeTicks ------------------------------------------------------------------
586 595
587 class BASE_EXPORT TimeTicks { 596 class BASE_EXPORT TimeTicks {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { 763 inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
755 return TimeTicks(t.ticks_ + delta_); 764 return TimeTicks(t.ticks_ + delta_);
756 } 765 }
757 766
758 // For logging use only. 767 // For logging use only.
759 BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks); 768 BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks);
760 769
761 } // namespace base 770 } // namespace base
762 771
763 #endif // BASE_TIME_TIME_H_ 772 #endif // BASE_TIME_TIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698