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 21 matching lines...) Expand all Loading... | |
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 return error <= ERR_CERT_BEGIN && error > ERR_CERT_END; | 39 return error <= ERR_CERT_BEGIN && error > ERR_CERT_END; |
40 } | 40 } |
41 | 41 |
42 // Returns true if |error| is a success error code. | |
darin (slow to review)
2012/08/10 18:03:02
I'm not sure we want to add these. You'll need fe
mkosiba (inactive)
2012/08/29 15:53:01
I'll pull it out for now. Should I be concerned ab
| |
43 inline bool IsSuccess(int error) { | |
44 return error >= OK; | |
45 } | |
46 | |
47 inline bool IsSuccessOrPending(int error) { | |
48 return IsSuccess(error) || error == ERR_IO_PENDING; | |
49 } | |
50 | |
42 // Map system error code to Error. | 51 // Map system error code to Error. |
43 NET_EXPORT Error MapSystemError(int os_error); | 52 NET_EXPORT Error MapSystemError(int os_error); |
44 | 53 |
45 // Returns a list of all the possible net error codes (not counting OK). This | 54 // 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 | 55 // is intended for use with UMA histograms that are reporting the result of |
47 // an action that is represented as a net error code. | 56 // an action that is represented as a net error code. |
48 // | 57 // |
49 // Note that the error codes are all positive (since histograms expect positive | 58 // 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 | 59 // 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. | 60 // error code that is not followed immediately by a valid error code. |
52 std::vector<int> GetAllErrorCodesForUma(); | 61 std::vector<int> GetAllErrorCodesForUma(); |
53 | 62 |
54 // A convenient function to translate platform file error to net error code. | 63 // A convenient function to translate platform file error to net error code. |
55 NET_EXPORT Error PlatformFileErrorToNetError( | 64 NET_EXPORT Error PlatformFileErrorToNetError( |
56 base::PlatformFileError file_error); | 65 base::PlatformFileError file_error); |
57 | 66 |
58 } // namespace net | 67 } // namespace net |
59 | 68 |
60 #endif // NET_BASE_NET_ERRORS_H__ | 69 #endif // NET_BASE_NET_ERRORS_H__ |
OLD | NEW |