Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3285)

Unified Diff: chrome/renderer/render_thread.cc

Issue 462027: Use factory to create histograms, and refcounts to track lifetimes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | net/base/connection_type_histograms.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_thread.cc
===================================================================
--- chrome/renderer/render_thread.cc (revision 33932)
+++ chrome/renderer/render_thread.cc (working copy)
@@ -482,11 +482,17 @@
static void* CreateHistogram(
const char *name, int min, int max, size_t buckets) {
- Histogram* histogram = new Histogram(name, min, max, buckets);
- if (histogram) {
- histogram->SetFlags(kUmaTargetedHistogramFlag);
- }
- return histogram;
+ if (min <= 0)
+ min = 1;
+ scoped_refptr<Histogram> histogram =
+ Histogram::HistogramFactoryGet(name, min, max, buckets);
+ // We verify this was not being destructed by setting a novel "PlannedLeak"
+ // flag and watching out for the flag in the destructor.
+ histogram->SetFlags(kUmaTargetedHistogramFlag | kPlannedLeakFlag);
+ // We'll end up leaking these histograms, unless there is some code hiding in
+ // there to do the dec-ref.
+ histogram->AddRef();
+ return histogram.get();
}
static void AddHistogramSample(void* hist, int sample) {
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | net/base/connection_type_histograms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698