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

Unified Diff: net/base/file_stream_metrics.cc

Issue 7583049: Record UMA statistics for file_stream operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Posix error. Created 9 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
Index: net/base/file_stream_metrics.cc
diff --git a/net/base/file_stream_metrics.cc b/net/base/file_stream_metrics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..52d81011ca2d46c8e1fbe53f81268c1f0f71d147
--- /dev/null
+++ b/net/base/file_stream_metrics.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2011 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 "net/base/file_stream_metrics.h"
+
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
+
+namespace net {
+
+namespace {
+
+void RecordFileErrorTypeCount(FileErrorSource source) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "FileErrorType.Counts", source, FILE_ERROR_SOURCE_COUNT);
+}
+
+} // namespace
+
+void RecordFileError(int error, FileErrorSource source, bool record) {
+ if (!record)
+ return;
+
+ RecordFileErrorTypeCount(source);
+
+ int bucket = GetErrorBucket(error);
cbentzel 2011/08/23 01:52:02 Rather than write logic to figure out which bucket
cbentzel 2011/08/30 14:48:23 As we discussed, I'm OK with the approach you took
+
+ static const int max_bucket = MaxBucket(); // Fixed value per platform.
+ static const int max_error = MaxError(); // Fixed value per platform.
+
+ switch(source) {
+ case FILE_ERROR_SOURCE_OPEN:
+ UMA_HISTOGRAM_ENUMERATION("FileError.Open", error, max_error);
cbentzel 2011/08/23 01:52:02 This should be Net.FileOpen_Error Net.FileOpen_E
ahendrickson 2011/08/31 19:39:52 Done.
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.Open", bucket, max_bucket);
+ break;
+
cbentzel 2011/08/23 01:52:02 Nit: most code I've seen doesn't have newlines bet
+ case FILE_ERROR_SOURCE_WRITE:
+ UMA_HISTOGRAM_ENUMERATION("FileError.Write", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.Write", bucket, max_bucket);
+ break;
+
+ case FILE_ERROR_SOURCE_READ:
+ UMA_HISTOGRAM_ENUMERATION("FileError.Read", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.Read", bucket, max_bucket);
+ break;
+
+ case FILE_ERROR_SOURCE_SEEK:
+ UMA_HISTOGRAM_ENUMERATION("FileError.Seek", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.Seek", bucket, max_bucket);
+ break;
+
+ case FILE_ERROR_SOURCE_FLUSH:
+ UMA_HISTOGRAM_ENUMERATION("FileError.Flush", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.Flush", bucket, max_bucket);
+ break;
+
+ case FILE_ERROR_SOURCE_SET_EOF:
+ UMA_HISTOGRAM_ENUMERATION("FileError.SetEof", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.SetEof", bucket, max_bucket);
+ break;
+
+ case FILE_ERROR_SOURCE_GET_SIZE:
+ UMA_HISTOGRAM_ENUMERATION("FileError.GetSize", error, max_error);
+ UMA_HISTOGRAM_ENUMERATION("FileErrorRange.GetSize", bucket, max_bucket);
+ break;
+
+ default:
+ break;
+ }
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698