[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / net / base / net_errors.cc
blobddba87b94c59fbbd39e06aae4a2725bca19126e1
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.
5 #include "net/base/net_errors.h"
7 namespace net {
9 const char kErrorDomain[] = "net";
11 std::string ErrorToString(int error) {
12 return "net::" + ErrorToShortString(error);
15 std::string ErrorToShortString(int error) {
16 if (error == 0)
17 return "OK";
19 const char* error_string;
20 switch (error) {
21 #define NET_ERROR(label, value) \
22 case ERR_ ## label: \
23 error_string = # label; \
24 break;
25 #include "net/base/net_error_list.h"
26 #undef NET_ERROR
27 default:
28 NOTREACHED();
29 error_string = "<unknown>";
31 return std::string("ERR_") + error_string;
34 bool IsCertificateError(int error) {
35 // Certificate errors are negative integers from net::ERR_CERT_BEGIN
36 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order.
37 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this
38 // rule.
39 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) ||
40 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN);
43 bool IsClientCertificateError(int error) {
44 switch (error) {
45 case ERR_BAD_SSL_CLIENT_AUTH_CERT:
46 case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
47 case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
48 case ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED:
49 return true;
50 default:
51 return false;
55 Error FileErrorToNetError(base::File::Error file_error) {
56 switch (file_error) {
57 case base::File::FILE_OK:
58 return OK;
59 case base::File::FILE_ERROR_ACCESS_DENIED:
60 return ERR_ACCESS_DENIED;
61 case base::File::FILE_ERROR_INVALID_URL:
62 return ERR_INVALID_URL;
63 case base::File::FILE_ERROR_NOT_FOUND:
64 return ERR_FILE_NOT_FOUND;
65 default:
66 return ERR_FAILED;
70 } // namespace net