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/proxy/host_resolver_resource_base.h" | 5 #include "ppapi/proxy/host_resolver_resource_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/proxy/net_address_resource.h" | 9 #include "ppapi/proxy/net_address_resource.h" |
| 10 #include "ppapi/proxy/pp_utils.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
11 #include "ppapi/shared_impl/tracked_callback.h" | 12 #include "ppapi/shared_impl/tracked_callback.h" |
12 #include "ppapi/shared_impl/var.h" | 13 #include "ppapi/shared_impl/var.h" |
13 | 14 |
14 namespace ppapi { | 15 namespace ppapi { |
15 namespace proxy { | 16 namespace proxy { |
16 | 17 |
17 namespace { | |
18 | |
19 int32_t ConvertPPError(int32_t pp_error, bool private_api) { | |
20 // The private API doesn't return network-specific error codes or | |
21 // PP_ERROR_NOACCESS. In order to preserve the behavior, we convert those to | |
22 // PP_ERROR_FAILED. | |
23 // TODO(yzshen): Consider defining ranges for different kinds of PP_Error | |
24 // codes, so that we can detect network-specific error codes in a better way. | |
25 if (private_api && | |
26 (pp_error <= PP_ERROR_CONNECTION_CLOSED || | |
27 pp_error == PP_ERROR_NOACCESS)) { | |
28 return PP_ERROR_FAILED; | |
29 } | |
30 | |
31 return pp_error; | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 HostResolverResourceBase::HostResolverResourceBase(Connection connection, | 18 HostResolverResourceBase::HostResolverResourceBase(Connection connection, |
37 PP_Instance instance, | 19 PP_Instance instance, |
38 bool private_api) | 20 bool private_api) |
39 : PluginResource(connection, instance), | 21 : PluginResource(connection, instance), |
40 private_api_(private_api), | 22 private_api_(private_api), |
41 allow_get_results_(false) { | 23 allow_get_results_(false) { |
42 if (private_api) | 24 if (private_api) |
43 SendCreate(BROWSER, PpapiHostMsg_HostResolver_CreatePrivate()); | 25 SendCreate(BROWSER, PpapiHostMsg_HostResolver_CreatePrivate()); |
44 else | 26 else |
45 SendCreate(BROWSER, PpapiHostMsg_HostResolver_Create()); | 27 SendCreate(BROWSER, PpapiHostMsg_HostResolver_Create()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 base::Bind(&HostResolverResourceBase::OnPluginMsgResolveReply, | 105 base::Bind(&HostResolverResourceBase::OnPluginMsgResolveReply, |
124 base::Unretained(this))); | 106 base::Unretained(this))); |
125 } | 107 } |
126 | 108 |
127 bool HostResolverResourceBase::ResolveInProgress() const { | 109 bool HostResolverResourceBase::ResolveInProgress() const { |
128 return TrackedCallback::IsPending(resolve_callback_); | 110 return TrackedCallback::IsPending(resolve_callback_); |
129 } | 111 } |
130 | 112 |
131 } // namespace proxy | 113 } // namespace proxy |
132 } // namespace ppapi | 114 } // namespace ppapi |
OLD | NEW |