 Chromium Code Reviews
 Chromium Code Reviews Issue 1011363005:
  [Extensions] Add metrics for UserScriptListener  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1011363005:
  [Extensions] Add metrics for UserScriptListener  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/browser/extensions/user_script_listener.cc | 
| diff --git a/chrome/browser/extensions/user_script_listener.cc b/chrome/browser/extensions/user_script_listener.cc | 
| index 232b365e0067ea526dc364614f3f2da6bab14da0..dd7060a1b626265f72aca1a7342b75645e8924e0 100644 | 
| --- a/chrome/browser/extensions/user_script_listener.cc | 
| +++ b/chrome/browser/extensions/user_script_listener.cc | 
| @@ -5,6 +5,8 @@ | 
| #include "chrome/browser/extensions/user_script_listener.h" | 
| #include "base/bind.h" | 
| +#include "base/metrics/histogram.h" | 
| 
Mark P
2015/03/19 18:59:15
histogram_macros is more appropriate
 
Devlin
2015/03/19 19:45:54
Done.
 | 
| +#include "base/timer/elapsed_timer.h" | 
| #include "chrome/browser/chrome_notification_types.h" | 
| #include "chrome/browser/profiles/profile.h" | 
| #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 
| @@ -34,8 +36,11 @@ class UserScriptListener::Throttle | 
| DCHECK(should_defer_); | 
| should_defer_ = false; | 
| // Only resume the request if |this| has deferred it. | 
| - if (did_defer_) | 
| + if (did_defer_) { | 
| + UMA_HISTOGRAM_TIMES("Extensions.ThrottledNetworkRequestDelay", | 
| + timer_->Elapsed()); | 
| 
not at google - send to devlin
2015/03/19 15:41:14
For completeness, timer_.reset()?
 
Devlin
2015/03/19 16:59:52
These are deleted right after resume is called, bu
 | 
| controller()->Resume(); | 
| + } | 
| } | 
| // ResourceThrottle implementation: | 
| @@ -44,6 +49,7 @@ class UserScriptListener::Throttle | 
| if (should_defer_) { | 
| *defer = true; | 
| did_defer_ = true; | 
| + timer_.reset(new base::ElapsedTimer()); | 
| } | 
| } | 
| @@ -54,6 +60,9 @@ class UserScriptListener::Throttle | 
| private: | 
| bool should_defer_; | 
| bool did_defer_; | 
| + scoped_ptr<base::ElapsedTimer> timer_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(Throttle); | 
| }; | 
| struct UserScriptListener::ProfileData { | 
| @@ -131,6 +140,8 @@ bool UserScriptListener::ShouldDelayRequest(const GURL& url, | 
| } | 
| void UserScriptListener::StartDelayedRequests() { | 
| + UMA_HISTOGRAM_COUNTS_100("Extensions.ThrottledNetworkRequests", | 
| + throttles_.size()); | 
| WeakThrottleList::const_iterator it; | 
| for (it = throttles_.begin(); it != throttles_.end(); ++it) { | 
| if (it->get()) |