diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 04:38:38 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 04:38:38 +0000 |
commit | 835d7c811c98f179090c57a827a9c9baa2130435 (patch) | |
tree | edcff6b2c9029c6f867f650d762837f2485d99fb /base | |
parent | 4b1deac7ba7e7a6bf0425e6ed4db26e0c29daa7f (diff) | |
download | chromium_src-835d7c811c98f179090c57a827a9c9baa2130435.zip chromium_src-835d7c811c98f179090c57a827a9c9baa2130435.tar.gz chromium_src-835d7c811c98f179090c57a827a9c9baa2130435.tar.bz2 |
Move Stats, histograms, and field trial into a metrics subdirectory of base and
put them in the base namespace.
TEST=it compiles
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gyp | 6 | ||||
-rw-r--r-- | base/base.gypi | 16 | ||||
-rw-r--r-- | base/data_pack.cc | 4 | ||||
-rw-r--r-- | base/file_util_win.cc | 2 | ||||
-rw-r--r-- | base/message_loop.cc | 9 | ||||
-rw-r--r-- | base/message_loop.h | 4 | ||||
-rw-r--r-- | base/message_pump_win.cc | 4 | ||||
-rw-r--r-- | base/metrics/field_trial.cc (renamed from base/field_trial.cc) | 5 | ||||
-rw-r--r-- | base/metrics/field_trial.h (renamed from base/field_trial.h) | 21 | ||||
-rw-r--r-- | base/metrics/field_trial_unittest.cc (renamed from base/field_trial_unittest.cc) | 10 | ||||
-rw-r--r-- | base/metrics/histogram.cc (renamed from base/histogram.cc) | 87 | ||||
-rw-r--r-- | base/metrics/histogram.h (renamed from base/histogram.h) | 82 | ||||
-rw-r--r-- | base/metrics/histogram_unittest.cc (renamed from base/histogram_unittest.cc) | 7 | ||||
-rw-r--r-- | base/metrics/stats_counters.cc (renamed from base/stats_counters.cc) | 18 | ||||
-rw-r--r-- | base/metrics/stats_counters.h (renamed from base/stats_counters.h) | 28 | ||||
-rw-r--r-- | base/metrics/stats_table.cc (renamed from base/stats_table.cc) | 94 | ||||
-rw-r--r-- | base/metrics/stats_table.h (renamed from base/stats_table.h) | 28 | ||||
-rw-r--r-- | base/metrics/stats_table_unittest.cc (renamed from base/stats_table_unittest.cc) | 22 | ||||
-rw-r--r-- | base/process_util_win.cc | 2 | ||||
-rw-r--r-- | base/worker_pool_mac.mm | 6 |
20 files changed, 249 insertions, 206 deletions
diff --git a/base/base.gyp b/base/base.gyp index 2f541ee..d6245ca 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -81,13 +81,11 @@ 'event_trace_consumer_win_unittest.cc', 'event_trace_controller_win_unittest.cc', 'event_trace_provider_win_unittest.cc', - 'field_trial_unittest.cc', 'file_descriptor_shuffle_unittest.cc', 'file_path_unittest.cc', 'file_util_unittest.cc', 'file_version_info_unittest.cc', 'gmock_unittest.cc', - 'histogram_unittest.cc', 'hmac_unittest.cc', 'id_map_unittest.cc', 'i18n/char_iterator_unittest.cc', @@ -108,6 +106,9 @@ 'message_loop_proxy_impl_unittest.cc', 'message_loop_unittest.cc', 'message_pump_glib_unittest.cc', + 'metrics/field_trial_unittest.cc', + 'metrics/histogram_unittest.cc', + 'metrics/stats_table_unittest.cc', 'non_thread_safe_unittest.cc', 'object_watcher_unittest.cc', 'observer_list_unittest.cc', @@ -135,7 +136,6 @@ 'simple_thread_unittest.cc', 'singleton_unittest.cc', 'stack_container_unittest.cc', - 'stats_table_unittest.cc', 'string_number_conversions_unittest.cc', 'string_piece_unittest.cc', 'string_split_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index bd15b00..9329ccb 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -95,8 +95,6 @@ 'gtk_util.cc', 'gtk_util.h', 'hash_tables.h', - 'histogram.cc', - 'histogram.h', 'iat_patch.cc', 'iat_patch.h', 'id_map.h', @@ -138,6 +136,12 @@ 'message_pump_default.h', 'message_pump_win.cc', 'message_pump_win.h', + 'metrics/histogram.cc', + 'metrics/histogram.h', + 'metrics/stats_counters.cc', + 'metrics/stats_counters.h', + 'metrics/stats_table.cc', + 'metrics/stats_table.h', 'mime_util.h', 'mime_util_xdg.cc', 'move.h', @@ -223,10 +227,6 @@ 'singleton.h', 'spin_wait.h', 'stack_container.h', - 'stats_counters.cc', - 'stats_counters.h', - 'stats_table.cc', - 'stats_table.h', 'stl_util-inl.h', 'string_number_conversions.cc', 'string_number_conversions.h', @@ -429,8 +429,6 @@ 'event_recorder.cc', 'event_recorder.h', 'event_recorder_stubs.cc', - 'field_trial.cc', - 'field_trial.h', 'file_descriptor_shuffle.cc', 'file_descriptor_shuffle.h', 'hmac.h', @@ -449,6 +447,8 @@ 'message_pump_libevent.h', 'message_pump_mac.h', 'message_pump_mac.mm', + 'metrics/field_trial.cc', + 'metrics/field_trial.h', 'nsimage_cache_mac.h', 'nsimage_cache_mac.mm', 'nss_util.cc', diff --git a/base/data_pack.cc b/base/data_pack.cc index 29ecf98..e01318f 100644 --- a/base/data_pack.cc +++ b/base/data_pack.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,8 +7,8 @@ #include <errno.h> #include "base/file_util.h" -#include "base/histogram.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/ref_counted_memory.h" #include "base/string_piece.h" diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 876b89d..dec4be6 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -13,8 +13,8 @@ #include <string> #include "base/file_path.h" -#include "base/histogram.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/pe_image.h" #include "base/scoped_comptr_win.h" #include "base/scoped_handle.h" diff --git a/base/message_loop.cc b/base/message_loop.cc index 56d1418..8f6c997b 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -7,10 +7,10 @@ #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" +#include "base/metrics/histogram.h" #include "base/thread_local.h" #if defined(OS_MACOSX) @@ -60,7 +60,7 @@ const int kNumberOfDistinctMessagesDisplayed = 1100; // 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_[] = { +const base::LinearHistogram::DescriptionPair event_descriptions_[] = { // Provide some pretty print capability in our histogram for our internal // messages. @@ -617,9 +617,10 @@ void MessageLoop::EnableHistogrammer(bool enable) { void MessageLoop::StartHistogrammer() { if (enable_histogrammer_ && !message_histogram_.get() - && StatisticsRecorder::WasStarted()) { + && base::StatisticsRecorder::WasStarted()) { DCHECK(!thread_name_.empty()); - message_histogram_ = LinearHistogram::FactoryGet("MsgLoop:" + thread_name_, + message_histogram_ = base::LinearHistogram::FactoryGet( + "MsgLoop:" + thread_name_, kLeastNonZeroMessageId, kMaxMessageId, kNumberOfDistinctMessagesDisplayed, message_histogram_->kHexRangePrintingFlag); diff --git a/base/message_loop.h b/base/message_loop.h index 363c5d0..94e0096 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -27,7 +27,9 @@ #endif #endif +namespace base { class Histogram; +} // A MessageLoop is used to process events for a particular thread. There is // at most one MessageLoop instance per thread. @@ -457,7 +459,7 @@ class MessageLoop : public base::MessagePump::Delegate { std::string thread_name_; // A profiling histogram showing the counts of various messages and events. - scoped_refptr<Histogram> message_histogram_; + scoped_refptr<base::Histogram> message_histogram_; // A null terminated list which creates an incoming_queue of tasks that are // aquired under a mutex for processing on this instance's thread. These tasks diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc index fc4b2e4..d0afd51 100644 --- a/base/message_pump_win.cc +++ b/base/message_pump_win.cc @@ -6,9 +6,7 @@ #include <math.h> -#include "base/histogram.h" - -using base::Time; +#include "base/metrics/histogram.h" namespace base { diff --git a/base/field_trial.cc b/base/metrics/field_trial.cc index a3e6ac6..63d9ed5 100644 --- a/base/field_trial.cc +++ b/base/metrics/field_trial.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/field_trial.h" +#include "base/metrics/field_trial.h" #include "base/logging.h" #include "base/rand_util.h" #include "base/stringprintf.h" -using base::TimeTicks; +namespace base { // static const int FieldTrial::kNotParticipating = -1; @@ -190,3 +190,4 @@ bool FieldTrialList::StringAugmentsState(const std::string& prior_state) { return true; } +} // namespace base diff --git a/base/field_trial.h b/base/metrics/field_trial.h index deee838..348a1a7 100644 --- a/base/field_trial.h +++ b/base/metrics/field_trial.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -59,8 +59,8 @@ //------------------------------------------------------------------------------ -#ifndef BASE_FIELD_TRIAL_H_ -#define BASE_FIELD_TRIAL_H_ +#ifndef BASE_METRICS_FIELD_TRIAL_H_ +#define BASE_METRICS_FIELD_TRIAL_H_ #pragma once #include <map> @@ -70,8 +70,9 @@ #include "base/ref_counted.h" #include "base/time.h" +namespace base { -class FieldTrial : public base::RefCounted<FieldTrial> { +class FieldTrial : public RefCounted<FieldTrial> { public: typedef int Probability; // Probability type for being selected in a trial. @@ -117,7 +118,7 @@ class FieldTrial : public base::RefCounted<FieldTrial> { const std::string& trial_name); private: - friend class base::RefCounted<FieldTrial>; + friend class RefCounted<FieldTrial>; virtual ~FieldTrial(); @@ -198,11 +199,11 @@ class FieldTrialList { // of the application. In some experiments it may be useful to discount // data that is gathered before the application has reached sufficient // stability (example: most DLL have loaded, etc.) - static base::TimeTicks application_start_time() { + static TimeTicks application_start_time() { if (global_) return global_->application_start_time_; // For testing purposes only, or when we don't yet have a start time. - return base::TimeTicks::Now(); + return TimeTicks::Now(); } private: @@ -222,7 +223,7 @@ class FieldTrialList { // A helper value made availabel to users, that shows when the FieldTrialList // was initialized. Note that this is a singleton instance, and hence is a // good approximation to the start of the process. - base::TimeTicks application_start_time_; + TimeTicks application_start_time_; // Lock for access to registered_. Lock lock_; @@ -231,5 +232,7 @@ class FieldTrialList { DISALLOW_COPY_AND_ASSIGN(FieldTrialList); }; -#endif // BASE_FIELD_TRIAL_H_ +} // namespace base + +#endif // BASE_METRICS_FIELD_TRIAL_H_ diff --git a/base/field_trial_unittest.cc b/base/metrics/field_trial_unittest.cc index 94eb7fc..aea8e85 100644 --- a/base/field_trial_unittest.cc +++ b/base/metrics/field_trial_unittest.cc @@ -1,14 +1,16 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Test of FieldTrial class -#include "base/field_trial.h" +#include "base/metrics/field_trial.h" #include "base/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { + class FieldTrialTest : public testing::Test { public: FieldTrialTest() : trial_list_() { } @@ -76,7 +78,7 @@ TEST_F(FieldTrialTest, RemainingProbability) { scoped_refptr<FieldTrial> trial; int counter = 0; do { - std::string name = base::StringPrintf("trial%d", ++counter); + std::string name = StringPrintf("trial%d", ++counter); trial = new FieldTrial(name, 10); trial->AppendGroup(loser, 5); // 50% chance of not being chosen. } while (trial->group() != FieldTrial::kNotParticipating); @@ -227,3 +229,5 @@ TEST_F(FieldTrialTest, MakeName) { EXPECT_EQ("Histogram_Winner", FieldTrial::MakeName("Histogram", "Field Trial")); } + +} // namespace base diff --git a/base/histogram.cc b/base/metrics/histogram.cc index e045d81..9746e9c 100644 --- a/base/histogram.cc +++ b/base/metrics/histogram.cc @@ -7,7 +7,7 @@ // vector of numbers corresponding to each of the aggregating buckets). // See header file for details and examples. -#include "base/histogram.h" +#include "base/metrics/histogram.h" #include <math.h> @@ -19,7 +19,7 @@ #include "base/pickle.h" #include "base/stringprintf.h" -using base::TimeDelta; +namespace base { typedef Histogram::Count Count; @@ -45,8 +45,10 @@ scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name, } scoped_refptr<Histogram> Histogram::FactoryTimeGet(const std::string& name, - base::TimeDelta minimum, base::TimeDelta maximum, size_t bucket_count, - Flags flags) { + TimeDelta minimum, + TimeDelta maximum, + size_t bucket_count, + Flags flags) { return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), bucket_count, flags); } @@ -304,14 +306,15 @@ void Histogram::SnapshotSample(SampleSet* sample) const { *sample = sample_; } -bool Histogram::HasConstructorArguments(Sample minimum, Sample maximum, +bool Histogram::HasConstructorArguments(Sample minimum, + Sample maximum, size_t bucket_count) { return ((minimum == declared_min_) && (maximum == declared_max_) && (bucket_count == bucket_count_)); } -bool Histogram::HasConstructorTimeDeltaArguments(base::TimeDelta minimum, - base::TimeDelta maximum, +bool Histogram::HasConstructorTimeDeltaArguments(TimeDelta minimum, + TimeDelta maximum, size_t bucket_count) { return ((minimum.InMilliseconds() == declared_min_) && (maximum.InMilliseconds() == declared_max_) && @@ -342,10 +345,10 @@ double Histogram::GetPeakBucketSize(const SampleSet& snapshot) const { void Histogram::WriteAsciiHeader(const SampleSet& snapshot, Count sample_count, std::string* output) const { - base::StringAppendF(output, - "Histogram: %s recorded %d samples", - histogram_name().c_str(), - sample_count); + StringAppendF(output, + "Histogram: %s recorded %d samples", + histogram_name().c_str(), + sample_count); if (0 == sample_count) { DCHECK_EQ(snapshot.sum(), 0); } else { @@ -354,13 +357,12 @@ void Histogram::WriteAsciiHeader(const SampleSet& snapshot, - average * average; double standard_deviation = sqrt(variance); - base::StringAppendF(output, - ", average = %.1f, standard deviation = %.1f", - average, standard_deviation); + StringAppendF(output, + ", average = %.1f, standard deviation = %.1f", + average, standard_deviation); } - if (flags_ & ~kHexRangePrintingFlag ) - base::StringAppendF(output, " (flags = 0x%x)", - flags_ & ~kHexRangePrintingFlag); + if (flags_ & ~kHexRangePrintingFlag) + StringAppendF(output, " (flags = 0x%x)", flags_ & ~kHexRangePrintingFlag); } void Histogram::WriteAsciiBucketContext(const int64 past, @@ -372,22 +374,22 @@ void Histogram::WriteAsciiBucketContext(const int64 past, WriteAsciiBucketValue(current, scaled_sum, output); if (0 < i) { double percentage = past / scaled_sum; - base::StringAppendF(output, " {%3.1f%%}", percentage); + StringAppendF(output, " {%3.1f%%}", percentage); } } const std::string Histogram::GetAsciiBucketRange(size_t i) const { std::string result; if (kHexRangePrintingFlag & flags_) - base::StringAppendF(&result, "%#x", ranges(i)); + StringAppendF(&result, "%#x", ranges(i)); else - base::StringAppendF(&result, "%d", ranges(i)); + StringAppendF(&result, "%d", ranges(i)); return result; } void Histogram::WriteAsciiBucketValue(Count current, double scaled_sum, std::string* output) const { - base::StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); + StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); } void Histogram::WriteAsciiBucketGraph(double current_size, double max_size, @@ -600,9 +602,11 @@ bool Histogram::SampleSet::Deserialize(void** iter, const Pickle& pickle) { // buckets. //------------------------------------------------------------------------------ -scoped_refptr<Histogram> LinearHistogram::FactoryGet( - const std::string& name, Sample minimum, Sample maximum, - size_t bucket_count, Flags flags) { +scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name, + Sample minimum, + Sample maximum, + size_t bucket_count, + Flags flags) { scoped_refptr<Histogram> histogram(NULL); if (minimum <= 0) @@ -622,8 +626,11 @@ scoped_refptr<Histogram> LinearHistogram::FactoryGet( } scoped_refptr<Histogram> LinearHistogram::FactoryTimeGet( - const std::string& name, base::TimeDelta minimum, base::TimeDelta maximum, - size_t bucket_count, Flags flags) { + const std::string& name, + TimeDelta minimum, + TimeDelta maximum, + size_t bucket_count, + Flags flags) { return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), bucket_count, flags); } @@ -631,15 +638,19 @@ scoped_refptr<Histogram> LinearHistogram::FactoryTimeGet( LinearHistogram::~LinearHistogram() { } -LinearHistogram::LinearHistogram(const std::string& name, Sample minimum, - Sample maximum, size_t bucket_count) +LinearHistogram::LinearHistogram(const std::string& name, + Sample minimum, + Sample maximum, + size_t bucket_count) : Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) { InitializeBucketRange(); DCHECK(ValidateBucketRanges()); } LinearHistogram::LinearHistogram(const std::string& name, - TimeDelta minimum, TimeDelta maximum, size_t bucket_count) + TimeDelta minimum, + TimeDelta maximum, + size_t bucket_count) : Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ? minimum : TimeDelta::FromMilliseconds(1), maximum, bucket_count) { @@ -727,7 +738,8 @@ BooleanHistogram::BooleanHistogram(const std::string& name) //------------------------------------------------------------------------------ scoped_refptr<Histogram> CustomHistogram::FactoryGet( - const std::string& name, const std::vector<int>& custom_ranges, + const std::string& name, + const std::vector<int>& custom_ranges, Flags flags) { scoped_refptr<Histogram> histogram(NULL); @@ -761,7 +773,7 @@ Histogram::ClassType CustomHistogram::histogram_type() const { } CustomHistogram::CustomHistogram(const std::string& name, - const std::vector<int>& custom_ranges) + const std::vector<int>& custom_ranges) : Histogram(name, custom_ranges[1], custom_ranges.back(), custom_ranges.size()) { DCHECK_GT(custom_ranges.size(), 1u); @@ -774,9 +786,8 @@ CustomHistogram::CustomHistogram(const std::string& name, void CustomHistogram::InitializeBucketRange() { DCHECK(ranges_vector_->size() <= bucket_count()); - for (size_t index = 0; index < ranges_vector_->size(); ++index) { + for (size_t index = 0; index < ranges_vector_->size(); ++index) SetBucketRange(index, (*ranges_vector_)[index]); - } } double CustomHistogram::GetBucketSize(Count current, size_t i) const { @@ -862,12 +873,10 @@ void StatisticsRecorder::WriteGraph(const std::string& query, std::string* output) { if (!histograms_) return; - if (query.length()) { - base::StringAppendF(output, "Collections of histograms for %s\n", - query.c_str()); - } else { + if (query.length()) + StringAppendF(output, "Collections of histograms for %s\n", query.c_str()); + else output->append("Collections of all histograms\n"); - } Histograms snapshot; GetSnapshot(query, &snapshot); @@ -922,3 +931,5 @@ StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; Lock* StatisticsRecorder::lock_ = NULL; // static bool StatisticsRecorder::dump_on_exit_ = false; + +} // namespace base diff --git a/base/histogram.h b/base/metrics/histogram.h index 0287d37..20f67c2 100644 --- a/base/histogram.h +++ b/base/metrics/histogram.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,8 +28,8 @@ // at the low end of the histogram scale, but allows the histogram to cover a // gigantic range with the addition of very few buckets. -#ifndef BASE_HISTOGRAM_H_ -#define BASE_HISTOGRAM_H_ +#ifndef BASE_METRICS_HISTOGRAM_H_ +#define BASE_METRICS_HISTOGRAM_H_ #pragma once #include <map> @@ -41,6 +41,9 @@ #include "base/time.h" class Lock; +class Pickle; + +namespace base { //------------------------------------------------------------------------------ // Provide easy general purpose histogram in a macro, just like stats counters. @@ -60,8 +63,9 @@ class Lock; name, sample, 1, 10000, 50) #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ - name, min, max, bucket_count, Histogram::kNoFlags); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryGet(name, min, max, bucket_count, \ + base::Histogram::kNoFlags); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) @@ -72,16 +76,18 @@ class Lock; // For folks that need real specific times, use this to select a precise range // of times you want plotted, and the number of buckets you want used. #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ - name, min, max, bucket_count, Histogram::kNoFlags); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ + base::Histogram::kNoFlags); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->AddTime(sample); \ } while (0) // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ - name, min, max, bucket_count, Histogram::kNoFlags); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ + base::Histogram::kNoFlags); \ DCHECK_EQ(name, counter->histogram_name()); \ if ((sample) < (max) && counter.get()) counter->AddTime(sample); \ } while (0) @@ -90,15 +96,18 @@ class Lock; // less than boundary_value. #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ - static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ - name, 1, boundary_value, boundary_value + 1, Histogram::kNoFlags); \ + static scoped_refptr<base::Histogram> counter = \ + base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ + boundary_value + 1, \ + base::Histogram::kNoFlags); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) #define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \ - static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \ - name, custom_ranges, Histogram::kNoFlags); \ + static scoped_refptr<base::Histogram> counter = \ + base::CustomHistogram::FactoryGet(name, custom_ranges, \ + base::Histogram::kNoFlags); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) @@ -160,16 +169,18 @@ class Lock; base::TimeDelta::FromHours(1), 50) #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ - name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ + base::Histogram::kUmaTargetedHistogramFlag); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->AddTime(sample); \ } while (0) // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ - name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ + base::Histogram::kUmaTargetedHistogramFlag); \ DCHECK_EQ(name, counter->histogram_name()); \ if ((sample) < (max) && counter.get()) counter->AddTime(sample); \ } while (0) @@ -184,8 +195,9 @@ class Lock; name, sample, 1, 10000, 50) #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ - static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ - name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + static scoped_refptr<base::Histogram> counter = \ + base::Histogram::FactoryGet(name, min, max, bucket_count, \ + base::Histogram::kUmaTargetedHistogramFlag); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) @@ -200,16 +212,17 @@ class Lock; UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ - static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ - name, 1, boundary_value, boundary_value + 1, \ - Histogram::kUmaTargetedHistogramFlag); \ + static scoped_refptr<base::Histogram> counter = \ + base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ + boundary_value + 1, base::Histogram::kUmaTargetedHistogramFlag); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \ - static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \ - name, custom_ranges, Histogram::kUmaTargetedHistogramFlag); \ + static scoped_refptr<base::Histogram> counter = \ + base::CustomHistogram::FactoryGet(name, custom_ranges, \ + base::Histogram::kUmaTargetedHistogramFlag); \ DCHECK_EQ(name, counter->histogram_name()); \ if (counter.get()) counter->Add(sample); \ } while (0) @@ -220,7 +233,6 @@ class BooleanHistogram; class CustomHistogram; class Histogram; class LinearHistogram; -class Pickle; class Histogram : public base::RefCountedThreadSafe<Histogram> { public: @@ -319,7 +331,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> { virtual void AddBoolean(bool value); // Accept a TimeDelta to increment. - void AddTime(base::TimeDelta time) { + void AddTime(TimeDelta time) { Add(static_cast<int>(time.InMilliseconds())); } @@ -371,16 +383,16 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> { virtual bool HasConstructorArguments(Sample minimum, Sample maximum, size_t bucket_count); - virtual bool HasConstructorTimeDeltaArguments(base::TimeDelta minimum, - base::TimeDelta maximum, + virtual bool HasConstructorTimeDeltaArguments(TimeDelta minimum, + TimeDelta maximum, size_t bucket_count); protected: friend class base::RefCountedThreadSafe<Histogram>; Histogram(const std::string& name, Sample minimum, Sample maximum, size_t bucket_count); - Histogram(const std::string& name, base::TimeDelta minimum, - base::TimeDelta maximum, size_t bucket_count); + Histogram(const std::string& name, TimeDelta minimum, + TimeDelta maximum, size_t bucket_count); virtual ~Histogram(); @@ -489,7 +501,7 @@ class LinearHistogram : public Histogram { static scoped_refptr<Histogram> FactoryGet(const std::string& name, Sample minimum, Sample maximum, size_t bucket_count, Flags flags); static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name, - base::TimeDelta minimum, base::TimeDelta maximum, size_t bucket_count, + TimeDelta minimum, TimeDelta maximum, size_t bucket_count, Flags flags); virtual ~LinearHistogram(); @@ -498,8 +510,8 @@ class LinearHistogram : public Histogram { LinearHistogram(const std::string& name, Sample minimum, Sample maximum, size_t bucket_count); - LinearHistogram(const std::string& name, base::TimeDelta minimum, - base::TimeDelta maximum, size_t bucket_count); + LinearHistogram(const std::string& name, TimeDelta minimum, + TimeDelta maximum, size_t bucket_count); // Initialize ranges_ mapping. virtual void InitializeBucketRange(); @@ -626,4 +638,6 @@ class StatisticsRecorder { DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); }; -#endif // BASE_HISTOGRAM_H_ +} // namespace base + +#endif // BASE_METRICS_HISTOGRAM_H_ diff --git a/base/histogram_unittest.cc b/base/metrics/histogram_unittest.cc index 4637a5f..e7e3983 100644 --- a/base/histogram_unittest.cc +++ b/base/metrics/histogram_unittest.cc @@ -4,12 +4,11 @@ // Test of Histogram class -#include "base/histogram.h" +#include "base/metrics/histogram.h" #include "base/time.h" #include "testing/gtest/include/gtest/gtest.h" -using base::TimeDelta; - +namespace base { namespace { class HistogramTest : public testing::Test { @@ -308,5 +307,5 @@ TEST(HistogramTest, BucketPlacementTest) { EXPECT_EQ(i + 1, sample.counts(i)); } - } // namespace +} // namespace base diff --git a/base/stats_counters.cc b/base/metrics/stats_counters.cc index 345e1d6..958f048 100644 --- a/base/stats_counters.cc +++ b/base/metrics/stats_counters.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/stats_counters.h" +#include "base/metrics/stats_counters.h" + +namespace base { StatsCounter::StatsCounter(const std::string& name) : counter_id_(-1) { @@ -69,15 +71,15 @@ StatsCounterTimer::~StatsCounterTimer() { void StatsCounterTimer::Start() { if (!Enabled()) return; - start_time_ = base::TimeTicks::Now(); - stop_time_ = base::TimeTicks(); + start_time_ = TimeTicks::Now(); + stop_time_ = TimeTicks(); } // Stop the timer and record the results. void StatsCounterTimer::Stop() { if (!Enabled() || !Running()) return; - stop_time_ = base::TimeTicks::Now(); + stop_time_ = TimeTicks::Now(); Record(); } @@ -87,7 +89,7 @@ bool StatsCounterTimer::Running() { } // Accept a TimeDelta to increment. -void StatsCounterTimer::AddTime(base::TimeDelta time) { +void StatsCounterTimer::AddTime(TimeDelta time) { Add(static_cast<int>(time.InMilliseconds())); } @@ -96,10 +98,10 @@ void StatsCounterTimer::Record() { } -StatsRate::StatsRate(const char* name) +StatsRate::StatsRate(const std::string& name) : StatsCounterTimer(name), counter_(name), - largest_add_(std::string(" ").append(name).append("MAX").c_str()) { + largest_add_(std::string(" ").append(name).append("MAX")) { } StatsRate::~StatsRate() { @@ -111,3 +113,5 @@ void StatsRate::Add(int value) { if (value > largest_add_.value()) largest_add_.Set(value); } + +} // namespace base diff --git a/base/stats_counters.h b/base/metrics/stats_counters.h index defb9ee..2de2b73 100644 --- a/base/stats_counters.h +++ b/base/metrics/stats_counters.h @@ -1,16 +1,18 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -#ifndef BASE_STATS_COUNTERS_H__ -#define BASE_STATS_COUNTERS_H__ +#ifndef BASE_METRICS_STATS_COUNTERS_H_ +#define BASE_METRICS_STATS_COUNTERS_H_ #pragma once #include <string> -#include "base/stats_table.h" + +#include "base/metrics/stats_table.h" #include "base/time.h" +namespace base { + // StatsCounters are dynamically created values which can be tracked in // the StatsTable. They are designed to be lightweight to create and // easy to use. @@ -44,14 +46,14 @@ //------------------------------------------------------------------------------ // First provide generic macros, which exist in production as well as debug. #define STATS_COUNTER(name, delta) do { \ - static StatsCounter counter(name); \ + static base::StatsCounter counter(name); \ counter.Add(delta); \ } while (0) #define SIMPLE_STATS_COUNTER(name) STATS_COUNTER(name, 1) #define RATE_COUNTER(name, duration) do { \ - static StatsRate hit_count(name); \ + static base::StatsRate hit_count(name); \ hit_count.AddTime(duration); \ } while (0) @@ -142,14 +144,14 @@ class StatsCounterTimer : protected StatsCounter { bool Running(); // Accept a TimeDelta to increment. - virtual void AddTime(base::TimeDelta time); + virtual void AddTime(TimeDelta time); protected: // Compute the delta between start and stop, in milliseconds. void Record(); - base::TimeTicks start_time_; - base::TimeTicks stop_time_; + TimeTicks start_time_; + TimeTicks stop_time_; }; // A StatsRate is a timer that keeps a count of the number of intervals added so @@ -158,7 +160,7 @@ class StatsCounterTimer : protected StatsCounter { class StatsRate : public StatsCounterTimer { public: // Constructs and starts the timer. - explicit StatsRate(const char* name); + explicit StatsRate(const std::string& name); virtual ~StatsRate(); virtual void Add(int value); @@ -189,4 +191,6 @@ template<class T> class StatsScope { T& timer_; }; -#endif // BASE_STATS_COUNTERS_H__ +} // namespace base + +#endif // BASE_METRICS_STATS_COUNTERS_H_ diff --git a/base/stats_table.cc b/base/metrics/stats_table.cc index 2ef78e8..98b2f57 100644 --- a/base/stats_table.cc +++ b/base/metrics/stats_table.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/stats_table.h" +#include "base/metrics/stats_table.h" #include "base/logging.h" #include "base/platform_thread.h" @@ -18,6 +18,8 @@ #include "errno.h" #endif +namespace base { + // The StatsTable uses a shared memory segment that is laid out as follows // // +-------------------------------------------+ @@ -84,23 +86,12 @@ inline int AlignedSize(int size) { return size + AlignOffset(size); } -// StatsTableTLSData carries the data stored in the TLS slots for the -// StatsTable. This is used so that we can properly cleanup when the -// thread exits and return the table slot. -// -// Each thread that calls RegisterThread in the StatsTable will have -// a StatsTableTLSData stored in its TLS. -struct StatsTableTLSData { - StatsTable* table; - int slot; -}; - } // namespace -// The StatsTablePrivate maintains convenience pointers into the +// The StatsTable::Private maintains convenience pointers into the // shared memory segment. Use this class to keep the data structure // clean and accessible. -class StatsTablePrivate { +class StatsTable::Private { public: // Various header information contained in the memory mapped segment. struct TableHeader { @@ -110,12 +101,12 @@ class StatsTablePrivate { int max_threads; }; - // Construct a new StatsTablePrivate based on expected size parameters, or + // Construct a new Private based on expected size parameters, or // return NULL on failure. - static StatsTablePrivate* New(const std::string& name, int size, + static Private* New(const std::string& name, int size, int max_threads, int max_counters); - base::SharedMemory* shared_memory() { return &shared_memory_; } + SharedMemory* shared_memory() { return &shared_memory_; } // Accessors for our header pointers TableHeader* table_header() const { return table_header_; } @@ -145,7 +136,7 @@ class StatsTablePrivate { private: // Constructor is private because you should use New() instead. - StatsTablePrivate() {} + Private() {} // Initializes the table on first access. Sets header values // appropriately and zeroes all counters. @@ -155,7 +146,7 @@ class StatsTablePrivate { // Initializes our in-memory pointers into a pre-created StatsTable. void ComputeMappedPointers(void* memory); - base::SharedMemory shared_memory_; + SharedMemory shared_memory_; TableHeader* table_header_; char* thread_names_table_; PlatformThreadId* thread_tid_table_; @@ -165,11 +156,11 @@ class StatsTablePrivate { }; // static -StatsTablePrivate* StatsTablePrivate::New(const std::string& name, - int size, - int max_threads, - int max_counters) { - scoped_ptr<StatsTablePrivate> priv(new StatsTablePrivate()); +StatsTable::Private* StatsTable::Private::New(const std::string& name, + int size, + int max_threads, + int max_counters) { + scoped_ptr<Private> priv(new Private()); if (!priv->shared_memory_.Create(name, false, true, size)) return NULL; if (!priv->shared_memory_.Map(size)) @@ -189,9 +180,9 @@ StatsTablePrivate* StatsTablePrivate::New(const std::string& name, return priv.release(); } -void StatsTablePrivate::InitializeTable(void* memory, int size, - int max_counters, - int max_threads) { +void StatsTable::Private::InitializeTable(void* memory, int size, + int max_counters, + int max_threads) { // Zero everything. memset(memory, 0, size); @@ -203,7 +194,7 @@ void StatsTablePrivate::InitializeTable(void* memory, int size, header->max_threads = max_threads; } -void StatsTablePrivate::ComputeMappedPointers(void* memory) { +void StatsTable::Private::ComputeMappedPointers(void* memory) { char* data = static_cast<char*>(memory); int offset = 0; @@ -238,7 +229,16 @@ void StatsTablePrivate::ComputeMappedPointers(void* memory) { DCHECK_EQ(offset, size()); } - +// TLSData carries the data stored in the TLS slots for the +// StatsTable. This is used so that we can properly cleanup when the +// thread exits and return the table slot. +// +// Each thread that calls RegisterThread in the StatsTable will have +// a TLSData stored in its TLS. +struct StatsTable::TLSData { + StatsTable* table; + int slot; +}; // We keep a singleton table which can be easily accessed. StatsTable* StatsTable::global_table_ = NULL; @@ -248,14 +248,14 @@ StatsTable::StatsTable(const std::string& name, int max_threads, : impl_(NULL), tls_index_(SlotReturnFunction) { int table_size = - AlignedSize(sizeof(StatsTablePrivate::TableHeader)) + + AlignedSize(sizeof(Private::TableHeader)) + AlignedSize((max_counters * sizeof(char) * kMaxCounterNameLength)) + AlignedSize((max_threads * sizeof(char) * kMaxThreadNameLength)) + AlignedSize(max_threads * sizeof(int)) + AlignedSize(max_threads * sizeof(int)) + AlignedSize((sizeof(int) * (max_counters * max_threads))); - impl_ = StatsTablePrivate::New(name, table_size, max_threads, max_counters); + impl_ = Private::New(name, table_size, max_threads, max_counters); if (!impl_) PLOG(ERROR) << "StatsTable did not initialize"; @@ -287,7 +287,7 @@ int StatsTable::RegisterThread(const std::string& name) { // so that two threads don't grab the same slot. Fortunately, // thread creation shouldn't happen in inner loops. { - base::SharedMemoryAutoLock lock(impl_->shared_memory()); + SharedMemoryAutoLock lock(impl_->shared_memory()); slot = FindEmptyThread(); if (!slot) { return 0; @@ -297,23 +297,23 @@ int StatsTable::RegisterThread(const std::string& name) { std::string thread_name = name; if (name.empty()) thread_name = kUnknownName; - base::strlcpy(impl_->thread_name(slot), thread_name.c_str(), - kMaxThreadNameLength); + strlcpy(impl_->thread_name(slot), thread_name.c_str(), + kMaxThreadNameLength); *(impl_->thread_tid(slot)) = PlatformThread::CurrentId(); - *(impl_->thread_pid(slot)) = base::GetCurrentProcId(); + *(impl_->thread_pid(slot)) = GetCurrentProcId(); } // Set our thread local storage. - StatsTableTLSData* data = new StatsTableTLSData; + TLSData* data = new TLSData; data->table = this; data->slot = slot; tls_index_.Set(data); return slot; } -StatsTableTLSData* StatsTable::GetTLSData() const { - StatsTableTLSData* data = - static_cast<StatsTableTLSData*>(tls_index_.Get()); +StatsTable::TLSData* StatsTable::GetTLSData() const { + TLSData* data = + static_cast<TLSData*>(tls_index_.Get()); if (!data) return NULL; @@ -326,7 +326,7 @@ void StatsTable::UnregisterThread() { UnregisterThread(GetTLSData()); } -void StatsTable::UnregisterThread(StatsTableTLSData* data) { +void StatsTable::UnregisterThread(TLSData* data) { if (!data) return; DCHECK(impl_); @@ -344,7 +344,7 @@ void StatsTable::SlotReturnFunction(void* data) { // This is called by the TLS destructor, which on some platforms has // already cleared the TLS info, so use the tls_data argument // rather than trying to fetch it ourselves. - StatsTableTLSData* tls_data = static_cast<StatsTableTLSData*>(data); + TLSData* tls_data = static_cast<TLSData*>(data); if (tls_data) { DCHECK(tls_data->table); tls_data->table->UnregisterThread(tls_data); @@ -367,7 +367,7 @@ int StatsTable::CountThreadsRegistered() const { } int StatsTable::GetSlot() const { - StatsTableTLSData* data = GetTLSData(); + TLSData* data = GetTLSData(); if (!data) return 0; return data->slot; @@ -448,7 +448,7 @@ int StatsTable::AddCounter(const std::string& name) { { // To add a counter to the shared memory, we need the // shared memory lock. - base::SharedMemoryAutoLock lock(impl_->shared_memory()); + SharedMemoryAutoLock lock(impl_->shared_memory()); // We have space, so create a new counter. counter_id = FindCounterOrEmptyRow(name); @@ -458,8 +458,8 @@ int StatsTable::AddCounter(const std::string& name) { std::string counter_name = name; if (name.empty()) counter_name = kUnknownName; - base::strlcpy(impl_->counter_name(counter_id), counter_name.c_str(), - kMaxCounterNameLength); + strlcpy(impl_->counter_name(counter_id), counter_name.c_str(), + kMaxCounterNameLength); } // now add to our in-memory cache @@ -549,3 +549,5 @@ int* StatsTable::FindLocation(const char* name) { // Now we can find the location in the table. return table->GetLocation(counter, slot); } + +} // namespace base diff --git a/base/stats_table.h b/base/metrics/stats_table.h index 3522876..e83039c 100644 --- a/base/stats_table.h +++ b/base/metrics/stats_table.h @@ -17,21 +17,18 @@ // threads/processes which can use it. // -#ifndef BASE_STATS_TABLE_H__ -#define BASE_STATS_TABLE_H__ +#ifndef BASE_METRICS_STATS_TABLE_H_ +#define BASE_METRICS_STATS_TABLE_H_ #pragma once #include <string> + #include "base/basictypes.h" #include "base/hash_tables.h" #include "base/lock.h" #include "base/thread_local_storage.h" -class StatsTablePrivate; - -namespace { -struct StatsTableTLSData; -} +namespace base { class StatsTable { public: @@ -133,6 +130,9 @@ class StatsTable { static int* FindLocation(const char *name); private: + class Private; + struct TLSData; + // Returns the space occupied by a thread in the table. Generally used // if a thread terminates but the process continues. This function // does not zero out the thread's counters. @@ -141,7 +141,7 @@ class StatsTable { // This variant expects the tls data to be passed in, so it is safe to // call from inside a posix tls destructor (see doc for pthread_key_create). - void UnregisterThread(StatsTableTLSData* tls_data); + void UnregisterThread(TLSData* tls_data); // The SlotReturnFunction is called at thread exit for each thread // which used the StatsTable. @@ -169,13 +169,15 @@ class StatsTable { // Get the TLS data for the calling thread. Returns NULL if none is // initialized. - StatsTableTLSData* GetTLSData() const; + TLSData* GetTLSData() const; - typedef base::hash_map<std::string, int> CountersMap; + typedef hash_map<std::string, int> CountersMap; + + Private* impl_; - StatsTablePrivate* impl_; // The counters_lock_ protects the counters_ hash table. Lock counters_lock_; + // The counters_ hash map is an in-memory hash of the counters. // It is used for quick lookup of counters, but is cannot be used // as a substitute for what is in the shared memory. Even though @@ -189,4 +191,6 @@ class StatsTable { DISALLOW_COPY_AND_ASSIGN(StatsTable); }; -#endif // BASE_STATS_TABLE_H__ +} // namespace base + +#endif // BASE_METRICS_STATS_TABLE_H_ diff --git a/base/stats_table_unittest.cc b/base/metrics/stats_table_unittest.cc index f926f29..c9eb9a2 100644 --- a/base/stats_table_unittest.cc +++ b/base/metrics/stats_table_unittest.cc @@ -1,17 +1,12 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#if defined(OS_WIN) -#include <process.h> -#include <windows.h> -#endif - #include "base/platform_thread.h" #include "base/simple_thread.h" #include "base/shared_memory.h" -#include "base/stats_table.h" -#include "base/stats_counters.h" +#include "base/metrics/stats_table.h" +#include "base/metrics/stats_counters.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/test/multiprocess_test.h" @@ -24,7 +19,7 @@ namespace base { class StatsTableTest : public MultiProcessTest { public: void DeleteShmem(const std::string& name) { - base::SharedMemory mem; + SharedMemory mem; mem.Delete(name); } }; @@ -77,10 +72,11 @@ const std::string kCounterMixed = "CounterMixed"; // The number of thread loops that we will do. const int kThreadLoops = 100; -class StatsTableThread : public base::SimpleThread { +class StatsTableThread : public SimpleThread { public: StatsTableThread(std::string name, int id) - : base::SimpleThread(name), id_(id) { } + : SimpleThread(name), + id_(id) {} virtual void Run(); private: int id_; @@ -208,13 +204,13 @@ TEST_F(StatsTableTest, FLAKY_MultipleProcesses) { // Spawn the processes. for (int16 index = 0; index < kMaxProcs; index++) { procs[index] = this->SpawnChild("StatsTableMultipleProcessMain", false); - EXPECT_NE(base::kNullProcessHandle, procs[index]); + EXPECT_NE(kNullProcessHandle, procs[index]); } // Wait for the processes to finish. for (int index = 0; index < kMaxProcs; index++) { EXPECT_TRUE(WaitForSingleProcess(procs[index], 60 * 1000)); - base::CloseProcessHandle(procs[index]); + CloseProcessHandle(procs[index]); } StatsCounter zero_counter(kCounterZero); diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 9b62b26..4b701e9 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -14,8 +14,8 @@ #include "base/command_line.h" #include "base/debug_util.h" -#include "base/histogram.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/scoped_handle_win.h" #include "base/scoped_ptr.h" #include "base/win_util.h" diff --git a/base/worker_pool_mac.mm b/base/worker_pool_mac.mm index b9d4192..a301bf8 100644 --- a/base/worker_pool_mac.mm +++ b/base/worker_pool_mac.mm @@ -1,16 +1,16 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/worker_pool_mac.h" -#include "base/third_party/dynamic_annotations/dynamic_annotations.h" -#include "base/histogram.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #import "base/scoped_nsautorelease_pool.h" #include "base/scoped_ptr.h" #import "base/singleton_objc.h" #include "base/task.h" +#include "base/third_party/dynamic_annotations/dynamic_annotations.h" // When C++ exceptions are disabled, the C++ library defines |try| and // |catch| so as to allow exception-expecting C++ code to build properly when |