| 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 #include "content/common/inter_process_time_ticks_converter.h" | 5 #include "content/common/inter_process_time_ticks_converter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 denominator_ = source_range; | 30 denominator_ = source_range; |
| 31 // Find out what we need to shift by to make this really work. | 31 // Find out what we need to shift by to make this really work. |
| 32 offset_ = local_lower_bound.value_ - Convert(remote_lower_bound.value_); | 32 offset_ = local_lower_bound.value_ - Convert(remote_lower_bound.value_); |
| 33 DCHECK_GE(local_upper_bound.value_, Convert(remote_upper_bound.value_)); | 33 DCHECK_GE(local_upper_bound.value_, Convert(remote_upper_bound.value_)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks( | 36 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks( |
| 37 const RemoteTimeTicks& remote_ms) { | 37 const RemoteTimeTicks& remote_ms) { |
| 38 DCHECK_LE(remote_lower_bound_, remote_ms.value_); | 38 DCHECK_LE(remote_lower_bound_, remote_ms.value_); |
| 39 DCHECK_GE(remote_upper_bound_, remote_ms.value_); | 39 DCHECK_GE(remote_upper_bound_, remote_ms.value_); |
| 40 RemoteTimeDelta remote_delta = remote_ms - remote_lower_bound_; | 40 RemoteTimeDelta remote_delta = remote_ms - |
| 41 RemoteTimeTicks(remote_lower_bound_); |
| 41 return LocalTimeTicks(remote_lower_bound_ + offset_ + | 42 return LocalTimeTicks(remote_lower_bound_ + offset_ + |
| 42 ToLocalTimeDelta(remote_delta).value_); | 43 ToLocalTimeDelta(remote_delta).value_); |
| 43 } | 44 } |
| 44 | 45 |
| 45 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta( | 46 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta( |
| 46 const RemoteTimeDelta& remote_delta) { | 47 const RemoteTimeDelta& remote_delta) { |
| 47 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_); | 48 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_); |
| 48 return LocalTimeDelta(Convert(remote_delta.value_)); | 49 return LocalTimeDelta(Convert(remote_delta.value_)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 int64 InterProcessTimeTicksConverter::Convert(int64 value) { | 52 int64 InterProcessTimeTicksConverter::Convert(int64 value) { |
| 52 if (value <= 0) { | 53 if (value <= 0) { |
| 53 return value; | 54 return value; |
| 54 } | 55 } |
| 55 return numerator_ * value / denominator_; | 56 return numerator_ * value / denominator_; |
| 56 } | 57 } |
| 57 | 58 |
| 58 } // namespace content | 59 } // namespace content |
| OLD | NEW |