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

Unified Diff: ppapi/proxy/udp_socket_resource_base.h

Issue 563073002: Pepper UDP socket: buffer received packets in the plugin process to improve performance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/udp_socket_resource_base.h
diff --git a/ppapi/proxy/udp_socket_resource_base.h b/ppapi/proxy/udp_socket_resource_base.h
index 978e774d404236111804a0412d0d57784784e8b8..9d051b32c5cb4dbd8129b192eac7d5d31d984641 100644
--- a/ppapi/proxy/udp_socket_resource_base.h
+++ b/ppapi/proxy/udp_socket_resource_base.h
@@ -5,6 +5,7 @@
#ifndef PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
#define PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
+#include <queue>
#include <string>
#include "base/basictypes.h"
@@ -23,8 +24,8 @@ class ResourceMessageReplyParams;
class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
public:
- // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom
- // message is allowed to request.
+ // The maximum number of bytes that each
+ // PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry.
static const int32_t kMaxReadSize;
// The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
// message is allowed to carry.
@@ -41,6 +42,10 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
// such a buffer size.
static const int32_t kMaxReceiveBufferSize;
+ // The maximum number of received packets that we allow instances of this
+ // class to buffer.
+ static const size_t kPluginReceiveBufferSlots;
+
protected:
UDPSocketResourceBase(Connection connection,
PP_Instance instance,
@@ -66,6 +71,16 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
void CloseImpl();
private:
+ struct RecvBuffer {
+ int32_t result;
+ std::string data;
+ PP_NetAddress_Private addr;
+ };
+
+ // Resource overrides.
+ virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
+ const IPC::Message& msg) OVERRIDE;
+
void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback);
// IPC message handlers.
@@ -73,14 +88,20 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
const ResourceMessageReplyParams& params);
void OnPluginMsgBindReply(const ResourceMessageReplyParams& params,
const PP_NetAddress_Private& bound_addr);
- void OnPluginMsgRecvFromReply(PP_Resource* output_addr,
- const ResourceMessageReplyParams& params,
- const std::string& data,
- const PP_NetAddress_Private& addr);
+ void OnPluginMsgPushRecvResult(const ResourceMessageReplyParams& params,
+ int32_t result,
+ const std::string& data,
+ const PP_NetAddress_Private& addr);
void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params,
int32_t bytes_written);
void RunCallback(scoped_refptr<TrackedCallback> callback, int32_t pp_result);
+ int32_t SetRecvFromOutput(int32_t browser_result,
+ const std::string& data,
+ const PP_NetAddress_Private& addr,
+ char* output_buffer,
+ int32_t num_bytes,
+ PP_Resource* output_addr);
bool private_api_;
bool bound_;
@@ -92,10 +113,13 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource {
char* read_buffer_;
int32_t bytes_to_read_;
+ PP_Resource* recvfrom_addr_resource_;
PP_NetAddress_Private recvfrom_addr_;
PP_NetAddress_Private bound_addr_;
+ std::queue<RecvBuffer> recv_buffers_;
+
DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase);
};

Powered by Google App Engine
This is Rietveld 408576698