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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « counter.h ('k') | counter_mock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "counter.h" 5 #include "counter.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include <base/eintr_wrapper.h> 9 #include <base/eintr_wrapper.h>
10 #include <base/logging.h> 10 #include <base/logging.h>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 case kRecordNull: 176 case kRecordNull:
177 case kRecordValid: 177 case kRecordValid:
178 // Nothing to do. 178 // Nothing to do.
179 break; 179 break;
180 180
181 default: 181 default:
182 NOTREACHED(); 182 NOTREACHED();
183 } 183 }
184 } 184 }
185 185
186 FrequencyCounter::FrequencyCounter() : cycle_duration_(1) {
187 }
188
189 FrequencyCounter::~FrequencyCounter() {
190 }
191
192 void FrequencyCounter::Init(const char* filename,
193 TaggedCounterInterface::Reporter reporter,
194 void* reporter_handle,
195 time_t cycle_duration) {
196 // Allow tests to inject tagged_counter_ dependency.
197 if (tagged_counter_.get() == NULL) {
198 tagged_counter_.reset(new TaggedCounter());
199 }
200 tagged_counter_->Init(filename, reporter, reporter_handle);
201 DCHECK(cycle_duration > 0);
202 cycle_duration_ = cycle_duration;
203 }
204
205 void FrequencyCounter::UpdateInternal(int32 count, time_t now) {
206 DCHECK(tagged_counter_.get() != NULL);
207 tagged_counter_->Update(GetCycleNumber(now), count);
208 }
209
210 int32 FrequencyCounter::GetCycleNumber(time_t now) {
211 return now / cycle_duration_;
212 }
213
186 } // namespace chromeos_metrics 214 } // namespace chromeos_metrics
OLDNEW
« 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