| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 RequestTimeLog& log = request_time_logs_[request_id]; | 144 RequestTimeLog& log = request_time_logs_[request_id]; |
| 145 if (log.completed) | 145 if (log.completed) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 log.request_duration = end_time - log.request_start_time; | 148 log.request_duration = end_time - log.request_start_time; |
| 149 log.completed = true; | 149 log.completed = true; |
| 150 | 150 |
| 151 if (log.extension_block_durations.empty()) | 151 if (log.extension_block_durations.empty()) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 HISTOGRAM_TIMES("Extensions.NetworkDelay", log.block_duration); | 154 UMA_HISTOGRAM_TIMES("Extensions.NetworkDelay", log.block_duration); |
| 155 | 155 |
| 156 Analyze(request_id); | 156 Analyze(request_id); |
| 157 } | 157 } |
| 158 | 158 |
| 159 std::set<std::string> ExtensionWebRequestTimeTracker::GetExtensionIds( | 159 std::set<std::string> ExtensionWebRequestTimeTracker::GetExtensionIds( |
| 160 const RequestTimeLog& log) const { | 160 const RequestTimeLog& log) const { |
| 161 std::set<std::string> result; | 161 std::set<std::string> result; |
| 162 for (std::map<std::string, base::TimeDelta>::const_iterator i = | 162 for (std::map<std::string, base::TimeDelta>::const_iterator i = |
| 163 log.extension_block_durations.begin(); | 163 log.extension_block_durations.begin(); |
| 164 i != log.extension_block_durations.end(); | 164 i != log.extension_block_durations.end(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // When a request is redirected, we have no way of knowing how long the | 245 // When a request is redirected, we have no way of knowing how long the |
| 246 // request would have taken, so we can't say how much an extension slowed | 246 // request would have taken, so we can't say how much an extension slowed |
| 247 // down this request. Just ignore it. | 247 // down this request. Just ignore it. |
| 248 request_time_logs_.erase(request_id); | 248 request_time_logs_.erase(request_id); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void ExtensionWebRequestTimeTracker::SetDelegate( | 251 void ExtensionWebRequestTimeTracker::SetDelegate( |
| 252 ExtensionWebRequestTimeTrackerDelegate* delegate) { | 252 ExtensionWebRequestTimeTrackerDelegate* delegate) { |
| 253 delegate_.reset(delegate); | 253 delegate_.reset(delegate); |
| 254 } | 254 } |
| OLD | NEW |