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

Side by Side Diff: ppapi/proxy/udp_socket_resource_base.h

Issue 869883003: Never lock the Pepper proxy lock on the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix size_t vs int32_t Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « ppapi/proxy/udp_socket_filter.cc ('k') | ppapi/proxy/udp_socket_resource_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_ 5 #ifndef PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
6 #define PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_ 6 #define PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string>
10 9
11 #include "base/basictypes.h" 10 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "ppapi/c/ppb_udp_socket.h" 13 #include "ppapi/c/ppb_udp_socket.h"
15 #include "ppapi/c/private/ppb_net_address_private.h" 14 #include "ppapi/c/private/ppb_net_address_private.h"
16 #include "ppapi/proxy/plugin_resource.h" 15 #include "ppapi/proxy/plugin_resource.h"
17 #include "ppapi/proxy/ppapi_proxy_export.h" 16 #include "ppapi/proxy/ppapi_proxy_export.h"
17 #include "ppapi/proxy/udp_socket_filter.h"
18 #include "ppapi/shared_impl/tracked_callback.h" 18 #include "ppapi/shared_impl/tracked_callback.h"
19 19
20 namespace ppapi { 20 namespace ppapi {
21 namespace proxy { 21 namespace proxy {
22 22
23 class ResourceMessageReplyParams; 23 class ResourceMessageReplyParams;
24 24
25 class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { 25 class PPAPI_PROXY_EXPORT UDPSocketResourceBase : public PluginResource {
26 public: 26 public:
27 // The maximum number of bytes that each 27 // The maximum number of bytes that each
28 // PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry. 28 // PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry.
29 static const int32_t kMaxReadSize; 29 static const int32_t kMaxReadSize;
30 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo 30 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
31 // message is allowed to carry. 31 // message is allowed to carry.
32 static const int32_t kMaxWriteSize; 32 static const int32_t kMaxWriteSize;
33 33
34 // The maximum number that we allow for setting 34 // The maximum number that we allow for setting
35 // PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE. This number is only for input 35 // PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE. This number is only for input
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 int32_t num_bytes, 72 int32_t num_bytes,
73 const PP_NetAddress_Private* addr, 73 const PP_NetAddress_Private* addr,
74 scoped_refptr<TrackedCallback> callback); 74 scoped_refptr<TrackedCallback> callback);
75 void CloseImpl(); 75 void CloseImpl();
76 int32_t JoinGroupImpl(const PP_NetAddress_Private *group, 76 int32_t JoinGroupImpl(const PP_NetAddress_Private *group,
77 scoped_refptr<TrackedCallback> callback); 77 scoped_refptr<TrackedCallback> callback);
78 int32_t LeaveGroupImpl(const PP_NetAddress_Private *group, 78 int32_t LeaveGroupImpl(const PP_NetAddress_Private *group,
79 scoped_refptr<TrackedCallback> callback); 79 scoped_refptr<TrackedCallback> callback);
80 80
81 private: 81 private:
82 struct RecvBuffer {
83 int32_t result;
84 std::string data;
85 PP_NetAddress_Private addr;
86 };
87
88 // Resource overrides.
89 virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
90 const IPC::Message& msg) override;
91
92 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback);
93
94 // IPC message handlers. 82 // IPC message handlers.
95 void OnPluginMsgGeneralReply(scoped_refptr<TrackedCallback> callback, 83 void OnPluginMsgGeneralReply(scoped_refptr<TrackedCallback> callback,
96 const ResourceMessageReplyParams& params); 84 const ResourceMessageReplyParams& params);
97 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, 85 void OnPluginMsgBindReply(const ResourceMessageReplyParams& params,
98 const PP_NetAddress_Private& bound_addr); 86 const PP_NetAddress_Private& bound_addr);
99 void OnPluginMsgPushRecvResult(const ResourceMessageReplyParams& params,
100 int32_t result,
101 const std::string& data,
102 const PP_NetAddress_Private& addr);
103 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, 87 void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params,
104 int32_t bytes_written); 88 int32_t bytes_written);
105 89
106 void RunCallback(scoped_refptr<TrackedCallback> callback, int32_t pp_result); 90 static void SlotBecameAvailable(PP_Resource resource);
107 91 static void SlotBecameAvailableWithLock(PP_Resource resource);
108 // Callers must ensure that |output_buffer| is big enough to store |data|.
109 int32_t SetRecvFromOutput(int32_t browser_result,
110 const std::string& data,
111 const PP_NetAddress_Private& addr,
112 char* output_buffer,
113 int32_t num_bytes,
114 PP_Resource* output_addr);
115 92
116 bool private_api_; 93 bool private_api_;
117 94
118 // |bind_called_| is true after Bind() is called, while |bound_| is true, 95 // |bind_called_| is true after Bind() is called, while |bound_| is true
119 // after Bind() succeeds. Bind() is an asynchronous method, so the timing 96 // after Bind() succeeds. Bind() is an asynchronous method, so the timing
120 // on which of these is set is slightly different. 97 // on which of these is set is slightly different.
121 bool bind_called_; 98 bool bind_called_;
122 bool bound_; 99 bool bound_;
123 bool closed_; 100 bool closed_;
124 101
125 scoped_refptr<TrackedCallback> bind_callback_; 102 scoped_refptr<TrackedCallback> bind_callback_;
126 scoped_refptr<TrackedCallback> recvfrom_callback_; 103 scoped_refptr<UDPSocketFilter> recv_filter_;
127 104
128 char* read_buffer_;
129 int32_t bytes_to_read_;
130 PP_Resource* recvfrom_addr_resource_;
131
132 PP_NetAddress_Private recvfrom_addr_;
133 PP_NetAddress_Private bound_addr_; 105 PP_NetAddress_Private bound_addr_;
134 106
135 std::queue<RecvBuffer> recv_buffers_;
136
137 std::queue<scoped_refptr<TrackedCallback>> sendto_callbacks_; 107 std::queue<scoped_refptr<TrackedCallback>> sendto_callbacks_;
138 108
139 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase); 109 DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceBase);
140 }; 110 };
141 111
142 } // namespace proxy 112 } // namespace proxy
143 } // namespace ppapi 113 } // namespace ppapi
144 114
145 #endif // PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_ 115 #endif // PPAPI_PROXY_UDP_SOCKET_RESOURCE_BASE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/udp_socket_filter.cc ('k') | ppapi/proxy/udp_socket_resource_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698