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 #include "net/base/net_errors.h" | 5 #include "net/base/net_errors.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/stringize_macros.h" | 9 #include "base/strings/stringize_macros.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 const char kErrorDomain[] = "net"; | 25 const char kErrorDomain[] = "net"; |
26 | 26 |
27 const char* ErrorToString(int error) { | 27 const char* ErrorToString(int error) { |
28 if (error == 0) | 28 if (error == 0) |
29 return "net::OK"; | 29 return "net::OK"; |
30 | 30 |
31 switch (error) { | 31 switch (error) { |
32 #define NET_ERROR(label, value) \ | 32 #define NET_ERROR(label, value) \ |
33 case ERR_ ## label: \ | 33 case ERR_##label: \ |
34 return "net::" STRINGIZE_NO_EXPANSION(ERR_ ## label); | 34 return "net::" STRINGIZE_NO_EXPANSION(ERR_##label); |
35 #include "net/base/net_error_list.h" | 35 #include "net/base/net_error_list.h" |
36 #undef NET_ERROR | 36 #undef NET_ERROR |
37 default: | 37 default: |
38 return "net::<unknown>"; | 38 return "net::<unknown>"; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 std::vector<int> GetAllErrorCodesForUma() { | 42 std::vector<int> GetAllErrorCodesForUma() { |
43 return base::CustomHistogram::ArrayToCustomRanges( | 43 return base::CustomHistogram::ArrayToCustomRanges(kAllErrorCodes, |
44 kAllErrorCodes, arraysize(kAllErrorCodes)); | 44 arraysize(kAllErrorCodes)); |
45 } | 45 } |
46 | 46 |
47 Error FileErrorToNetError(base::File::Error file_error) { | 47 Error FileErrorToNetError(base::File::Error file_error) { |
48 switch (file_error) { | 48 switch (file_error) { |
49 case base::File::FILE_OK: | 49 case base::File::FILE_OK: |
50 return net::OK; | 50 return net::OK; |
51 case base::File::FILE_ERROR_ACCESS_DENIED: | 51 case base::File::FILE_ERROR_ACCESS_DENIED: |
52 return net::ERR_ACCESS_DENIED; | 52 return net::ERR_ACCESS_DENIED; |
53 case base::File::FILE_ERROR_INVALID_URL: | 53 case base::File::FILE_ERROR_INVALID_URL: |
54 return net::ERR_INVALID_URL; | 54 return net::ERR_INVALID_URL; |
55 case base::File::FILE_ERROR_NOT_FOUND: | 55 case base::File::FILE_ERROR_NOT_FOUND: |
56 return net::ERR_FILE_NOT_FOUND; | 56 return net::ERR_FILE_NOT_FOUND; |
57 default: | 57 default: |
58 return net::ERR_FAILED; | 58 return net::ERR_FAILED; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 } // namespace net | 62 } // namespace net |
OLD | NEW |