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


CrOS-Libchrome-Original-Commit: e8829a1981a2d9d849c377c28f9444fdefee0f44
diff --git a/base/message_loop.cc b/base/message_loop.cc
index ddca7db..64913e5 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -531,11 +531,12 @@
   if (enable_histogrammer_ && !message_histogram_.get()
       && StatisticsRecorder::WasStarted()) {
     DCHECK(!thread_name_.empty());
-    message_histogram_.reset(
-        new LinearHistogram(("MsgLoop:" + thread_name_).c_str(),
+    message_histogram_ =
+        LinearHistogram::LinearHistogramFactoryGet(
+                            ("MsgLoop:" + thread_name_),
                             kLeastNonZeroMessageId,
                             kMaxMessageId,
-                            kNumberOfDistinctMessagesDisplayed));
+                            kNumberOfDistinctMessagesDisplayed);
     message_histogram_->SetFlags(message_histogram_->kHexRangePrintingFlag);
     message_histogram_->SetRangeDescriptions(event_descriptions_);
   }