summaryrefslogtreecommitdiffstats
path: root/base/metrics
diff options
context:
space:
mode:
Diffstat (limited to 'base/metrics')
-rw-r--r--base/metrics/field_trial.h8
-rw-r--r--base/metrics/histogram.cc20
-rw-r--r--base/metrics/histogram.h24
-rw-r--r--base/metrics/stats_table.cc4
-rw-r--r--base/metrics/stats_table.h9
-rw-r--r--base/metrics/stats_table_unittest.cc8
6 files changed, 38 insertions, 35 deletions
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 1f0af9e..8902077 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -217,12 +217,12 @@ class FieldTrialList {
static size_t GetFieldTrialCount();
private:
- // Helper function should be called only while holding lock_.
- FieldTrial* PreLockedFind(const std::string& name);
-
// A map from FieldTrial names to the actual instances.
typedef std::map<std::string, FieldTrial*> RegistrationList;
+ // Helper function should be called only while holding lock_.
+ FieldTrial* PreLockedFind(const std::string& name);
+
static FieldTrialList* global_; // The singleton of this class.
// This will tell us if there is an attempt to register a field trial without
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 75df12e..1526cd8 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -14,10 +14,10 @@
#include <algorithm>
#include <string>
-#include "base/lock.h"
#include "base/logging.h"
#include "base/pickle.h"
#include "base/stringprintf.h"
+#include "base/synchronization/lock.h"
namespace base {
@@ -911,9 +911,9 @@ StatisticsRecorder::StatisticsRecorder() {
// during the termination phase. Since it's a static data member, we will
// leak one per process, which would be similar to the instance allocated
// during static initialization and released only on process termination.
- lock_ = new Lock;
+ lock_ = new base::Lock;
}
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
histograms_ = new HistogramMap;
}
@@ -928,7 +928,7 @@ StatisticsRecorder::~StatisticsRecorder() {
// Clean up.
HistogramMap* histograms = NULL;
{
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
histograms = histograms_;
histograms_ = NULL;
}
@@ -941,7 +941,7 @@ StatisticsRecorder::~StatisticsRecorder() {
bool StatisticsRecorder::IsActive() {
if (lock_ == NULL)
return false;
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
return NULL != histograms_;
}
@@ -954,7 +954,7 @@ bool StatisticsRecorder::IsActive() {
void StatisticsRecorder::Register(Histogram* histogram) {
if (lock_ == NULL)
return;
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
if (!histograms_)
return;
const std::string name = histogram->histogram_name();
@@ -1011,7 +1011,7 @@ void StatisticsRecorder::WriteGraph(const std::string& query,
void StatisticsRecorder::GetHistograms(Histograms* output) {
if (lock_ == NULL)
return;
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
if (!histograms_)
return;
for (HistogramMap::iterator it = histograms_->begin();
@@ -1026,7 +1026,7 @@ bool StatisticsRecorder::FindHistogram(const std::string& name,
scoped_refptr<Histogram>* histogram) {
if (lock_ == NULL)
return false;
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
if (!histograms_)
return false;
HistogramMap::iterator it = histograms_->find(name);
@@ -1041,7 +1041,7 @@ void StatisticsRecorder::GetSnapshot(const std::string& query,
Histograms* snapshot) {
if (lock_ == NULL)
return;
- AutoLock auto_lock(*lock_);
+ base::AutoLock auto_lock(*lock_);
if (!histograms_)
return;
for (HistogramMap::iterator it = histograms_->begin();
@@ -1055,7 +1055,7 @@ void StatisticsRecorder::GetSnapshot(const std::string& query,
// static
StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL;
// static
-Lock* StatisticsRecorder::lock_ = NULL;
+base::Lock* StatisticsRecorder::lock_ = NULL;
// static
bool StatisticsRecorder::dump_on_exit_ = false;
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index 6b09aa3..3bb3f03 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -41,11 +41,12 @@
#include "base/logging.h"
#include "base/time.h"
-class Lock;
class Pickle;
namespace base {
+class Lock;
+
//------------------------------------------------------------------------------
// Provide easy general purpose histogram in a macro, just like stats counters.
// The first four macros use 50 buckets.
@@ -541,11 +542,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
// buckets.
class LinearHistogram : public Histogram {
public:
- virtual ClassType histogram_type() const;
-
- // Store a list of number/text values for use in rendering the histogram.
- // The last element in the array has a null in its "description" slot.
- virtual void SetRangeDescriptions(const DescriptionPair descriptions[]);
+ virtual ~LinearHistogram();
/* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit
default underflow bucket. */
@@ -555,7 +552,12 @@ class LinearHistogram : public Histogram {
TimeDelta minimum, TimeDelta maximum, size_t bucket_count,
Flags flags);
- virtual ~LinearHistogram();
+ // Overridden from Histogram:
+ virtual ClassType histogram_type() const;
+
+ // Store a list of number/text values for use in rendering the histogram.
+ // The last element in the array has a null in its "description" slot.
+ virtual void SetRangeDescriptions(const DescriptionPair descriptions[]);
protected:
LinearHistogram(const std::string& name, Sample minimum,
@@ -609,11 +611,13 @@ class BooleanHistogram : public LinearHistogram {
// CustomHistogram is a histogram for a set of custom integers.
class CustomHistogram : public Histogram {
public:
- virtual ClassType histogram_type() const;
static scoped_refptr<Histogram> FactoryGet(const std::string& name,
const std::vector<Sample>& custom_ranges, Flags flags);
+ // Overridden from Histogram:
+ virtual ClassType histogram_type() const;
+
protected:
CustomHistogram(const std::string& name,
const std::vector<Sample>& custom_ranges);
@@ -681,7 +685,7 @@ class StatisticsRecorder {
static HistogramMap* histograms_;
// lock protects access to the above map.
- static Lock* lock_;
+ static base::Lock* lock_;
// Dump all known histograms to log.
static bool dump_on_exit_;
diff --git a/base/metrics/stats_table.cc b/base/metrics/stats_table.cc
index bf93395..757c08e 100644
--- a/base/metrics/stats_table.cc
+++ b/base/metrics/stats_table.cc
@@ -5,13 +5,13 @@
#include "base/metrics/stats_table.h"
#include "base/logging.h"
-#include "base/platform_thread.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
#include "base/shared_memory.h"
#include "base/string_piece.h"
#include "base/string_util.h"
-#include "base/thread_local_storage.h"
+#include "base/threading/platform_thread.h"
+#include "base/threading/thread_local_storage.h"
#include "base/utf_string_conversions.h"
#if defined(OS_POSIX)
diff --git a/base/metrics/stats_table.h b/base/metrics/stats_table.h
index e83039c..32b22eb 100644
--- a/base/metrics/stats_table.h
+++ b/base/metrics/stats_table.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
//
@@ -26,7 +26,7 @@
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/lock.h"
-#include "base/thread_local_storage.h"
+#include "base/threading/thread_local_storage.h"
namespace base {
@@ -132,6 +132,7 @@ class StatsTable {
private:
class Private;
struct TLSData;
+ typedef hash_map<std::string, int> CountersMap;
// Returns the space occupied by a thread in the table. Generally used
// if a thread terminates but the process continues. This function
@@ -171,8 +172,6 @@ class StatsTable {
// initialized.
TLSData* GetTLSData() const;
- typedef hash_map<std::string, int> CountersMap;
-
Private* impl_;
// The counters_lock_ protects the counters_ hash table.
@@ -184,7 +183,7 @@ class StatsTable {
// we don't have a counter in our hash table, another process may
// have created it.
CountersMap counters_;
- TLSSlot tls_index_;
+ ThreadLocalStorage::Slot tls_index_;
static StatsTable* global_table_;
diff --git a/base/metrics/stats_table_unittest.cc b/base/metrics/stats_table_unittest.cc
index c9eb9a2..944813d 100644
--- a/base/metrics/stats_table_unittest.cc
+++ b/base/metrics/stats_table_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/platform_thread.h"
-#include "base/simple_thread.h"
-#include "base/shared_memory.h"
-#include "base/metrics/stats_table.h"
#include "base/metrics/stats_counters.h"
+#include "base/metrics/stats_table.h"
+#include "base/shared_memory.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/test/multiprocess_test.h"
+#include "base/threading/platform_thread.h"
+#include "base/threading/simple_thread.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"