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

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: Simplified the UMA error statistics gathering. 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..b79a2fa7c106a0004729ad732ae05f26faa459b6
--- /dev/null
+++ b/net/base/file_stream_metrics.cc
@@ -0,0 +1,84 @@
+// 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 <string>
+#if defined(OS_WIN)
+#include <windows.h>
cbentzel 2011/08/16 13:36:02 You shouldn't need to include windows.h here.
ahendrickson 2011/08/17 20:12:04 Done.
+#endif
+
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
+#include "net/base/file_stream.h"
cbentzel 2011/08/16 13:36:02 You shouldn't need to include file_stream.h either
ahendrickson 2011/08/17 20:12:04 Done.
+
+namespace net {
+
+namespace {
+
+void RecordFileErrorTypeCount(FileErrorSource type) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "FileErrorType.Counts", type, FILE_ERROR_SOURCE_COUNT);
+}
+
+} // namespace
+
+void RecordFileError(int error, FileErrorSource type) {
+ RecordFileErrorTypeCount(type);
+
+ DLOG(WARNING) << "() " << "Recording error " << error
cbentzel 2011/08/16 13:36:02 Remove this.
ahendrickson 2011/08/17 20:12:04 Done.
+ << " of type " << type;
+
+ unsigned int max_error = (1U << 14) - 2; // Histogram limit.
+
+ error = ReduceErrorRange(error);
+ max_error = MaxError();
cbentzel 2011/08/16 13:36:02 You might want to document that this can never cha
ahendrickson 2011/08/17 20:12:04 Done.
+
+ switch(type) {
+ case FILE_ERROR_SOURCE_IS_NOT_OPEN:
+ {
cbentzel 2011/08/16 13:36:02 Nit: Do you need these braces? May be less vertica
ahendrickson 2011/08/17 20:12:04 Done.
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.NotOpen", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_OPEN:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.Open", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_WRITE:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.Write", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_READ:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.Read", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_SEEK:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.Seek", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_FLUSH:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.Flush", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_SET_EOF:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.SetEof", error, max_error);
+ break;
+ }
+ case FILE_ERROR_SOURCE_GET_SIZE:
+ {
+ UMA_HISTOGRAM_ENUMERATION("FileErrorSource.GetSize", error, max_error);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698