| 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 #include "net/quic/quic_time.h" | 5 #include "net/quic/quic_time.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 QuicTime::Delta QuicTime::Subtract(const QuicTime& other) const { | 98 QuicTime::Delta QuicTime::Subtract(const QuicTime& other) const { |
| 99 return QuicTime::Delta(ticks_ - other.ticks_); | 99 return QuicTime::Delta(ticks_ - other.ticks_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // static | 102 // static |
| 103 QuicWallTime QuicWallTime::FromUNIXSeconds(uint64 seconds) { | 103 QuicWallTime QuicWallTime::FromUNIXSeconds(uint64 seconds) { |
| 104 return QuicWallTime(seconds); | 104 return QuicWallTime(seconds); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // static |
| 108 QuicWallTime QuicWallTime::Zero() { |
| 109 return QuicWallTime(0); |
| 110 } |
| 111 |
| 107 uint64 QuicWallTime::ToUNIXSeconds() const { | 112 uint64 QuicWallTime::ToUNIXSeconds() const { |
| 108 return seconds_; | 113 return seconds_; |
| 109 } | 114 } |
| 110 | 115 |
| 111 bool QuicWallTime::IsAfter(QuicWallTime other) const { | 116 bool QuicWallTime::IsAfter(QuicWallTime other) const { |
| 112 return seconds_ > other.seconds_; | 117 return seconds_ > other.seconds_; |
| 113 } | 118 } |
| 114 | 119 |
| 115 bool QuicWallTime::IsBefore(QuicWallTime other) const { | 120 bool QuicWallTime::IsBefore(QuicWallTime other) const { |
| 116 return seconds_ < other.seconds_; | 121 return seconds_ < other.seconds_; |
| 117 } | 122 } |
| 118 | 123 |
| 124 bool QuicWallTime::IsZero() const { |
| 125 return seconds_ == 0; |
| 126 } |
| 127 |
| 119 QuicTime::Delta QuicWallTime::AbsoluteDifference(QuicWallTime other) const { | 128 QuicTime::Delta QuicWallTime::AbsoluteDifference(QuicWallTime other) const { |
| 120 uint64 d; | 129 uint64 d; |
| 121 | 130 |
| 122 if (seconds_ > other.seconds_) { | 131 if (seconds_ > other.seconds_) { |
| 123 d = seconds_ - other.seconds_; | 132 d = seconds_ - other.seconds_; |
| 124 } else { | 133 } else { |
| 125 d = other.seconds_ - seconds_; | 134 d = other.seconds_ - seconds_; |
| 126 } | 135 } |
| 127 | 136 |
| 128 if (d > static_cast<uint64>(kint64max)) { | 137 if (d > static_cast<uint64>(kint64max)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 145 seconds = 0; | 154 seconds = 0; |
| 146 } | 155 } |
| 147 return QuicWallTime(seconds); | 156 return QuicWallTime(seconds); |
| 148 } | 157 } |
| 149 | 158 |
| 150 QuicWallTime::QuicWallTime(uint64 seconds) | 159 QuicWallTime::QuicWallTime(uint64 seconds) |
| 151 : seconds_(seconds) { | 160 : seconds_(seconds) { |
| 152 } | 161 } |
| 153 | 162 |
| 154 } // namespace net | 163 } // namespace net |
| OLD | NEW |