| 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 #ifndef NET_BASE_NET_ERRORS_H__ | 5 #ifndef NET_BASE_NET_ERRORS_H__ |
| 6 #define NET_BASE_NET_ERRORS_H__ | 6 #define NET_BASE_NET_ERRORS_H__ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, | 29 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // Returns a textual representation of the error code for logging purposes. | 32 // Returns a textual representation of the error code for logging purposes. |
| 33 NET_EXPORT const char* ErrorToString(int error); | 33 NET_EXPORT const char* ErrorToString(int error); |
| 34 | 34 |
| 35 // Returns true if |error| is a certificate error code. | 35 // Returns true if |error| is a certificate error code. |
| 36 inline bool IsCertificateError(int error) { | 36 inline bool IsCertificateError(int error) { |
| 37 // Certificate errors are negative integers from net::ERR_CERT_BEGIN | 37 // Certificate errors are negative integers from net::ERR_CERT_BEGIN |
| 38 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. | 38 // (inclusive) to net::ERR_CERT_END (exclusive) in *decreasing* order. |
| 39 // ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN is currently an exception to this |
| 40 // rule. |
| 39 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || | 41 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || |
| 40 (error == ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY) || | |
| 41 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); | 42 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Map system error code to Error. | 45 // Map system error code to Error. |
| 45 NET_EXPORT Error MapSystemError(int os_error); | 46 NET_EXPORT Error MapSystemError(int os_error); |
| 46 | 47 |
| 47 // Returns a list of all the possible net error codes (not counting OK). This | 48 // Returns a list of all the possible net error codes (not counting OK). This |
| 48 // is intended for use with UMA histograms that are reporting the result of | 49 // is intended for use with UMA histograms that are reporting the result of |
| 49 // an action that is represented as a net error code. | 50 // an action that is represented as a net error code. |
| 50 // | 51 // |
| 51 // Note that the error codes are all positive (since histograms expect positive | 52 // Note that the error codes are all positive (since histograms expect positive |
| 52 // sample values). Also note that a guard bucket is created after any valid | 53 // sample values). Also note that a guard bucket is created after any valid |
| 53 // error code that is not followed immediately by a valid error code. | 54 // error code that is not followed immediately by a valid error code. |
| 54 NET_EXPORT std::vector<int> GetAllErrorCodesForUma(); | 55 NET_EXPORT std::vector<int> GetAllErrorCodesForUma(); |
| 55 | 56 |
| 56 // A convenient function to translate file error to net error code. | 57 // A convenient function to translate file error to net error code. |
| 57 NET_EXPORT Error FileErrorToNetError(base::File::Error file_error); | 58 NET_EXPORT Error FileErrorToNetError(base::File::Error file_error); |
| 58 | 59 |
| 59 } // namespace net | 60 } // namespace net |
| 60 | 61 |
| 61 #endif // NET_BASE_NET_ERRORS_H__ | 62 #endif // NET_BASE_NET_ERRORS_H__ |
| OLD | NEW |