Chromium Code Reviews| 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 <string> | |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 // Error domain of the net module's error codes. | 17 // Error domain of the net module's error codes. |
| 17 NET_EXPORT extern const char kErrorDomain[]; | 18 NET_EXPORT extern const char kErrorDomain[]; |
| 18 | 19 |
| 19 // Error values are negative. | 20 // Error values are negative. |
| 20 enum Error { | 21 enum Error { |
| 21 // No error. | 22 // No error. |
| 22 OK = 0, | 23 OK = 0, |
| 23 | 24 |
| 24 #define NET_ERROR(label, value) ERR_ ## label = value, | 25 #define NET_ERROR(label, value) ERR_ ## label = value, |
| 25 #include "net/base/net_error_list.h" | 26 #include "net/base/net_error_list.h" |
| 26 #undef NET_ERROR | 27 #undef NET_ERROR |
| 27 | 28 |
| 28 // The value of the first certificate error code. | 29 // The value of the first certificate error code. |
| 29 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, | 30 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID, |
| 30 }; | 31 }; |
| 31 | 32 |
| 33 // Same as above, but leaves off the leading "net::". | |
|
eroman
2014/08/05 22:54:51
"Same as below", or move this down ;)
mmenke
2014/08/06 16:40:56
Moved it down (And its definition as well), "same
| |
| 34 NET_EXPORT std::string ErrorToShortString(int error); | |
| 35 | |
| 32 // Returns a textual representation of the error code for logging purposes. | 36 // Returns a textual representation of the error code for logging purposes. |
| 33 NET_EXPORT const char* ErrorToString(int error); | 37 NET_EXPORT std::string ErrorToString(int error); |
| 34 | 38 |
| 35 // Returns true if |error| is a certificate error code. | 39 // Returns true if |error| is a certificate error code. |
| 36 inline bool IsCertificateError(int error) { | 40 NET_EXPORT bool IsCertificateError(int error); |
| 37 // Certificate errors are negative integers from net::ERR_CERT_BEGIN | |
| 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. | |
| 41 return (error <= ERR_CERT_BEGIN && error > ERR_CERT_END) || | |
| 42 (error == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN); | |
| 43 } | |
| 44 | 41 |
| 45 // Map system error code to Error. | 42 // Map system error code to Error. |
| 46 NET_EXPORT Error MapSystemError(int os_error); | 43 NET_EXPORT Error MapSystemError(int os_error); |
| 47 | 44 |
| 48 // Returns a list of all the possible net error codes (not counting OK). This | 45 // Returns a list of all the possible net error codes (not counting OK). This |
| 49 // is intended for use with UMA histograms that are reporting the result of | 46 // is intended for use with UMA histograms that are reporting the result of |
| 50 // an action that is represented as a net error code. | 47 // an action that is represented as a net error code. |
| 51 // | 48 // |
| 52 // Note that the error codes are all positive (since histograms expect positive | 49 // Note that the error codes are all positive (since histograms expect positive |
| 53 // sample values). Also note that a guard bucket is created after any valid | 50 // sample values). Also note that a guard bucket is created after any valid |
| 54 // error code that is not followed immediately by a valid error code. | 51 // error code that is not followed immediately by a valid error code. |
| 55 NET_EXPORT std::vector<int> GetAllErrorCodesForUma(); | 52 NET_EXPORT std::vector<int> GetAllErrorCodesForUma(); |
| 56 | 53 |
| 57 // A convenient function to translate file error to net error code. | 54 // A convenient function to translate file error to net error code. |
| 58 NET_EXPORT Error FileErrorToNetError(base::File::Error file_error); | 55 NET_EXPORT Error FileErrorToNetError(base::File::Error file_error); |
| 59 | 56 |
| 60 } // namespace net | 57 } // namespace net |
| 61 | 58 |
| 62 #endif // NET_BASE_NET_ERRORS_H__ | 59 #endif // NET_BASE_NET_ERRORS_H__ |
| OLD | NEW |