OLD | NEW |
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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/common/process_type.h" | 16 #include "content/public/common/process_type.h" |
17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
18 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
| 19 #include "net/udp/udp_socket.h" |
19 #include "ppapi/c/pp_instance.h" | 20 #include "ppapi/c/pp_instance.h" |
20 #include "ppapi/c/pp_stdint.h" | 21 #include "ppapi/c/pp_stdint.h" |
21 #include "ppapi/c/ppb_udp_socket.h" | 22 #include "ppapi/c/ppb_udp_socket.h" |
22 #include "ppapi/host/resource_message_filter.h" | 23 #include "ppapi/host/resource_message_filter.h" |
23 | 24 |
24 struct PP_NetAddress_Private; | 25 struct PP_NetAddress_Private; |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 class IOBuffer; | 28 class IOBuffer; |
28 class IOBufferWithSize; | 29 class IOBufferWithSize; |
29 class UDPServerSocket; | |
30 } | 30 } |
31 | 31 |
32 namespace ppapi { | 32 namespace ppapi { |
33 | 33 |
34 class SocketOptionData; | 34 class SocketOptionData; |
35 | 35 |
36 namespace host { | 36 namespace host { |
37 struct ReplyMessageContext; | 37 struct ReplyMessageContext; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 namespace content { | 41 namespace content { |
42 | 42 |
43 class BrowserPpapiHostImpl; | 43 class BrowserPpapiHostImpl; |
44 struct SocketPermissionRequest; | 44 struct SocketPermissionRequest; |
45 | 45 |
46 class CONTENT_EXPORT PepperUDPSocketMessageFilter | 46 class CONTENT_EXPORT PepperUDPSocketMessageFilter |
47 : public ppapi::host::ResourceMessageFilter { | 47 : public ppapi::host::ResourceMessageFilter { |
48 public: | 48 public: |
49 PepperUDPSocketMessageFilter(BrowserPpapiHostImpl* host, | 49 PepperUDPSocketMessageFilter(BrowserPpapiHostImpl* host, |
50 PP_Instance instance, | 50 PP_Instance instance, |
51 bool private_api); | 51 bool private_api); |
52 | 52 |
53 static size_t GetNumInstances(); | 53 static size_t GetNumInstances(); |
54 | 54 |
55 protected: | 55 protected: |
56 ~PepperUDPSocketMessageFilter() override; | 56 ~PepperUDPSocketMessageFilter() override; |
57 | 57 |
58 private: | 58 private: |
| 59 enum SocketOption { |
| 60 SOCKET_OPTION_ADDRESS_REUSE = 1 << 0, |
| 61 SOCKET_OPTION_BROADCAST = 1 << 1, |
| 62 SOCKET_OPTION_RCVBUF_SIZE = 1 << 2, |
| 63 SOCKET_OPTION_SNDBUF_SIZE = 1 << 3 |
| 64 }; |
| 65 |
59 // ppapi::host::ResourceMessageFilter overrides. | 66 // ppapi::host::ResourceMessageFilter overrides. |
60 scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( | 67 scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( |
61 const IPC::Message& message) override; | 68 const IPC::Message& message) override; |
62 int32_t OnResourceMessageReceived( | 69 int32_t OnResourceMessageReceived( |
63 const IPC::Message& msg, | 70 const IPC::Message& msg, |
64 ppapi::host::HostMessageContext* context) override; | 71 ppapi::host::HostMessageContext* context) override; |
65 | 72 |
66 int32_t OnMsgSetOption(const ppapi::host::HostMessageContext* context, | 73 int32_t OnMsgSetOption(const ppapi::host::HostMessageContext* context, |
67 PP_UDPSocket_Option name, | 74 PP_UDPSocket_Option name, |
68 const ppapi::SocketOptionData& value); | 75 const ppapi::SocketOptionData& value); |
(...skipping 27 matching lines...) Expand all Loading... |
96 void SendSendToReply(const ppapi::host::ReplyMessageContext& context, | 103 void SendSendToReply(const ppapi::host::ReplyMessageContext& context, |
97 int32_t result, | 104 int32_t result, |
98 int32_t bytes_written); | 105 int32_t bytes_written); |
99 | 106 |
100 void SendBindError(const ppapi::host::ReplyMessageContext& context, | 107 void SendBindError(const ppapi::host::ReplyMessageContext& context, |
101 int32_t result); | 108 int32_t result); |
102 void SendRecvFromError(int32_t result); | 109 void SendRecvFromError(int32_t result); |
103 void SendSendToError(const ppapi::host::ReplyMessageContext& context, | 110 void SendSendToError(const ppapi::host::ReplyMessageContext& context, |
104 int32_t result); | 111 int32_t result); |
105 | 112 |
106 bool allow_address_reuse_; | 113 // Bitwise-or of SocketOption flags. This stores the state about whether |
107 bool allow_broadcast_; | 114 // each option is set before Bind() is called. |
| 115 int socket_options_; |
108 | 116 |
109 scoped_ptr<net::UDPServerSocket> socket_; | 117 // Locally cached value of buffer size. |
| 118 int32_t rcvbuf_size_; |
| 119 int32_t sndbuf_size_; |
| 120 |
| 121 scoped_ptr<net::UDPSocket> socket_; |
110 bool closed_; | 122 bool closed_; |
111 | 123 |
112 scoped_refptr<net::IOBuffer> recvfrom_buffer_; | 124 scoped_refptr<net::IOBuffer> recvfrom_buffer_; |
113 scoped_refptr<net::IOBufferWithSize> sendto_buffer_; | 125 scoped_refptr<net::IOBufferWithSize> sendto_buffer_; |
114 | 126 |
115 net::IPEndPoint recvfrom_address_; | 127 net::IPEndPoint recvfrom_address_; |
116 | 128 |
117 size_t remaining_recv_slots_; | 129 size_t remaining_recv_slots_; |
118 | 130 |
119 bool external_plugin_; | 131 bool external_plugin_; |
120 bool private_api_; | 132 bool private_api_; |
121 | 133 |
122 int render_process_id_; | 134 int render_process_id_; |
123 int render_frame_id_; | 135 int render_frame_id_; |
124 | 136 |
125 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocketMessageFilter); | 137 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocketMessageFilter); |
126 }; | 138 }; |
127 | 139 |
128 } // namespace content | 140 } // namespace content |
129 | 141 |
130 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER
_H_ | 142 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_MESSAGE_FILTER
_H_ |
OLD | NEW |