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 "chrome/browser/extensions/extension_webrequest_time_tracker.h" | 5 #include "chrome/browser/extensions/extension_webrequest_time_tracker.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 | 8 |
9 // TODO(mpcomplete): tweak all these constants. | 9 // TODO(mpcomplete): tweak all these constants. |
10 namespace { | 10 namespace { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 RequestTimeLog& log = request_time_logs_[request_id]; | 74 RequestTimeLog& log = request_time_logs_[request_id]; |
75 if (log.completed) | 75 if (log.completed) |
76 return; | 76 return; |
77 | 77 |
78 log.request_duration = end_time - log.request_start_time; | 78 log.request_duration = end_time - log.request_start_time; |
79 log.completed = true; | 79 log.completed = true; |
80 | 80 |
81 if (log.extension_block_durations.empty()) | 81 if (log.extension_block_durations.empty()) |
82 return; | 82 return; |
83 | 83 |
84 HISTOGRAM_TIMES("Extensions.NetworkDelay", log.block_duration); | 84 UMA_HISTOGRAM_TIMES("Extensions.NetworkDelay", log.block_duration); |
85 | 85 |
86 Analyze(request_id); | 86 Analyze(request_id); |
87 } | 87 } |
88 | 88 |
89 void ExtensionWebRequestTimeTracker::Analyze(int64 request_id) { | 89 void ExtensionWebRequestTimeTracker::Analyze(int64 request_id) { |
90 RequestTimeLog& log = request_time_logs_[request_id]; | 90 RequestTimeLog& log = request_time_logs_[request_id]; |
91 | 91 |
92 // Ignore really short requests. Time spent on these is negligible, and any | 92 // Ignore really short requests. Time spent on these is negligible, and any |
93 // extra delay the extension adds is likely to be noise. | 93 // extra delay the extension adds is likely to be noise. |
94 if (log.request_duration.InMilliseconds() < kMinRequestTimeToCareMs) | 94 if (log.request_duration.InMilliseconds() < kMinRequestTimeToCareMs) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // might average out to only being "25% slow". | 145 // might average out to only being "25% slow". |
146 request_time_logs_.erase(request_id); | 146 request_time_logs_.erase(request_id); |
147 } | 147 } |
148 | 148 |
149 void ExtensionWebRequestTimeTracker::SetRequestRedirected(int64 request_id) { | 149 void ExtensionWebRequestTimeTracker::SetRequestRedirected(int64 request_id) { |
150 // When a request is redirected, we have no way of knowing how long the | 150 // When a request is redirected, we have no way of knowing how long the |
151 // request would have taken, so we can't say how much an extension slowed | 151 // request would have taken, so we can't say how much an extension slowed |
152 // down this request. Just ignore it. | 152 // down this request. Just ignore it. |
153 request_time_logs_.erase(request_id); | 153 request_time_logs_.erase(request_id); |
154 } | 154 } |
OLD | NEW |