Index: storage/common/storage_histograms.cc |
diff --git a/storage/common/storage_histograms.cc b/storage/common/storage_histograms.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..adb99124fc37f696fcbd83bcda8087d547431d54 |
--- /dev/null |
+++ b/storage/common/storage_histograms.cc |
@@ -0,0 +1,36 @@ |
+// Copyright 2017 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. |
+ |
+#include "storage/common/storage_histograms.h" |
+ |
+#include "base/metrics/histogram_macros.h" |
+ |
+namespace storage { |
+ |
+namespace { |
+ |
+base::HistogramBase* GetBytesCountHistogram(const std::string& name) { |
+ const int kMin = 1; |
+ const int kMax = 10000000; |
+ const int kNumBuckets = 50; |
+ return base::Histogram::FactoryGet( |
+ name, kMin, kMax, kNumBuckets, |
+ base::Histogram::kUmaTargetedHistogramFlag); |
Ilya Sherman
2017/05/19 00:17:14
nit: Could you use base::UmaHistogramCustomCounts
michaeln
2017/05/19 01:22:05
yes, thats much better, thank you :)
|
+} |
+ |
+} // anonomous namespace |
+ |
+void RecordBytesWritten(const char* label, int amount) { |
+ std::string name("Storage.BytesWritten."); |
+ name.append(label); |
Ilya Sherman
2017/05/19 00:17:14
Optional nit: It might be cleaner to pass the labe
michaeln
2017/05/19 01:22:05
i'd rather not have to construct a string at each
|
+ GetBytesCountHistogram(name)->Add(amount); |
+} |
+ |
+void RecordBytesRead(const char* label, int amount) { |
+ std::string name("Storage.BytesRead."); |
+ name.append(label); |
+ GetBytesCountHistogram(name)->Add(amount); |
+} |
+ |
+} // namespace storage |