Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: ppapi/proxy/host_resolver_resource_base.cc

Issue 16933003: Implement PPB_HostResolver_Dev: part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/host_resolver_resource_base.cc
diff --git a/ppapi/proxy/host_resolver_resource_base.cc b/ppapi/proxy/host_resolver_resource_base.cc
index c4055a73eef9614faa516798a3174a27722331c7..cb2df3267ac6536a0a4fe04b8e1be0b25053595c 100644
--- a/ppapi/proxy/host_resolver_resource_base.cc
+++ b/ppapi/proxy/host_resolver_resource_base.cc
@@ -13,11 +13,33 @@
namespace ppapi {
namespace proxy {
+namespace {
+
+int32_t ConvertPPError(int32_t pp_error, bool private_api) {
+ // The private API doesn't return network-specific error codes or
+ // PP_ERROR_NOACCESS. In order to preserve the havavior, we convert those to
+ // PP_ERROR_FAILED.
+ if (private_api &&
+ (pp_error <= PP_ERROR_CONNECTION_CLOSED ||
raymes 2013/06/18 18:21:17 nit: It would sort of be nicer to check whether th
yzshen1 2013/06/18 19:08:43 I agree with you that the current code doesn't loo
+ pp_error == PP_ERROR_NOACCESS)) {
+ return PP_ERROR_FAILED;
+ }
+
+ return pp_error;
+}
+
+} // namespace
+
HostResolverResourceBase::HostResolverResourceBase(Connection connection,
- PP_Instance instance)
+ PP_Instance instance,
+ bool private_api)
: PluginResource(connection, instance),
+ private_api_(private_api),
allow_get_results_(false) {
- SendCreate(BROWSER, PpapiHostMsg_HostResolverPrivate_Create());
+ if (private_api)
+ SendCreate(BROWSER, PpapiHostMsg_HostResolver_CreatePrivate());
+ else
+ SendCreate(BROWSER, PpapiHostMsg_HostResolver_Create());
}
HostResolverResourceBase::~HostResolverResourceBase() {
@@ -85,14 +107,14 @@ void HostResolverResourceBase::OnPluginMsgResolveReply(
canonical_name_.clear();
net_address_list_.clear();
}
- resolve_callback_->Run(params.result());
+ resolve_callback_->Run(ConvertPPError(params.result(), private_api_));
}
void HostResolverResourceBase::SendResolve(
const HostPortPair& host_port,
const PP_HostResolver_Private_Hint* hint) {
- PpapiHostMsg_HostResolverPrivate_Resolve msg(host_port, *hint);
- Call<PpapiPluginMsg_HostResolverPrivate_ResolveReply>(
+ PpapiHostMsg_HostResolver_Resolve msg(host_port, *hint);
+ Call<PpapiPluginMsg_HostResolver_ResolveReply>(
BROWSER,
msg,
base::Bind(&HostResolverResourceBase::OnPluginMsgResolveReply,

Powered by Google App Engine
This is Rietveld 408576698