Attempt four at landing the "histogram.h removed from message_loop.h" patch.

Previously committed as r52349 and r52336. Related commits: r52367, r52364
and r52343.

Rerunning trybots due to previous trybot breakage.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/2965015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52496 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 5097dc8cf47eb60b3284db2ccf3c1e645c6d8b7b
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 1668fd7..218ff26 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -7,6 +7,7 @@
 #include <algorithm>
 
 #include "base/compiler_specific.h"
+#include "base/histogram.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
 #include "base/message_pump_default.h"
@@ -27,22 +28,53 @@
 using base::Time;
 using base::TimeDelta;
 
+namespace {
+
 // A lazily created thread local storage for quick access to a thread's message
 // loop, if one exists.  This should be safe and free of static constructors.
-static base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr(
+base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr(
     base::LINKER_INITIALIZED);
 
-//------------------------------------------------------------------------------
-
 // Logical events for Histogram profiling. Run with -message-loop-histogrammer
 // to get an accounting of messages and actions taken on each thread.
-static const int kTaskRunEvent = 0x1;
-static const int kTimerEvent = 0x2;
+const int kTaskRunEvent = 0x1;
+const int kTimerEvent = 0x2;
 
 // Provide range of message IDs for use in histogramming and debug display.
-static const int kLeastNonZeroMessageId = 1;
-static const int kMaxMessageId = 1099;
-static const int kNumberOfDistinctMessagesDisplayed = 1100;
+const int kLeastNonZeroMessageId = 1;
+const int kMaxMessageId = 1099;
+const int kNumberOfDistinctMessagesDisplayed = 1100;
+
+// Provide a macro that takes an expression (such as a constant, or macro
+// constant) and creates a pair to initalize an array of pairs.  In this case,
+// our pair consists of the expressions value, and the "stringized" version
+// of the expression (i.e., the exrpression put in quotes).  For example, if
+// we have:
+//    #define FOO 2
+//    #define BAR 5
+// then the following:
+//    VALUE_TO_NUMBER_AND_NAME(FOO + BAR)
+// will expand to:
+//   {7, "FOO + BAR"}
+// We use the resulting array as an argument to our histogram, which reads the
+// number as a bucket identifier, and proceeds to use the corresponding name
+// in the pair (i.e., the quoted string) when printing out a histogram.
+#define VALUE_TO_NUMBER_AND_NAME(name) {name, #name},
+
+const LinearHistogram::DescriptionPair event_descriptions_[] = {
+  // Provide some pretty print capability in our histogram for our internal
+  // messages.
+
+  // A few events we handle (kindred to messages), and used to profile actions.
+  VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent)
+  VALUE_TO_NUMBER_AND_NAME(kTimerEvent)
+
+  {-1, NULL}  // The list must be null terminated, per API to histogram.
+};
+
+bool enable_histogrammer_ = false;
+
+}  // namespace
 
 //------------------------------------------------------------------------------
 
@@ -567,9 +599,6 @@
 // on each thread.
 
 // static
-bool MessageLoop::enable_histogrammer_ = false;
-
-// static
 void MessageLoop::EnableHistogrammer(bool enable) {
   enable_histogrammer_ = enable;
 }
@@ -591,34 +620,6 @@
     message_histogram_->Add(event);
 }
 
-// Provide a macro that takes an expression (such as a constant, or macro
-// constant) and creates a pair to initalize an array of pairs.  In this case,
-// our pair consists of the expressions value, and the "stringized" version
-// of the expression (i.e., the exrpression put in quotes).  For example, if
-// we have:
-//    #define FOO 2
-//    #define BAR 5
-// then the following:
-//    VALUE_TO_NUMBER_AND_NAME(FOO + BAR)
-// will expand to:
-//   {7, "FOO + BAR"}
-// We use the resulting array as an argument to our histogram, which reads the
-// number as a bucket identifier, and proceeds to use the corresponding name
-// in the pair (i.e., the quoted string) when printing out a histogram.
-#define VALUE_TO_NUMBER_AND_NAME(name) {name, #name},
-
-// static
-const LinearHistogram::DescriptionPair MessageLoop::event_descriptions_[] = {
-  // Provide some pretty print capability in our histogram for our internal
-  // messages.
-
-  // A few events we handle (kindred to messages), and used to profile actions.
-  VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent)
-  VALUE_TO_NUMBER_AND_NAME(kTimerEvent)
-
-  {-1, NULL}  // The list must be null terminated, per API to histogram.
-};
-
 //------------------------------------------------------------------------------
 // MessageLoopForUI
 
diff --git a/base/message_loop.h b/base/message_loop.h
index 8deacec..35b2651 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -9,11 +9,10 @@
 #include <string>
 
 #include "base/basictypes.h"
-#include "base/histogram.h"
+#include "base/lock.h"
 #include "base/message_pump.h"
 #include "base/observer_list.h"
 #include "base/ref_counted.h"
-#include "base/scoped_ptr.h"
 #include "base/task.h"
 
 #if defined(OS_WIN)
@@ -27,6 +26,8 @@
 #endif
 #endif
 
+class Histogram;
+
 // A MessageLoop is used to process events for a particular thread.  There is
 // at most one MessageLoop instance per thread.
 //
@@ -427,9 +428,6 @@
   // If message_histogram_ is NULL, this is a no-op.
   void HistogramEvent(int event);
 
-  static const LinearHistogram::DescriptionPair event_descriptions_[];
-  static bool enable_histogrammer_;
-
   Type type_;
 
   // A list of tasks that need to be processed by this instance.  Note that
diff --git a/base/message_loop_proxy_impl_unittest.cc b/base/message_loop_proxy_impl_unittest.cc
index 5fe341c..a3cb800 100644
--- a/base/message_loop_proxy_impl_unittest.cc
+++ b/base/message_loop_proxy_impl_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "base/message_loop.h"
 #include "base/message_loop_proxy_impl.h"
+#include "base/scoped_ptr.h"
 #include "base/thread.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h
index 62db5dc..f7dabef 100644
--- a/base/observer_list_threadsafe.h
+++ b/base/observer_list_threadsafe.h
@@ -5,8 +5,9 @@
 #ifndef BASE_OBSERVER_LIST_THREADSAFE_H_
 #define BASE_OBSERVER_LIST_THREADSAFE_H_
 
-#include <vector>
 #include <algorithm>
+#include <map>
+#include <vector>
 
 #include "base/basictypes.h"
 #include "base/callback.h"
diff --git a/base/weak_ptr_unittest.cc b/base/weak_ptr_unittest.cc
index 0713983..b808401 100644
--- a/base/weak_ptr_unittest.cc
+++ b/base/weak_ptr_unittest.cc
@@ -5,6 +5,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "base/message_loop.h"
 #include "base/thread.h"
+#include "base/scoped_ptr.h"
 #include "base/weak_ptr.h"
 
 namespace base {