1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright (c) 2012 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/basictypes.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
namespace net {
namespace {
const char* FileErrorSourceStrings[] = {
"OPEN",
"WRITE",
"READ",
"SEEK",
"FLUSH",
"SET_EOF",
"GET_SIZE"
};
COMPILE_ASSERT(ARRAYSIZE_UNSAFE(FileErrorSourceStrings) ==
FILE_ERROR_SOURCE_COUNT,
file_error_source_enum_has_changed);
void RecordFileErrorTypeCount(FileErrorSource source) {
UMA_HISTOGRAM_ENUMERATION(
"Net.FileErrorType_Counts", source, FILE_ERROR_SOURCE_COUNT);
}
} // namespace
void RecordFileError(int error, FileErrorSource source, bool record) {
LOG(ERROR) << " " << __FUNCTION__ << "()"
<< " error = " << error
<< " source = " << source
<< " record = " << record;
if (!record)
return;
RecordFileErrorTypeCount(source);
int bucket = GetFileErrorUmaBucket(error);
// Fixed values per platform.
static const int max_bucket = MaxFileErrorUmaBucket();
static const int max_error = MaxFileErrorUmaValue();
switch(source) {
case FILE_ERROR_SOURCE_OPEN:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_Open", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_Open", bucket, max_bucket);
break;
case FILE_ERROR_SOURCE_WRITE:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_Write", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_Write", bucket, max_bucket);
break;
case FILE_ERROR_SOURCE_READ:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_Read", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_Read", bucket, max_bucket);
break;
case FILE_ERROR_SOURCE_SEEK:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_Seek", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_Seek", bucket, max_bucket);
break;
case FILE_ERROR_SOURCE_FLUSH:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_Flush", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_Flush", bucket, max_bucket);
break;
case FILE_ERROR_SOURCE_SET_EOF:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_SetEof", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_SetEof", bucket,
max_bucket);
break;
case FILE_ERROR_SOURCE_GET_SIZE:
UMA_HISTOGRAM_ENUMERATION("Net.FileError_GetSize", error, max_error);
UMA_HISTOGRAM_ENUMERATION("Net.FileErrorRange_GetSize", bucket,
max_bucket);
break;
default:
break;
}
}
const char* GetFileErrorSourceName(FileErrorSource source) {
DCHECK_NE(FILE_ERROR_SOURCE_COUNT, source);
return FileErrorSourceStrings[source];
}
} // namespace net
|