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/renderer_host/buffered_resource_handler.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/renderer_host/buffered_resource_handler.cc')
-rw-r--r-- | chrome/browser/renderer_host/buffered_resource_handler.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index f3ca82f..6cf4430 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -30,18 +30,23 @@ const int kMaxBytesToSniff = 512; void RecordSnifferMetrics(bool sniffing_blocked, bool we_would_like_to_sniff, const std::string& mime_type) { - static BooleanHistogram nosniff_usage("nosniff.usage"); - nosniff_usage.SetFlags(kUmaTargetedHistogramFlag); - nosniff_usage.AddBoolean(sniffing_blocked); + static scoped_refptr<Histogram> nosniff_usage = + BooleanHistogram::BooleanHistogramFactoryGet("nosniff.usage"); + nosniff_usage->SetFlags(kUmaTargetedHistogramFlag); + nosniff_usage->AddBoolean(sniffing_blocked); if (sniffing_blocked) { - static BooleanHistogram nosniff_otherwise("nosniff.otherwise"); - nosniff_otherwise.SetFlags(kUmaTargetedHistogramFlag); - nosniff_otherwise.AddBoolean(we_would_like_to_sniff); - - static BooleanHistogram nosniff_empty_mime_type("nosniff.empty_mime_type"); - nosniff_empty_mime_type.SetFlags(kUmaTargetedHistogramFlag); - nosniff_empty_mime_type.AddBoolean(mime_type.empty()); + static scoped_refptr<Histogram> nosniff_otherwise = + BooleanHistogram::BooleanHistogramFactoryGet( + "nosniff.otherwise"); + nosniff_otherwise->SetFlags(kUmaTargetedHistogramFlag); + nosniff_otherwise->AddBoolean(we_would_like_to_sniff); + + static scoped_refptr<Histogram> nosniff_empty_mime_type = + BooleanHistogram::BooleanHistogramFactoryGet( + "nosniff.empty_mime_type"); + nosniff_empty_mime_type->SetFlags(kUmaTargetedHistogramFlag); + nosniff_empty_mime_type->AddBoolean(mime_type.empty()); } } |