0
Files
src/ppapi/proxy/network_proxy_resource.cc
Avi Drissman 821ca309ed Update header includes for /base/functional in /p*
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I36784c7cc322001d0b0ec2590c3847f4298033ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4157596
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091526}
2023-01-11 22:42:15 +00:00

65 lines
2.1 KiB
C++

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/network_proxy_resource.h"
#include "base/functional/bind.h"
#include "ppapi/proxy/dispatch_reply_message.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
namespace proxy {
NetworkProxyResource::NetworkProxyResource(Connection connection,
PP_Instance instance)
: PluginResource(connection, instance) {
SendCreate(BROWSER, PpapiHostMsg_NetworkProxy_Create());
}
NetworkProxyResource::~NetworkProxyResource() {
}
thunk::PPB_NetworkProxy_API* NetworkProxyResource::AsPPB_NetworkProxy_API() {
return this;
}
int32_t NetworkProxyResource::GetProxyForURL(
PP_Instance /* instance */,
PP_Var url,
PP_Var* proxy_string,
scoped_refptr<TrackedCallback> callback) {
StringVar* string_url = StringVar::FromPPVar(url);
if (!string_url)
return PP_ERROR_BADARGUMENT;
Call<PpapiPluginMsg_NetworkProxy_GetProxyForURLReply>(
BROWSER, PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()),
base::BindOnce(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply,
base::Unretained(this), base::Unretained(proxy_string),
callback));
return PP_OK_COMPLETIONPENDING;
}
void NetworkProxyResource::OnPluginMsgGetProxyForURLReply(
PP_Var* proxy_string_out_param,
scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params,
const std::string& proxy_string) {
if (!TrackedCallback::IsPending(callback)) {
// The callback should not have already been run. If this resource is
// deleted, LastPluginRefWasReleased in PluginResource should abort the
// callback and should not run this callback.
NOTREACHED();
return;
}
if (params.result() == PP_OK) {
*proxy_string_out_param = (new StringVar(proxy_string))->GetPPVar();
}
callback->Run(params.result());
}
} // namespace proxy
} // namespace ppapi