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

Unified Diff: counter.cc

Issue 3181015: Add # daily crashes metrics and separate kernel crashes out. (Closed) Base URL: ssh://git@chromiumos-git//metrics.git
Patch Set: Respond to review Created 10 years, 4 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 | « counter.h ('k') | counter_mock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: counter.cc
diff --git a/counter.cc b/counter.cc
index b81a0d1beb9f9b93183148d30c90f93c198e1fc0..4de1db1051fb7570d07f5413b04adee46b87a49d 100644
--- a/counter.cc
+++ b/counter.cc
@@ -183,4 +183,32 @@ void TaggedCounter::WriteRecord(int fd) {
}
}
+FrequencyCounter::FrequencyCounter() : cycle_duration_(1) {
+}
+
+FrequencyCounter::~FrequencyCounter() {
+}
+
+void FrequencyCounter::Init(const char* filename,
+ TaggedCounterInterface::Reporter reporter,
+ void* reporter_handle,
+ time_t cycle_duration) {
+ // Allow tests to inject tagged_counter_ dependency.
+ if (tagged_counter_.get() == NULL) {
+ tagged_counter_.reset(new TaggedCounter());
+ }
+ tagged_counter_->Init(filename, reporter, reporter_handle);
+ DCHECK(cycle_duration > 0);
+ cycle_duration_ = cycle_duration;
+}
+
+void FrequencyCounter::UpdateInternal(int32 count, time_t now) {
+ DCHECK(tagged_counter_.get() != NULL);
+ tagged_counter_->Update(GetCycleNumber(now), count);
+}
+
+int32 FrequencyCounter::GetCycleNumber(time_t now) {
+ return now / cycle_duration_;
+}
+
} // namespace chromeos_metrics
« no previous file with comments | « counter.h ('k') | counter_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698