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

Side by Side Diff: content/common/inter_process_time_ticks_converter.cc

Issue 12094085: LoadTiming in net part 7: Hooking it all up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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 23 matching lines...) Expand all
34 } 34 }
35 // Set up scaling factors, and then deduce shift. 35 // Set up scaling factors, and then deduce shift.
36 numerator_ = target_range; 36 numerator_ = target_range;
37 denominator_ = source_range; 37 denominator_ = source_range;
38 // Find out what we need to shift by to make this really work. 38 // Find out what we need to shift by to make this really work.
39 offset_ = local_lower_bound.value_ - Convert(remote_lower_bound.value_); 39 offset_ = local_lower_bound.value_ - Convert(remote_lower_bound.value_);
40 DCHECK_GE(local_upper_bound.value_, Convert(remote_upper_bound.value_)); 40 DCHECK_GE(local_upper_bound.value_, Convert(remote_upper_bound.value_));
41 } 41 }
42 42
43 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks( 43 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks(
44 const RemoteTimeTicks& remote_ms) { 44 const RemoteTimeTicks& remote_ms) const {
45 if (!remote_ms.value_)
46 return LocalTimeTicks(0);
45 DCHECK_LE(remote_lower_bound_, remote_ms.value_); 47 DCHECK_LE(remote_lower_bound_, remote_ms.value_);
46 DCHECK_GE(remote_upper_bound_, remote_ms.value_); 48 DCHECK_GE(remote_upper_bound_, remote_ms.value_);
47 RemoteTimeDelta remote_delta = remote_ms - remote_lower_bound_; 49 RemoteTimeDelta remote_delta = remote_ms - remote_lower_bound_;
48 return LocalTimeTicks(remote_lower_bound_ + offset_ + 50 return LocalTimeTicks(remote_lower_bound_ + offset_ +
49 ToLocalTimeDelta(remote_delta).value_); 51 ToLocalTimeDelta(remote_delta).value_);
50 } 52 }
51 53
52 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta( 54 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta(
53 const RemoteTimeDelta& remote_delta) { 55 const RemoteTimeDelta& remote_delta) const {
54 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_); 56 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_);
55 return LocalTimeDelta(Convert(remote_delta.value_)); 57 return LocalTimeDelta(Convert(remote_delta.value_));
56 } 58 }
57 59
58 int64 InterProcessTimeTicksConverter::Convert(int64 value) { 60 int64 InterProcessTimeTicksConverter::Convert(int64 value) const {
59 if (value <= 0) { 61 if (value <= 0) {
60 return value; 62 return value;
61 } 63 }
62 return numerator_ * value / denominator_; 64 return numerator_ * value / denominator_;
63 } 65 }
64 66
65 } // namespace content 67 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698