| 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" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_warning_set.h" | 12 #include "chrome/browser/extensions/extension_warning_set.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 | 14 |
| 15 using content::BrowserThread; |
| 16 |
| 15 // TODO(mpcomplete): tweak all these constants. | 17 // TODO(mpcomplete): tweak all these constants. |
| 16 namespace { | 18 namespace { |
| 17 // The number of requests we keep track of at a time. | 19 // The number of requests we keep track of at a time. |
| 18 const size_t kMaxRequestsLogged = 100u; | 20 const size_t kMaxRequestsLogged = 100u; |
| 19 | 21 |
| 20 // If a request completes faster than this amount (in ms), then we ignore it. | 22 // If a request completes faster than this amount (in ms), then we ignore it. |
| 21 // Any delays on such a request was negligible. | 23 // Any delays on such a request was negligible. |
| 22 const int kMinRequestTimeToCareMs = 10; | 24 const int kMinRequestTimeToCareMs = 10; |
| 23 | 25 |
| 24 // Thresholds above which we consider a delay caused by an extension to be "too | 26 // Thresholds above which we consider a delay caused by an extension to be "too |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // When a request is redirected, we have no way of knowing how long the | 242 // When a request is redirected, we have no way of knowing how long the |
| 241 // request would have taken, so we can't say how much an extension slowed | 243 // request would have taken, so we can't say how much an extension slowed |
| 242 // down this request. Just ignore it. | 244 // down this request. Just ignore it. |
| 243 request_time_logs_.erase(request_id); | 245 request_time_logs_.erase(request_id); |
| 244 } | 246 } |
| 245 | 247 |
| 246 void ExtensionWebRequestTimeTracker::SetDelegate( | 248 void ExtensionWebRequestTimeTracker::SetDelegate( |
| 247 ExtensionWebRequestTimeTrackerDelegate* delegate) { | 249 ExtensionWebRequestTimeTrackerDelegate* delegate) { |
| 248 delegate_.reset(delegate); | 250 delegate_.reset(delegate); |
| 249 } | 251 } |
| OLD | NEW |