Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: src/counters.h

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/conversions.cc ('k') | src/counters.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.h
===================================================================
--- src/counters.h (revision 7267)
+++ src/counters.h (working copy)
@@ -38,27 +38,27 @@
// counters for monitoring. Counters can be looked up and
// manipulated by name.
-class StatsTable : public AllStatic {
+class StatsTable {
public:
// Register an application-defined function where
// counters can be looked up.
- static void SetCounterFunction(CounterLookupCallback f) {
+ void SetCounterFunction(CounterLookupCallback f) {
lookup_function_ = f;
}
// Register an application-defined function to create
// a histogram for passing to the AddHistogramSample function
- static void SetCreateHistogramFunction(CreateHistogramCallback f) {
+ void SetCreateHistogramFunction(CreateHistogramCallback f) {
create_histogram_function_ = f;
}
// Register an application-defined function to add a sample
// to a histogram created with CreateHistogram function
- static void SetAddHistogramSampleFunction(AddHistogramSampleCallback f) {
+ void SetAddHistogramSampleFunction(AddHistogramSampleCallback f) {
add_histogram_sample_function_ = f;
}
- static bool HasCounterFunction() {
+ bool HasCounterFunction() const {
return lookup_function_ != NULL;
}
@@ -68,7 +68,7 @@
// may receive a different location to store it's counter.
// The return value must not be cached and re-used across
// threads, although a single thread is free to cache it.
- static int* FindLocation(const char* name) {
+ int* FindLocation(const char* name) {
if (!lookup_function_) return NULL;
return lookup_function_(name);
}
@@ -78,25 +78,31 @@
// function. min and max define the expected minimum and maximum
// sample values. buckets is the maximum number of buckets
// that the samples will be grouped into.
- static void* CreateHistogram(const char* name,
- int min,
- int max,
- size_t buckets) {
+ void* CreateHistogram(const char* name,
+ int min,
+ int max,
+ size_t buckets) {
if (!create_histogram_function_) return NULL;
return create_histogram_function_(name, min, max, buckets);
}
// Add a sample to a histogram created with the CreateHistogram
// function.
- static void AddHistogramSample(void* histogram, int sample) {
+ void AddHistogramSample(void* histogram, int sample) {
if (!add_histogram_sample_function_) return;
return add_histogram_sample_function_(histogram, sample);
}
private:
- static CounterLookupCallback lookup_function_;
- static CreateHistogramCallback create_histogram_function_;
- static AddHistogramSampleCallback add_histogram_sample_function_;
+ StatsTable();
+
+ CounterLookupCallback lookup_function_;
+ CreateHistogramCallback create_histogram_function_;
+ AddHistogramSampleCallback add_histogram_sample_function_;
+
+ friend class Isolate;
+
+ DISALLOW_COPY_AND_ASSIGN(StatsTable);
};
// StatsCounters are dynamically created values which can be tracked in
@@ -166,9 +172,12 @@
if (lookup_done_)
return ptr_;
lookup_done_ = true;
- ptr_ = StatsTable::FindLocation(name_);
+ ptr_ = FindLocationInStatsTable();
return ptr_;
}
+
+ private:
+ int* FindLocationInStatsTable() const;
};
// StatsCounterTimer t = { { L"t:foo", NULL, false }, 0, 0 };
@@ -216,10 +225,13 @@
void* GetHistogram() {
if (!lookup_done_) {
lookup_done_ = true;
- histogram_ = StatsTable::CreateHistogram(name_, 0, 10000, 50);
+ histogram_ = CreateHistogram();
}
return histogram_;
}
+
+ private:
+ void* CreateHistogram() const;
};
// Helper class for scoping a HistogramTimer.
« no previous file with comments | « src/conversions.cc ('k') | src/counters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698