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