diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 00:09:37 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-06 00:09:37 +0000 |
commit | e8829a1981a2d9d849c377c28f9444fdefee0f44 (patch) | |
tree | 3cfe522cf76d308dec9fca773d3f9495e12abc5e /chrome/browser/jankometer.cc | |
parent | 4f3b65a30cad88c1f1e482f7bda69ef50f8e1364 (diff) | |
download | chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.zip chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.tar.gz chromium_src-e8829a1981a2d9d849c377c28f9444fdefee0f44.tar.bz2 |
Use factory to create histograms, and refcounts to track lifetimes
This is CL patch 377028 by Raman Tenneti, with minor changes to
make the try-bots happier.
It is cleanup that better ensures lifetimes of histograms (making it harder
for users to abuse them).
bug=16495 (repairs leak induced by the first landing)
bug=18840 (should make leaks less possible)
tbr=raman.tenneti
Review URL: http://codereview.chromium.org/462027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/jankometer.cc')
-rw-r--r-- | chrome/browser/jankometer.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/chrome/browser/jankometer.cc b/chrome/browser/jankometer.cc index 32b42ca..10d2f14 100644 --- a/chrome/browser/jankometer.cc +++ b/chrome/browser/jankometer.cc @@ -91,13 +91,15 @@ class JankObserver : public base::RefCountedThreadSafe<JankObserver>, : MaxMessageDelay_(excessive_duration), slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), - process_times_((std::string("Chrome.ProcMsgL ") + - thread_name).c_str(), 1, 3600000, 50), - total_times_((std::string("Chrome.TotalMsgL ") + - thread_name).c_str(), 1, 3600000, 50), total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { - process_times_.SetFlags(kUmaTargetedHistogramFlag); - total_times_.SetFlags(kUmaTargetedHistogramFlag); + process_times_ = Histogram::HistogramFactoryGet( + (std::string("Chrome.ProcMsgL ") + thread_name), + 1, 3600000, 50); + total_times_ = Histogram::HistogramFactoryGet( + (std::string("Chrome.TotalMsgL ") + thread_name), + 1, 3600000, 50); + process_times_->SetFlags(kUmaTargetedHistogramFlag); + total_times_->SetFlags(kUmaTargetedHistogramFlag); } // Attaches the observer to the current thread's message loop. You can only @@ -137,8 +139,8 @@ class JankObserver : public base::RefCountedThreadSafe<JankObserver>, TimeTicks now = TimeTicks::Now(); if (begin_process_message_ != TimeTicks()) { TimeDelta processing_time = now - begin_process_message_; - process_times_.AddTime(processing_time); - total_times_.AddTime(queueing_time_ + processing_time); + process_times_->AddTime(processing_time); + total_times_->AddTime(queueing_time_ + processing_time); } if (now - begin_process_message_ > TimeDelta::FromMilliseconds(kMaxMessageProcessingMs)) { @@ -208,8 +210,8 @@ class JankObserver : public base::RefCountedThreadSafe<JankObserver>, // Counters for the two types of jank we measure. StatsCounter slow_processing_counter_; // Messages with long processing time. StatsCounter queueing_delay_counter_; // Messages with long queueing delay. - Histogram process_times_; // Time spent processing task. - Histogram total_times_; // Total of queueing plus processing time. + scoped_refptr<Histogram> process_times_; // Time spent processing task. + scoped_refptr<Histogram> total_times_; // Total queueing plus processing. JankWatchdog total_time_watchdog_; // Watching for excessive total_time. DISALLOW_EVIL_CONSTRUCTORS(JankObserver); |