Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 // Returns true if this object has not been initialized. | 485 // Returns true if this object has not been initialized. |
| 486 bool is_null() const { | 486 bool is_null() const { |
| 487 return ticks_ == 0; | 487 return ticks_ == 0; |
| 488 } | 488 } |
| 489 | 489 |
| 490 // Returns the internal numeric value of the TimeTicks object. | 490 // Returns the internal numeric value of the TimeTicks object. |
| 491 int64 ToInternalValue() const { | 491 int64 ToInternalValue() const { |
| 492 return ticks_; | 492 return ticks_; |
| 493 } | 493 } |
| 494 | 494 |
| 495 // Converts an integer value representing TimeTicks to a class. This is used | |
| 496 // when deserializing a |TimeTicks| structure, using a value that originated | |
| 497 // from |TimeTicks::ToInternalValue()|. | |
| 498 static TimeTicks FromInternalValue(int64 ticks) { | |
| 499 return TimeTicks(ticks); | |
| 500 } | |
|
wtc
2011/08/26 21:55:41
It is safe to deserialize this way only if all the
James Simonsen
2011/08/26 22:34:29
Pavel and I discussed this earlier. All of the pla
wtc
2011/08/26 23:39:15
If you are relying on this fact, and are deseriali
| |
| 501 | |
| 495 TimeTicks& operator=(TimeTicks other) { | 502 TimeTicks& operator=(TimeTicks other) { |
| 496 ticks_ = other.ticks_; | 503 ticks_ = other.ticks_; |
| 497 return *this; | 504 return *this; |
| 498 } | 505 } |
| 499 | 506 |
| 500 // Compute the difference between two times. | 507 // Compute the difference between two times. |
| 501 TimeDelta operator-(TimeTicks other) const { | 508 TimeDelta operator-(TimeTicks other) const { |
| 502 return TimeDelta(ticks_ - other.ticks_); | 509 return TimeDelta(ticks_ - other.ticks_); |
| 503 } | 510 } |
| 504 | 511 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 #endif | 564 #endif |
| 558 }; | 565 }; |
| 559 | 566 |
| 560 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { | 567 inline TimeTicks TimeDelta::operator+(TimeTicks t) const { |
| 561 return TimeTicks(t.ticks_ + delta_); | 568 return TimeTicks(t.ticks_ + delta_); |
| 562 } | 569 } |
| 563 | 570 |
| 564 } // namespace base | 571 } // namespace base |
| 565 | 572 |
| 566 #endif // BASE_TIME_H_ | 573 #endif // BASE_TIME_H_ |
| OLD | NEW |