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

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, 8 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 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 30 matching lines...) Expand all
41 local_base_time_ = local_lower_bound.value_; 41 local_base_time_ = local_lower_bound.value_;
42 // When converting times, remote bounds should equal local bounds. 42 // When converting times, remote bounds should equal local bounds.
43 DCHECK_EQ(local_lower_bound.value_, 43 DCHECK_EQ(local_lower_bound.value_,
44 ToLocalTimeTicks(remote_lower_bound).value_); 44 ToLocalTimeTicks(remote_lower_bound).value_);
45 DCHECK_EQ(local_upper_bound.value_, 45 DCHECK_EQ(local_upper_bound.value_,
46 ToLocalTimeTicks(remote_upper_bound).value_); 46 ToLocalTimeTicks(remote_upper_bound).value_);
47 DCHECK_EQ(target_range, Convert(source_range)); 47 DCHECK_EQ(target_range, Convert(source_range));
48 } 48 }
49 49
50 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks( 50 LocalTimeTicks InterProcessTimeTicksConverter::ToLocalTimeTicks(
51 const RemoteTimeTicks& remote_ms) { 51 const RemoteTimeTicks& remote_ms) const {
52 // If input time is "null", return another "null" time. 52 // If input time is "null", return another "null" time.
53 if (remote_ms.value_ == 0) 53 if (remote_ms.value_ == 0)
54 return LocalTimeTicks(0); 54 return LocalTimeTicks(0);
55 DCHECK_LE(remote_lower_bound_, remote_ms.value_); 55 DCHECK_LE(remote_lower_bound_, remote_ms.value_);
56 DCHECK_GE(remote_upper_bound_, remote_ms.value_); 56 DCHECK_GE(remote_upper_bound_, remote_ms.value_);
57 RemoteTimeDelta remote_delta = remote_ms - remote_lower_bound_; 57 RemoteTimeDelta remote_delta = remote_ms - remote_lower_bound_;
58 return LocalTimeTicks(local_base_time_ + 58 return LocalTimeTicks(local_base_time_ +
59 ToLocalTimeDelta(remote_delta).value_); 59 ToLocalTimeDelta(remote_delta).value_);
60 } 60 }
61 61
62 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta( 62 LocalTimeDelta InterProcessTimeTicksConverter::ToLocalTimeDelta(
63 const RemoteTimeDelta& remote_delta) { 63 const RemoteTimeDelta& remote_delta) const {
64 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_); 64 DCHECK_GE(remote_upper_bound_, remote_lower_bound_ + remote_delta.value_);
65 return LocalTimeDelta(Convert(remote_delta.value_)); 65 return LocalTimeDelta(Convert(remote_delta.value_));
66 } 66 }
67 67
68 int64 InterProcessTimeTicksConverter::Convert(int64 value) { 68 int64 InterProcessTimeTicksConverter::Convert(int64 value) const {
69 if (value <= 0) { 69 if (value <= 0) {
70 return value; 70 return value;
71 } 71 }
72 return numerator_ * value / denominator_; 72 return numerator_ * value / denominator_;
73 } 73 }
74 74
75 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « content/common/inter_process_time_ticks_converter.h ('k') | content/common/resource_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698