| OLD | NEW |
| 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" | 7 #include "base/basictypes.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/stringize_macros.h" | 9 #include "base/strings/stringize_macros.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 bool IsCertificateError(int error) { | 50 bool IsCertificateError(int error) { |
| 51 // Certificate errors are negative integers from net::ERR_CERT_BEGIN | 51 // Certificate errors are negative integers from net::ERR_CERT_BEGIN |
| 52 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. | 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 | 53 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this |
| 54 // rule. | 54 // rule. |
| 55 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || | 55 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || |
| 56 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); | 56 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); |
| 57 } | 57 } |
| 58 | 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 |
| 59 std::vector<int> GetAllErrorCodesForUma() { | 71 std::vector<int> GetAllErrorCodesForUma() { |
| 60 return base::CustomHistogram::ArrayToCustomRanges( | 72 return base::CustomHistogram::ArrayToCustomRanges( |
| 61 kAllErrorCodes, arraysize(kAllErrorCodes)); | 73 kAllErrorCodes, arraysize(kAllErrorCodes)); |
| 62 } | 74 } |
| 63 | 75 |
| 64 Error FileErrorToNetError(base::File::Error file_error) { | 76 Error FileErrorToNetError(base::File::Error file_error) { |
| 65 switch (file_error) { | 77 switch (file_error) { |
| 66 case base::File::FILE_OK: | 78 case base::File::FILE_OK: |
| 67 return net::OK; | 79 return net::OK; |
| 68 case base::File::FILE_ERROR_ACCESS_DENIED: | 80 case base::File::FILE_ERROR_ACCESS_DENIED: |
| 69 return net::ERR_ACCESS_DENIED; | 81 return net::ERR_ACCESS_DENIED; |
| 70 case base::File::FILE_ERROR_INVALID_URL: | 82 case base::File::FILE_ERROR_INVALID_URL: |
| 71 return net::ERR_INVALID_URL; | 83 return net::ERR_INVALID_URL; |
| 72 case base::File::FILE_ERROR_NOT_FOUND: | 84 case base::File::FILE_ERROR_NOT_FOUND: |
| 73 return net::ERR_FILE_NOT_FOUND; | 85 return net::ERR_FILE_NOT_FOUND; |
| 74 default: | 86 default: |
| 75 return net::ERR_FAILED; | 87 return net::ERR_FAILED; |
| 76 } | 88 } |
| 77 } | 89 } |
| 78 | 90 |
| 79 } // namespace net | 91 } // namespace net |
| OLD | NEW |