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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/base/net_errors_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/base/net_errors.h"
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 {
24
25 const char kErrorDomain[] = "net";
26
27 std::string ErrorToString(int error) {
28 return "net::" + ErrorToShortString(error);
29 }
30
31 std::string ErrorToShortString(int error) {
32 if (error == 0)
33 return "OK";
34
35 const char* error_string;
36 switch (error) {
37 #define NET_ERROR(label, value) \
38 case ERR_ ## label: \
39 error_string = # label; \
40 break;
41 #include "net/base/net_error_list.h"
42 #undef NET_ERROR
43 default:
44 NOTREACHED();
45 error_string = "<unknown>";
46 }
47 return std::string("ERR_") + error_string;
48 }
49
50 bool IsCertificateError(int error) {
51 // Certificate errors are negative integers from net::ERR_CERT_BEGIN
52 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order.
53 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this
54 // rule.
55 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) ||
56 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN);
57 }
58
59 bool IsClientCertificateError(int error) {
60 switch (error) {
61 case ERR_BAD_SSL_CLIENT_AUTH_CERT:
62 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
63 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
64 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED:
65 return true;
66 default:
67 return false;
68 }
69 }
70
71 std::vector<int> GetAllErrorCodesForUma() {
72 return base::CustomHistogram::ArrayToCustomRanges(
73 kAllErrorCodes, arraysize(kAllErrorCodes));
74 }
75
76 Error FileErrorToNetError(base::File::Error file_error) {
77 switch (file_error) {
78 case base::File::FILE_OK:
79 return net::OK;
80 case base::File::FILE_ERROR_ACCESS_DENIED:
81 return net::ERR_ACCESS_DENIED;
82 case base::File::FILE_ERROR_INVALID_URL:
83 return net::ERR_INVALID_URL;
84 case base::File::FILE_ERROR_NOT_FOUND:
85 return net::ERR_FILE_NOT_FOUND;
86 default:
87 return net::ERR_FAILED;
88 }
89 }
90
91 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_errors.h ('k') | net/base/net_errors_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698