diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-14 17:47:13 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-14 17:47:13 +0000 |
commit | f1d9428ecf3a598fb8bc86c9e1f8707dc6bd73cb (patch) | |
tree | 674b70edcb7ba1059d8a7d22d5d57fac501a850b /base | |
parent | 03f57072cd19125c59fbc1d7c76f2856ca200850 (diff) | |
download | chromium_src-f1d9428ecf3a598fb8bc86c9e1f8707dc6bd73cb.zip chromium_src-f1d9428ecf3a598fb8bc86c9e1f8707dc6bd73cb.tar.gz chromium_src-f1d9428ecf3a598fb8bc86c9e1f8707dc6bd73cb.tar.bz2 |
Revert 52336 - More header cleanup:
- Some cleanup to url_request.h
- Remove task.h from headers that don't need it.
- Remove histogram.h from message_loop.h
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2986002
TBR=erg@chromium.org
Review URL: http://codereview.chromium.org/2969006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop.cc | 79 | ||||
-rw-r--r-- | base/message_loop.h | 8 | ||||
-rw-r--r-- | base/message_loop_proxy_impl_unittest.cc | 1 | ||||
-rw-r--r-- | base/observer_list_threadsafe.h | 3 | ||||
-rw-r--r-- | base/weak_ptr_unittest.cc | 1 |
5 files changed, 45 insertions, 47 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index 218ff26..1668fd7 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -7,7 +7,6 @@ #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" @@ -28,53 +27,22 @@ 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. -base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr( +static 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. -const int kTaskRunEvent = 0x1; -const int kTimerEvent = 0x2; +static const int kTaskRunEvent = 0x1; +static const int kTimerEvent = 0x2; // Provide range of message IDs for use in histogramming and debug display. -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 +static const int kLeastNonZeroMessageId = 1; +static const int kMaxMessageId = 1099; +static const int kNumberOfDistinctMessagesDisplayed = 1100; //------------------------------------------------------------------------------ @@ -599,6 +567,9 @@ bool MessageLoop::PendingTask::operator<(const PendingTask& other) const { // on each thread. // static +bool MessageLoop::enable_histogrammer_ = false; + +// static void MessageLoop::EnableHistogrammer(bool enable) { enable_histogrammer_ = enable; } @@ -620,6 +591,34 @@ void MessageLoop::HistogramEvent(int event) { 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 35b2651..8deacec 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -9,10 +9,11 @@ #include <string> #include "base/basictypes.h" -#include "base/lock.h" +#include "base/histogram.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) @@ -26,8 +27,6 @@ #endif #endif -class Histogram; - // A MessageLoop is used to process events for a particular thread. There is // at most one MessageLoop instance per thread. // @@ -428,6 +427,9 @@ class MessageLoop : public base::MessagePump::Delegate { // 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 a3cb800..5fe341c 100644 --- a/base/message_loop_proxy_impl_unittest.cc +++ b/base/message_loop_proxy_impl_unittest.cc @@ -4,7 +4,6 @@ #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 f7dabef..62db5dc 100644 --- a/base/observer_list_threadsafe.h +++ b/base/observer_list_threadsafe.h @@ -5,9 +5,8 @@ #ifndef BASE_OBSERVER_LIST_THREADSAFE_H_ #define BASE_OBSERVER_LIST_THREADSAFE_H_ -#include <algorithm> -#include <map> #include <vector> +#include <algorithm> #include "base/basictypes.h" #include "base/callback.h" diff --git a/base/weak_ptr_unittest.cc b/base/weak_ptr_unittest.cc index b808401..0713983 100644 --- a/base/weak_ptr_unittest.cc +++ b/base/weak_ptr_unittest.cc @@ -5,7 +5,6 @@ #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 { |