summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authordsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 19:08:23 +0000
committerdsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 19:08:23 +0000
commit553dba6dd707ee02e609910462d2b7977f284af2 (patch)
treec38ea1fbfb3a1d387134541faa9bdfc0720234cf /base
parent0e7fe5cab991f8751ecaa6cd43ff7e51d9647dde (diff)
downloadchromium_src-553dba6dd707ee02e609910462d2b7977f284af2.zip
chromium_src-553dba6dd707ee02e609910462d2b7977f284af2.tar.gz
chromium_src-553dba6dd707ee02e609910462d2b7977f284af2.tar.bz2
Use string for Histogram names since these are all ASCII anyway.
Wide-character literals cause problems between platforms. Review URL: http://codereview.chromium.org/28046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/histogram.cc19
-rw-r--r--base/histogram.h13
-rw-r--r--base/histogram_unittest.cc61
-rw-r--r--base/message_loop.cc10
-rw-r--r--base/message_pump_win.cc2
-rw-r--r--base/process_util_win.cc6
6 files changed, 53 insertions, 58 deletions
diff --git a/base/histogram.cc b/base/histogram.cc
index 173cf40..79e9497 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -23,10 +23,10 @@ typedef Histogram::Count Count;
// static
const int Histogram::kHexRangePrintingFlag = 0x8000;
-Histogram::Histogram(const wchar_t* name, Sample minimum,
+Histogram::Histogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count)
- : StatsRate(WideToASCII(name).c_str()),
- histogram_name_(WideToASCII(name)),
+ : StatsRate(name),
+ histogram_name_(name),
declared_min_(minimum),
declared_max_(maximum),
bucket_count_(bucket_count),
@@ -37,10 +37,10 @@ Histogram::Histogram(const wchar_t* name, Sample minimum,
Initialize();
}
-Histogram::Histogram(const wchar_t* name, TimeDelta minimum,
+Histogram::Histogram(const char* name, TimeDelta minimum,
TimeDelta maximum, size_t bucket_count)
- : StatsRate(WideToASCII(name).c_str()),
- histogram_name_(WideToASCII(name)),
+ : StatsRate(name),
+ histogram_name_(name),
declared_min_(static_cast<int> (minimum.InMilliseconds())),
declared_max_(static_cast<int> (maximum.InMilliseconds())),
bucket_count_(bucket_count),
@@ -415,14 +415,14 @@ void Histogram::SampleSet::Subtract(const SampleSet& other) {
// buckets.
//------------------------------------------------------------------------------
-LinearHistogram::LinearHistogram(const wchar_t* name,
+LinearHistogram::LinearHistogram(const char* name,
Sample minimum, Sample maximum, size_t bucket_count)
: Histogram(name, minimum >= 1 ? minimum : 1, maximum, bucket_count) {
InitializeBucketRange();
DCHECK(ValidateBucketRanges());
}
-LinearHistogram::LinearHistogram(const wchar_t* name,
+LinearHistogram::LinearHistogram(const char* name,
TimeDelta minimum, TimeDelta maximum, size_t bucket_count)
: Histogram(name, minimum >= TimeDelta::FromMilliseconds(1) ?
minimum : TimeDelta::FromMilliseconds(1),
@@ -487,7 +487,7 @@ double LinearHistogram::GetBucketSize(Count current, size_t i) const {
// This section provides implementation for ThreadSafeHistogram.
//------------------------------------------------------------------------------
-ThreadSafeHistogram::ThreadSafeHistogram(const wchar_t* name, Sample minimum,
+ThreadSafeHistogram::ThreadSafeHistogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count)
: Histogram(name, minimum, maximum, bucket_count),
lock_() {
@@ -650,4 +650,3 @@ StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
Lock* StatisticsRecorder::lock_ = NULL;
// static
bool StatisticsRecorder::dump_on_exit_ = false;
-
diff --git a/base/histogram.h b/base/histogram.h
index 624f80a..cf80c09 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -218,9 +218,9 @@ class Histogram : public StatsRate {
};
//----------------------------------------------------------------------------
- Histogram(const wchar_t* name, Sample minimum,
+ Histogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count);
- Histogram(const wchar_t* name, base::TimeDelta minimum,
+ Histogram(const char* name, base::TimeDelta minimum,
base::TimeDelta maximum, size_t bucket_count);
virtual ~Histogram();
@@ -357,9 +357,9 @@ class LinearHistogram : public Histogram {
Sample sample;
const char* description; // Null means end of a list of pairs.
};
- LinearHistogram(const wchar_t* name, Sample minimum,
+ LinearHistogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count);
- LinearHistogram(const wchar_t* name, base::TimeDelta minimum,
+ LinearHistogram(const char* name, base::TimeDelta minimum,
base::TimeDelta maximum, size_t bucket_count);
~LinearHistogram() {}
@@ -397,7 +397,7 @@ class LinearHistogram : public Histogram {
// BooleanHistogram is a histogram for booleans.
class BooleanHistogram : public LinearHistogram {
public:
- explicit BooleanHistogram(const wchar_t* name)
+ explicit BooleanHistogram(const char* name)
: LinearHistogram(name, 0, 2, 3) {
}
@@ -413,7 +413,7 @@ class BooleanHistogram : public LinearHistogram {
class ThreadSafeHistogram : public Histogram {
public:
- ThreadSafeHistogram(const wchar_t* name, Sample minimum,
+ ThreadSafeHistogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count);
// Provide the analog to Add()
@@ -485,4 +485,3 @@ class StatisticsRecorder {
};
#endif // BASE_HISTOGRAM_H__
-
diff --git a/base/histogram_unittest.cc b/base/histogram_unittest.cc
index 7085f97..b54ad7f 100644
--- a/base/histogram_unittest.cc
+++ b/base/histogram_unittest.cc
@@ -20,20 +20,20 @@ class HistogramTest : public testing::Test {
// Check for basic syntax and use.
TEST(HistogramTest, StartupShutdownTest) {
// Try basic construction
- Histogram histogram(L"TestHistogram", 1, 1000, 10);
- Histogram histogram1(L"Test1Histogram", 1, 1000, 10);
+ Histogram histogram("TestHistogram", 1, 1000, 10);
+ Histogram histogram1("Test1Histogram", 1, 1000, 10);
- LinearHistogram linear_histogram(L"TestLinearHistogram", 1, 1000, 10);
- LinearHistogram linear_histogram1(L"Test1LinearHistogram", 1, 1000, 10);
+ LinearHistogram linear_histogram("TestLinearHistogram", 1, 1000, 10);
+ LinearHistogram linear_histogram1("Test1LinearHistogram", 1, 1000, 10);
// Use standard macros (but with fixed samples)
- HISTOGRAM_TIMES(L"Test2Histogram", TimeDelta::FromDays(1));
- HISTOGRAM_COUNTS(L"Test3Histogram", 30);
+ HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1));
+ HISTOGRAM_COUNTS("Test3Histogram", 30);
- DHISTOGRAM_TIMES(L"Test4Histogram", TimeDelta::FromDays(1));
- DHISTOGRAM_COUNTS(L"Test5Histogram", 30);
+ DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1));
+ DHISTOGRAM_COUNTS("Test5Histogram", 30);
- ASSET_HISTOGRAM_COUNTS(L"Test6Histogram", 129);
+ ASSET_HISTOGRAM_COUNTS("Test6Histogram", 129);
// Try to construct samples.
Histogram::SampleSet sample1;
@@ -58,35 +58,35 @@ TEST(HistogramTest, RecordedStartupTest) {
EXPECT_EQ(0U, histograms.size());
// Try basic construction
- Histogram histogram(L"TestHistogram", 1, 1000, 10);
+ Histogram histogram("TestHistogram", 1, 1000, 10);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
EXPECT_EQ(1U, histograms.size());
- Histogram histogram1(L"Test1Histogram", 1, 1000, 10);
+ Histogram histogram1("Test1Histogram", 1, 1000, 10);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
EXPECT_EQ(2U, histograms.size());
- LinearHistogram linear_histogram(L"TestLinearHistogram", 1, 1000, 10);
- LinearHistogram linear_histogram1(L"Test1LinearHistogram", 1, 1000, 10);
+ LinearHistogram linear_histogram("TestLinearHistogram", 1, 1000, 10);
+ LinearHistogram linear_histogram1("Test1LinearHistogram", 1, 1000, 10);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
EXPECT_EQ(4U, histograms.size());
// Use standard macros (but with fixed samples)
- HISTOGRAM_TIMES(L"Test2Histogram", TimeDelta::FromDays(1));
- HISTOGRAM_COUNTS(L"Test3Histogram", 30);
+ HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1));
+ HISTOGRAM_COUNTS("Test3Histogram", 30);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
EXPECT_EQ(6U, histograms.size());
- ASSET_HISTOGRAM_COUNTS(L"TestAssetHistogram", 1000);
+ ASSET_HISTOGRAM_COUNTS("TestAssetHistogram", 1000);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
EXPECT_EQ(7U, histograms.size());
- DHISTOGRAM_TIMES(L"Test4Histogram", TimeDelta::FromDays(1));
- DHISTOGRAM_COUNTS(L"Test5Histogram", 30);
+ DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1));
+ DHISTOGRAM_COUNTS("Test5Histogram", 30);
histograms.clear();
StatisticsRecorder::GetHistograms(&histograms); // Load up lists
#ifndef NDEBUG
@@ -103,7 +103,7 @@ TEST(HistogramTest, RangeTest) {
recorder.GetHistograms(&histograms);
EXPECT_EQ(0U, histograms.size());
- Histogram histogram(L"Histogram", 1, 64, 8); // As mentioned in header file.
+ Histogram histogram("Histogram", 1, 64, 8); // As mentioned in header file.
// Check that we got a nice exponential when there was enough rooom.
EXPECT_EQ(0, histogram.ranges(0));
int power_of_2 = 1;
@@ -113,26 +113,26 @@ TEST(HistogramTest, RangeTest) {
}
EXPECT_EQ(INT_MAX, histogram.ranges(8));
- Histogram short_histogram(L"Histogram Shortened", 1, 7, 8);
+ Histogram short_histogram("Histogram Shortened", 1, 7, 8);
// Check that when the number of buckets is short, we get a linear histogram
// for lack of space to do otherwise.
for (int i = 0; i < 8; i++)
EXPECT_EQ(i, short_histogram.ranges(i));
EXPECT_EQ(INT_MAX, short_histogram.ranges(8));
- LinearHistogram linear_histogram(L"Linear", 1, 7, 8);
+ LinearHistogram linear_histogram("Linear", 1, 7, 8);
// We also get a nice linear set of bucket ranges when we ask for it
for (int i = 0; i < 8; i++)
EXPECT_EQ(i, linear_histogram.ranges(i));
EXPECT_EQ(INT_MAX, linear_histogram.ranges(8));
- LinearHistogram linear_broad_histogram(L"Linear widened", 2, 14, 8);
+ LinearHistogram linear_broad_histogram("Linear widened", 2, 14, 8);
// ...but when the list has more space, then the ranges naturally spread out.
for (int i = 0; i < 8; i++)
EXPECT_EQ(2 * i, linear_broad_histogram.ranges(i));
EXPECT_EQ(INT_MAX, linear_broad_histogram.ranges(8));
- ThreadSafeHistogram threadsafe_histogram(L"ThreadSafe", 1, 32, 15);
+ ThreadSafeHistogram threadsafe_histogram("ThreadSafe", 1, 32, 15);
// When space is a little tight, we transition from linear to exponential.
// This is what happens in both the basic histogram, and the threadsafe
// variant (which is derived).
@@ -160,7 +160,7 @@ TEST(HistogramTest, RangeTest) {
// Make sure histogram handles out-of-bounds data gracefully.
TEST(HistogramTest, BoundsTest) {
const size_t kBucketCount = 50;
- Histogram histogram(L"Bounded", 10, 100, kBucketCount);
+ Histogram histogram("Bounded", 10, 100, kBucketCount);
// Put two samples "out of bounds" above and below.
histogram.Add(5);
@@ -182,7 +182,7 @@ TEST(HistogramTest, BoundsTest) {
// Check to be sure samples land as expected is "correct" buckets.
TEST(HistogramTest, BucketPlacementTest) {
- Histogram histogram(L"Histogram", 1, 64, 8); // As mentioned in header file.
+ Histogram histogram("Histogram", 1, 64, 8); // As mentioned in header file.
// Check that we got a nice exponential since there was enough rooom.
EXPECT_EQ(0, histogram.ranges(0));
@@ -211,8 +211,8 @@ TEST(HistogramTest, BucketPlacementTest) {
EXPECT_EQ(i + 1, sample.counts(i));
}
-static const wchar_t* kAssetTestHistogramName = L"AssetCountTest";
-static const wchar_t* kAssetTestDebugHistogramName = L"DAssetCountTest";
+static const char kAssetTestHistogramName[] = "AssetCountTest";
+static const char kAssetTestDebugHistogramName[] = "DAssetCountTest";
void AssetCountFunction(int sample) {
ASSET_HISTOGRAM_COUNTS(kAssetTestHistogramName, sample);
DASSET_HISTOGRAM_COUNTS(kAssetTestDebugHistogramName, sample);
@@ -229,16 +229,14 @@ TEST(HistogramTest, AssetCountTest) {
StatisticsRecorder::Histograms histogram_list;
StatisticsRecorder::GetHistograms(&histogram_list);
ASSERT_NE(0U, histogram_list.size());
- std::string ascii_name = WideToASCII(kAssetTestHistogramName);
- std::string debug_ascii_name = WideToASCII(kAssetTestDebugHistogramName);
const Histogram* our_histogram = NULL;
const Histogram* our_debug_histogram = NULL;
for (StatisticsRecorder::Histograms::iterator it = histogram_list.begin();
it != histogram_list.end();
++it) {
- if (!(*it)->histogram_name().compare(ascii_name))
+ if (!(*it)->histogram_name().compare(kAssetTestHistogramName))
our_histogram = *it;
- else if (!(*it)->histogram_name().compare(debug_ascii_name)) {
+ else if (!(*it)->histogram_name().compare(kAssetTestDebugHistogramName)) {
our_debug_histogram = *it;
}
}
@@ -294,4 +292,3 @@ TEST(HistogramTest, AssetCountTest) {
}
} // namespace
-
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 12ad3fa..a57946b 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -504,11 +504,11 @@ void MessageLoop::StartHistogrammer() {
if (enable_histogrammer_ && !message_histogram_.get()
&& StatisticsRecorder::WasStarted()) {
DCHECK(!thread_name_.empty());
- message_histogram_.reset(new LinearHistogram(
- ASCIIToWide("MsgLoop:" + thread_name_).c_str(),
- kLeastNonZeroMessageId,
- kMaxMessageId,
- kNumberOfDistinctMessagesDisplayed));
+ message_histogram_.reset(
+ new LinearHistogram(("MsgLoop:" + thread_name_).c_str(),
+ kLeastNonZeroMessageId,
+ kMaxMessageId,
+ kNumberOfDistinctMessagesDisplayed));
message_histogram_->SetFlags(message_histogram_->kHexRangePrintingFlag);
message_histogram_->SetRangeDescriptions(event_descriptions_);
}
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc
index ca5baa8..e415623 100644
--- a/base/message_pump_win.cc
+++ b/base/message_pump_win.cc
@@ -158,7 +158,7 @@ void MessagePumpForUI::PumpOutPendingPaintMessages() {
break;
}
// Histogram what was really being used, to help to adjust kMaxPeekCount.
- DHISTOGRAM_COUNTS(L"Loop.PumpOutPendingPaintMessages Peeks", peek_count);
+ DHISTOGRAM_COUNTS("Loop.PumpOutPendingPaintMessages Peeks", peek_count);
}
//-----------------------------------------------------------------------------
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 2edf5ec..34ec599 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -216,14 +216,14 @@ bool DidProcessCrash(ProcessHandle handle) {
const int kLeastValue = 0;
const int kMaxValue = 0xFFF;
const int kBucketCount = kMaxValue - kLeastValue + 1;
- static LinearHistogram least_significant_histogram(L"ExitCodes.LSNibbles",
+ static LinearHistogram least_significant_histogram("ExitCodes.LSNibbles",
kLeastValue + 1, kMaxValue, kBucketCount);
least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);
least_significant_histogram.Add(exitcode & 0xFFF);
// Histogram the high order 3 nibbles
- static LinearHistogram most_significant_histogram(L"ExitCodes.MSNibbles",
+ static LinearHistogram most_significant_histogram("ExitCodes.MSNibbles",
kLeastValue + 1, kMaxValue, kBucketCount);
most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);
@@ -231,7 +231,7 @@ bool DidProcessCrash(ProcessHandle handle) {
most_significant_histogram.Add((exitcode >> 20) & 0xFFF);
// Histogram the middle order 2 nibbles
- static LinearHistogram mid_significant_histogram(L"ExitCodes.MidNibbles",
+ static LinearHistogram mid_significant_histogram("ExitCodes.MidNibbles",
1, 0xFF, 0x100);
mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);