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

Side by Side Diff: net/base/net_errors.cc

Issue 1140273002: Replace GetAllErrorCodesForUma calls with UMA_HISTOGRAM_SPARSE_SLOWLY. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fallback-type
Patch Set: asvitkine comment Created 5 years, 7 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 | « net/base/net_errors.h ('k') | net/dns/host_resolver_impl.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 "net/base/net_errors.h" 5 #include "net/base/net_errors.h"
6 6
7 #include "base/basictypes.h"
8 #include "base/metrics/histogram.h"
9 #include "base/strings/stringize_macros.h"
10
11 namespace {
12
13 // Get all valid error codes into an array as positive numbers, for use in the
14 // |GetAllErrorCodesForUma| function below.
15 #define NET_ERROR(label, value) -(value),
16 const int kAllErrorCodes[] = {
17 #include "net/base/net_error_list.h"
18 };
19 #undef NET_ERROR
20
21 } // namespace
22
23 namespace net { 7 namespace net {
24 8
25 const char kErrorDomain[] = "net"; 9 const char kErrorDomain[] = "net";
26 10
27 std::string ErrorToString(int error) { 11 std::string ErrorToString(int error) {
28 return "net::" + ErrorToShortString(error); 12 return "net::" + ErrorToShortString(error);
29 } 13 }
30 14
31 std::string ErrorToShortString(int error) { 15 std::string ErrorToShortString(int error) {
32 if (error == 0) 16 if (error == 0)
(...skipping 28 matching lines...) Expand all
61 case ERR_BAD_SSL_CLIENT_AUTH_CERT: 45 case ERR_BAD_SSL_CLIENT_AUTH_CERT:
62 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED: 46 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
63 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY: 47 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
64 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED: 48 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED:
65 return true; 49 return true;
66 default: 50 default:
67 return false; 51 return false;
68 } 52 }
69 } 53 }
70 54
71 std::vector<int> GetAllErrorCodesForUma() {
72 return base::CustomHistogram::ArrayToCustomRanges(
73 kAllErrorCodes, arraysize(kAllErrorCodes));
74 }
75
76 Error FileErrorToNetError(base::File::Error file_error) { 55 Error FileErrorToNetError(base::File::Error file_error) {
77 switch (file_error) { 56 switch (file_error) {
78 case base::File::FILE_OK: 57 case base::File::FILE_OK:
79 return OK; 58 return OK;
80 case base::File::FILE_ERROR_ACCESS_DENIED: 59 case base::File::FILE_ERROR_ACCESS_DENIED:
81 return ERR_ACCESS_DENIED; 60 return ERR_ACCESS_DENIED;
82 case base::File::FILE_ERROR_INVALID_URL: 61 case base::File::FILE_ERROR_INVALID_URL:
83 return ERR_INVALID_URL; 62 return ERR_INVALID_URL;
84 case base::File::FILE_ERROR_NOT_FOUND: 63 case base::File::FILE_ERROR_NOT_FOUND:
85 return ERR_FILE_NOT_FOUND; 64 return ERR_FILE_NOT_FOUND;
86 default: 65 default:
87 return ERR_FAILED; 66 return ERR_FAILED;
88 } 67 }
89 } 68 }
90 69
91 } // namespace net 70 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_errors.h ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698