OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ |
7 | 7 |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 9 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 10 #include "content/browser/renderer_host/pepper/pepper_udp_socket_private_shared.
h" |
13 #include "net/base/completion_callback.h" | |
14 #include "net/base/ip_endpoint.h" | |
15 #include "ppapi/c/pp_stdint.h" | |
16 | |
17 struct PP_NetAddress_Private; | |
18 | |
19 namespace net { | |
20 class IOBuffer; | |
21 class UDPServerSocket; | |
22 } | |
23 | 11 |
24 namespace content { | 12 namespace content { |
25 class PepperMessageFilter; | 13 class PepperMessageFilter; |
26 | 14 |
27 // PepperUDPSocket is used by PepperMessageFilter to handle requests from | 15 // PepperUDPSocket is used by PepperMessageFilter to handle requests from |
28 // the Pepper UDP socket API (PPB_UDPSocket_Private). | 16 // the Pepper UDP socket API (PPB_UDPSocket_Private). |
29 class PepperUDPSocket { | 17 class PepperUDPSocket : public PepperUDPSocketPrivateShared { |
30 public: | 18 public: |
31 PepperUDPSocket(PepperMessageFilter* manager, | 19 PepperUDPSocket(PepperMessageFilter* manager, |
32 int32 routing_id, | 20 int32 routing_id, |
33 uint32 plugin_dispatcher_id, | 21 uint32 plugin_dispatcher_id, |
34 uint32 socket_id); | 22 uint32 socket_id); |
35 ~PepperUDPSocket(); | 23 virtual ~PepperUDPSocket(); |
36 | 24 |
37 int routing_id() { return routing_id_; } | 25 int routing_id() { return routing_id_; } |
38 | 26 |
39 void AllowAddressReuse(bool value); | |
40 void AllowBroadcast(bool value); | |
41 void Bind(const PP_NetAddress_Private& addr); | |
42 void RecvFrom(int32_t num_bytes); | |
43 void SendTo(const std::string& data, const PP_NetAddress_Private& addr); | |
44 void SendBindACKError(); | |
45 void SendSendToACKError(); | |
46 | |
47 private: | 27 private: |
48 void SendRecvFromACKError(); | 28 // PepperUDPSocketPrivateShared implementation. |
49 | 29 virtual void SendBindReply(bool succeeded, |
50 void OnBindCompleted(int result); | 30 const PP_NetAddress_Private& addr) OVERRIDE; |
51 void OnRecvFromCompleted(int result); | 31 virtual void SendRecvFromReply(bool succeeded, |
52 void OnSendToCompleted(int result); | 32 const std::string& data, |
| 33 const PP_NetAddress_Private& addr) OVERRIDE; |
| 34 virtual void SendSendToReply(bool succeeded, int32_t bytes_written) OVERRIDE; |
53 | 35 |
54 PepperMessageFilter* manager_; | 36 PepperMessageFilter* manager_; |
55 int32 routing_id_; | 37 int32 routing_id_; |
56 uint32 plugin_dispatcher_id_; | 38 uint32 plugin_dispatcher_id_; |
57 uint32 socket_id_; | 39 uint32 socket_id_; |
58 bool allow_address_reuse_; | |
59 bool allow_broadcast_; | |
60 | |
61 scoped_ptr<net::UDPServerSocket> socket_; | |
62 | |
63 scoped_refptr<net::IOBuffer> recvfrom_buffer_; | |
64 scoped_refptr<net::IOBuffer> sendto_buffer_; | |
65 | |
66 net::IPEndPoint recvfrom_address_; | |
67 net::IPEndPoint bound_address_; | |
68 | 40 |
69 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocket); | 41 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocket); |
70 }; | 42 }; |
71 | 43 |
72 } // namespace content | 44 } // namespace content |
73 | 45 |
74 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ | 46 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ |
OLD | NEW |