OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ppapi/host/error_conversion.h" | 5 #include "ppapi/proxy/error_conversion.h" |
6 | 6 |
7 #include "base/safe_numerics.h" | 7 #include "base/safe_numerics.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 | 10 |
11 namespace ppapi { | 11 namespace ppapi { |
12 namespace host { | 12 namespace proxy { |
13 | 13 |
14 int32_t NetErrorToPepperError(int net_error) { | 14 int32_t NetErrorToPepperError(int net_error) { |
15 if (net_error > 0) | 15 if (net_error > 0) |
16 return base::checked_numeric_cast<int32_t>(net_error); | 16 return base::checked_numeric_cast<int32_t>(net_error); |
17 | 17 |
18 switch (net_error) { | 18 switch (net_error) { |
19 case net::OK: | 19 case net::OK: |
20 return PP_OK; | 20 return PP_OK; |
21 case net::ERR_IO_PENDING: | 21 case net::ERR_IO_PENDING: |
22 return PP_OK_COMPLETIONPENDING; | 22 return PP_OK_COMPLETIONPENDING; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return PP_ERROR_NOACCESS; | 64 return PP_ERROR_NOACCESS; |
65 case net::ERR_MSG_TOO_BIG: | 65 case net::ERR_MSG_TOO_BIG: |
66 return PP_ERROR_MESSAGE_TOO_BIG; | 66 return PP_ERROR_MESSAGE_TOO_BIG; |
67 case net::ERR_ADDRESS_IN_USE: | 67 case net::ERR_ADDRESS_IN_USE: |
68 return PP_ERROR_ADDRESS_IN_USE; | 68 return PP_ERROR_ADDRESS_IN_USE; |
69 default: | 69 default: |
70 return PP_ERROR_FAILED; | 70 return PP_ERROR_FAILED; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 } // namespace host | 74 int32_t ConvertNetworkAPIErrorForCompatibility(int32_t pp_error, |
| 75 bool private_api) { |
| 76 // The private API doesn't return network-specific error codes or |
| 77 // PP_ERROR_NOACCESS. In order to preserve the behavior, we convert those to |
| 78 // PP_ERROR_FAILED. |
| 79 if (private_api && |
| 80 (pp_error <= PP_ERROR_CONNECTION_CLOSED || |
| 81 pp_error == PP_ERROR_NOACCESS)) { |
| 82 return PP_ERROR_FAILED; |
| 83 } |
| 84 return pp_error; |
| 85 } |
| 86 |
| 87 } // namespace proxy |
75 } // namespace ppapi | 88 } // namespace ppapi |
OLD | NEW |