summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 22:29:29 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-10 22:29:29 +0000
commite6f02aba72e297560ece0e79d165abf4c49149ff (patch)
tree95fb68ad511b0ac62e2532c47f46362afff39f88
parentcaae50cacfe0304045b9a961af797e3cf38bde23 (diff)
downloadchromium_src-e6f02aba72e297560ece0e79d165abf4c49149ff.zip
chromium_src-e6f02aba72e297560ece0e79d165abf4c49149ff.tar.gz
chromium_src-e6f02aba72e297560ece0e79d165abf4c49149ff.tar.bz2
Remove histogram connection to base classes in stats_counter
Now that histograms move data from renderer to browser, there is less reason to connect to stats counters. Stats counters were using shared memory, and now they may plausibly use the histogram's IPC mechanism instead to move data to the browser. The first step is remove the inheritance, and teh next (plausible/future) step would be to implement counters as histograms with only one bucket. r=mbelshe Review URL: http://codereview.chromium.org/66029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13544 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/histogram.cc10
-rw-r--r--base/histogram.h15
-rw-r--r--chrome/app/chrome_dll_main.cc1
-rw-r--r--chrome/browser/spellchecker.cc1
-rw-r--r--chrome/common/ipc_channel_posix.cc1
-rw-r--r--chrome/common/ipc_channel_win.cc1
-rw-r--r--chrome/renderer/renderer_main.cc1
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h1
8 files changed, 17 insertions, 14 deletions
diff --git a/base/histogram.cc b/base/histogram.cc
index d1568429..687a549 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -25,8 +25,7 @@ const int Histogram::kHexRangePrintingFlag = 0x8000;
Histogram::Histogram(const char* name, Sample minimum,
Sample maximum, size_t bucket_count)
- : StatsRate(name),
- histogram_name_(name),
+ : histogram_name_(name),
declared_min_(minimum),
declared_max_(maximum),
bucket_count_(bucket_count),
@@ -39,8 +38,7 @@ Histogram::Histogram(const char* name, Sample minimum,
Histogram::Histogram(const char* name, TimeDelta minimum,
TimeDelta maximum, size_t bucket_count)
- : StatsRate(name),
- histogram_name_(name),
+ : histogram_name_(name),
declared_min_(static_cast<int> (minimum.InMilliseconds())),
declared_max_(static_cast<int> (maximum.InMilliseconds())),
bucket_count_(bucket_count),
@@ -58,14 +56,11 @@ Histogram::~Histogram() {
DCHECK(ValidateBucketRanges());
}
-// Hooks to override stats counter methods. This ensures that we gather all
-// input the stats counter sees.
void Histogram::Add(int value) {
if (!registered_)
registered_ = StatisticsRecorder::Register(this);
if (value >= kSampleType_MAX)
value = kSampleType_MAX - 1;
- StatsRate::Add(value);
if (value < 0)
value = 0;
size_t index = BucketIndex(value);
@@ -631,7 +626,6 @@ ThreadSafeHistogram::ThreadSafeHistogram(const char* name, Sample minimum,
void ThreadSafeHistogram::Remove(int value) {
if (value >= kSampleType_MAX)
value = kSampleType_MAX - 1;
- StatsRate::Add(-value);
size_t index = BucketIndex(value);
Accumulate(value, -1, index);
}
diff --git a/base/histogram.h b/base/histogram.h
index 0773a7a..59981ea 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -36,7 +36,7 @@
#include <vector>
#include "base/lock.h"
-#include "base/stats_counters.h"
+#include "base/time.h"
//------------------------------------------------------------------------------
// Provide easy general purpose histogram in a macro, just like stats counters.
@@ -203,7 +203,7 @@ static const int kRendererHistogramFlag = 1 << 4;
class Pickle;
-class Histogram : public StatsRate {
+class Histogram {
public:
typedef int Sample; // Used for samples (and ranges of samples).
typedef int Count; // Used to count samples in a bucket.
@@ -263,9 +263,11 @@ class Histogram : public StatsRate {
base::TimeDelta maximum, size_t bucket_count);
virtual ~Histogram();
- // Hooks to override stats counter methods. This ensures that we gather all
- // input the stats counter sees.
- virtual void Add(int value);
+ void Add(int value);
+ // Accept a TimeDelta to increment.
+ void AddTime(base::TimeDelta time) {
+ Add(static_cast<int>(time.InMilliseconds()));
+ }
void AddSampleSet(const SampleSet& sample);
@@ -465,7 +467,7 @@ class BooleanHistogram : public LinearHistogram {
: LinearHistogram(name, 0, 2, 3) {
}
- virtual void AddBoolean(bool value) { Add(value ? 1 : 0); }
+ void AddBoolean(bool value) { Add(value ? 1 : 0); }
private:
DISALLOW_COPY_AND_ASSIGN(BooleanHistogram);
@@ -526,6 +528,7 @@ class StatisticsRecorder {
// Method for extracting histograms which were marked for use by UMA.
static void GetHistograms(Histograms* output);
+ // Find a histogram by name. This method is thread safe.
static Histogram* GetHistogram(const std::string& query);
static void set_dump_on_exit(bool enable) { dump_on_exit_ = enable; }
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 547e3fa..00ee793 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -32,6 +32,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/scoped_nsautorelease_pool.h"
+#include "base/stats_counters.h"
#include "base/stats_table.h"
#include "base/string_util.h"
#if defined(OS_WIN)
diff --git a/chrome/browser/spellchecker.cc b/chrome/browser/spellchecker.cc
index 39aec18..91fc9c7 100644
--- a/chrome/browser/spellchecker.cc
+++ b/chrome/browser/spellchecker.cc
@@ -9,6 +9,7 @@
#include "base/histogram.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/stats_counters.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc
index 23c008a..71a1f44 100644
--- a/chrome/common/ipc_channel_posix.cc
+++ b/chrome/common/ipc_channel_posix.cc
@@ -22,6 +22,7 @@
#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "base/singleton.h"
+#include "base/stats_counters.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/file_descriptor_set_posix.h"
diff --git a/chrome/common/ipc_channel_win.cc b/chrome/common/ipc_channel_win.cc
index 38e442a..d4e7c31 100644
--- a/chrome/common/ipc_channel_win.cc
+++ b/chrome/common/ipc_channel_win.cc
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/non_thread_safe.h"
+#include "base/stats_counters.h"
#include "base/win_util.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/ipc_logging.h"
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index c6637ab..2295edb 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -9,6 +9,7 @@
#include "base/platform_thread.h"
#include "base/process_util.h"
#include "base/scoped_nsautorelease_pool.h"
+#include "base/stats_counters.h"
#include "base/string_util.h"
#include "base/system_monitor.h"
#include "chrome/common/chrome_constants.h"
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 6bba743..013d46f 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_
+#include "base/stats_counters.h"
#include "base/string_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"