OLD | NEW |
---|---|
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 time, internally represented as | 5 // Time represents an absolute point in time, internally represented as |
6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each | 6 // microseconds (s/1,000,000) since a platform-dependent epoch. Each |
7 // platform's epoch, along with other system-dependent clock interface | 7 // platform's epoch, along with other system-dependent clock interface |
8 // routines, is defined in time_PLATFORM.cc. | 8 // routines, is 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 TimeDelta() : delta_(0) { | 57 TimeDelta() : delta_(0) { |
58 } | 58 } |
59 | 59 |
60 // Converts units of time to TimeDeltas. | 60 // Converts units of time to TimeDeltas. |
61 static TimeDelta FromDays(int64 days); | 61 static TimeDelta FromDays(int64 days); |
62 static TimeDelta FromHours(int64 hours); | 62 static TimeDelta FromHours(int64 hours); |
63 static TimeDelta FromMinutes(int64 minutes); | 63 static TimeDelta FromMinutes(int64 minutes); |
64 static TimeDelta FromSeconds(int64 secs); | 64 static TimeDelta FromSeconds(int64 secs); |
65 static TimeDelta FromMilliseconds(int64 ms); | 65 static TimeDelta FromMilliseconds(int64 ms); |
66 static TimeDelta FromMicroseconds(int64 us); | 66 static TimeDelta FromMicroseconds(int64 us); |
67 #if defined(OS_WIN) | |
68 static TimeDelta FromQPCValue(LONGLONG qpcValue); | |
brianderson
2012/07/30 19:38:13
jar, is it ok that we add functions to convert nat
apatrick_chromium
2012/07/30 19:43:31
Google style is qpc_value.
| |
69 #endif | |
67 | 70 |
68 // Converts an integer value representing TimeDelta to a class. This is used | 71 // Converts an integer value representing TimeDelta to a class. This is used |
69 // when deserializing a |TimeDelta| structure, using a value known to be | 72 // when deserializing a |TimeDelta| structure, using a value known to be |
70 // compatible. It is not provided as a constructor because the integer type | 73 // compatible. It is not provided as a constructor because the integer type |
71 // may be unclear from the perspective of a caller. | 74 // may be unclear from the perspective of a caller. |
72 static TimeDelta FromInternalValue(int64 delta) { | 75 static TimeDelta FromInternalValue(int64 delta) { |
73 return TimeDelta(delta); | 76 return TimeDelta(delta); |
74 } | 77 } |
75 | 78 |
76 // Returns the internal numeric value of the TimeDelta object. Please don't | 79 // Returns the internal numeric value of the TimeDelta object. Please don't |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 // high-res time (i.e. HighResNow()). On systems where a global trace clock | 506 // high-res time (i.e. HighResNow()). On systems where a global trace clock |
504 // is defined, timestamping TraceEvents's with this value guarantees | 507 // is defined, timestamping TraceEvents's with this value guarantees |
505 // synchronization between events collected inside chrome and events | 508 // synchronization between events collected inside chrome and events |
506 // collected outside (e.g. kernel, X server). | 509 // collected outside (e.g. kernel, X server). |
507 static TimeTicks NowFromSystemTraceTime(); | 510 static TimeTicks NowFromSystemTraceTime(); |
508 | 511 |
509 #if defined(OS_WIN) | 512 #if defined(OS_WIN) |
510 // Get the absolute value of QPC time drift. For testing. | 513 // Get the absolute value of QPC time drift. For testing. |
511 static int64 GetQPCDriftMicroseconds(); | 514 static int64 GetQPCDriftMicroseconds(); |
512 | 515 |
516 static TimeTicks FromQPCValue(LONGLONG qpcValue); | |
apatrick_chromium
2012/07/30 19:43:31
Same here.
| |
517 | |
513 // Returns true if the high resolution clock is working on this system. | 518 // Returns true if the high resolution clock is working on this system. |
514 // This is only for testing. | 519 // This is only for testing. |
515 static bool IsHighResClockWorking(); | 520 static bool IsHighResClockWorking(); |
516 #endif | 521 #endif |
517 | 522 |
518 // Returns true if this object has not been initialized. | 523 // Returns true if this object has not been initialized. |
519 bool is_null() const { | 524 bool is_null() const { |
520 return ticks_ == 0; | 525 return ticks_ == 0; |
521 } | 526 } |
522 | 527 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 #endif | 604 #endif |
600 }; | 605 }; |
601 | 606 |
602 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 607 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
603 return TimeTicks(t.ticks_ + delta_); | 608 return TimeTicks(t.ticks_ + delta_); |
604 } | 609 } |
605 | 610 |
606 } // namespace base | 611 } // namespace base |
607 | 612 |
608 #endif // BASE_TIME_H_ | 613 #endif // BASE_TIME_H_ |
OLD | NEW |