Index: ppapi/proxy/vpn_provider_resource.cc |
diff --git a/ppapi/proxy/vpn_provider_resource.cc b/ppapi/proxy/vpn_provider_resource.cc |
index 506496143577c90142d1ee0bdd2dbcb3e54fbb5d..bf960bdf8075f8a56d1f9e866e6b1498df4afdfb 100644 |
--- a/ppapi/proxy/vpn_provider_resource.cc |
+++ b/ppapi/proxy/vpn_provider_resource.cc |
@@ -23,9 +23,7 @@ |
send_packet_callback_(nullptr), |
receive_packet_callback_(nullptr), |
receive_packet_callback_var_(nullptr), |
- bound_(false) { |
- SendCreate(BROWSER, PpapiHostMsg_VpnProvider_Create()); |
-} |
+ bound_(false) {} |
VpnProviderResource::~VpnProviderResource() {} |
@@ -36,15 +34,7 @@ |
void VpnProviderResource::OnReplyReceived( |
const ResourceMessageReplyParams& params, |
const IPC::Message& msg) { |
- PPAPI_BEGIN_MESSAGE_MAP(VpnProviderResource, msg) |
- PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(PpapiPluginMsg_VpnProvider_OnUnbind, |
- OnPluginMsgOnUnbindReceived) |
- PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( |
- PpapiPluginMsg_VpnProvider_OnPacketReceived, |
- OnPluginMsgOnPacketReceived) |
- PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( |
- PluginResource::OnReplyReceived(params, msg)) |
- PPAPI_END_MESSAGE_MAP() |
+ PluginResource::OnReplyReceived(params, msg); |
} |
int32_t VpnProviderResource::Bind( |
@@ -61,14 +51,7 @@ |
if (!configuration_name_var) |
return PP_ERROR_BADARGUMENT; |
- bind_callback_ = callback; |
- |
- Call<PpapiPluginMsg_VpnProvider_BindReply>( |
- BROWSER, PpapiHostMsg_VpnProvider_Bind(configuration_id_var->value(), |
- configuration_name_var->value()), |
- base::Bind(&VpnProviderResource::OnPluginMsgBindReply, this)); |
- |
- return PP_OK_COMPLETIONPENDING; |
+ return PP_ERROR_NOTSUPPORTED; |
} |
int32_t VpnProviderResource::SendPacket( |
@@ -103,17 +86,10 @@ |
if (!packet_arraybuffer.get()) |
return PP_ERROR_BADARGUMENT; |
+ char* packet_pointer = static_cast<char*>(packet_arraybuffer->Map()); |
uint32_t packet_size = packet_arraybuffer->ByteLength(); |
- if (packet_size > send_packet_buffer_->max_packet_size()) |
- return PP_ERROR_MESSAGE_TOO_BIG; |
- |
- char* packet_pointer = static_cast<char*>(packet_arraybuffer->Map()); |
memcpy(send_packet_buffer_->GetBuffer(id), packet_pointer, packet_size); |
packet_arraybuffer->Unmap(); |
- |
- Call<PpapiPluginMsg_VpnProvider_SendPacketReply>( |
- BROWSER, PpapiHostMsg_VpnProvider_SendPacket(packet_size, id), |
- base::Bind(&VpnProviderResource::OnPluginMsgSendPacketReply, this)); |
return PP_OK; |
} |
@@ -150,31 +126,22 @@ |
PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(send_packets_.front()); |
send_packets_.pop(); |
} |
- |
- send_packet_buffer_.reset(); |
- recv_packet_buffer_.reset(); |
} |
void VpnProviderResource::OnPluginMsgOnPacketReceived( |
const ResourceMessageReplyParams& params, |
uint32_t packet_size, |
uint32_t id) { |
- DCHECK_LE(packet_size, recv_packet_buffer_->max_packet_size()); |
if (!bound_) { |
- // Ignore packet and mark shared memory as available |
- Post(BROWSER, PpapiHostMsg_VpnProvider_OnPacketReceivedReply(id)); |
return; |
} |
// Append received packet to queue. |
- void* packet_pointer = recv_packet_buffer_->GetBuffer(id); |
+ void* packet_pointer = receive_packet_buffer_->GetBuffer(id); |
scoped_refptr<Var> packet_var( |
PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar(packet_size, |
packet_pointer)); |
received_packets_.push(packet_var); |
- |
- // Mark shared memory as available for next packet |
- Post(BROWSER, PpapiHostMsg_VpnProvider_OnPacketReceivedReply(id)); |
if (!TrackedCallback::IsPending(receive_packet_callback_) || |
TrackedCallback::IsScheduledToRun(receive_packet_callback_)) { |
@@ -209,8 +176,9 @@ |
} |
send_packet_buffer_ = base::WrapUnique(new ppapi::VpnProviderSharedBuffer( |
queue_size, max_packet_size, std::move(send_shm))); |
- recv_packet_buffer_ = base::WrapUnique(new ppapi::VpnProviderSharedBuffer( |
- queue_size, max_packet_size, std::move(receive_shm))); |
+ receive_packet_buffer_ = |
+ base::WrapUnique(new ppapi::VpnProviderSharedBuffer( |
+ queue_size, max_packet_size, std::move(receive_shm))); |
bound_ = (result == PP_OK); |
} |
@@ -222,7 +190,7 @@ |
void VpnProviderResource::OnPluginMsgSendPacketReply( |
const ResourceMessageReplyParams& params, |
- uint32_t id) { |
+ int32_t id) { |
if (!send_packets_.empty() && bound_) { |
// Process remaining packets |
DoSendPacket(send_packets_.front(), id); |