Revert 205649 "Adding wittman who can submit this change. Either..."
[chromium-blink-merge.git] / net / base / net_errors.h
blob21749d8b76b3062c03349c18bfa7239bc1901c5d
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 #ifndef NET_BASE_NET_ERRORS_H__
6 #define NET_BASE_NET_ERRORS_H__
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/platform_file.h"
12 #include "net/base/net_export.h"
14 namespace net {
16 // Error domain of the net module's error codes.
17 NET_EXPORT extern const char kErrorDomain[];
19 // Error values are negative.
20 enum Error {
21 // No error.
22 OK = 0,
24 #define NET_ERROR(label, value) ERR_ ## label = value,
25 #include "net/base/net_error_list.h"
26 #undef NET_ERROR
28 // The value of the first certificate error code.
29 ERR_CERT_BEGIN = ERR_CERT_COMMON_NAME_INVALID,
32 // Returns a textual representation of the error code for logging purposes.
33 NET_EXPORT const char* ErrorToString(int error);
35 // Returns true if |error| is a certificate error code.
36 inline 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 return error <= ERR_CERT_BEGIN && error > ERR_CERT_END;
42 // Map system error code to Error.
43 NET_EXPORT Error MapSystemError(int os_error);
45 // Returns a list of all the possible net error codes (not counting OK). This
46 // is intended for use with UMA histograms that are reporting the result of
47 // an action that is represented as a net error code.
49 // Note that the error codes are all positive (since histograms expect positive
50 // sample values). Also note that a guard bucket is created after any valid
51 // error code that is not followed immediately by a valid error code.
52 NET_EXPORT std::vector<int> GetAllErrorCodesForUma();
54 // A convenient function to translate platform file error to net error code.
55 NET_EXPORT Error PlatformFileErrorToNetError(
56 base::PlatformFileError file_error);
58 } // namespace net
60 #endif // NET_BASE_NET_ERRORS_H__