| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.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 | |
| 24 namespace content { | |
| 25 class PepperMessageFilter; | |
| 26 | |
| 27 // PepperUDPSocket is used by PepperMessageFilter to handle requests from | |
| 28 // the Pepper UDP socket API (PPB_UDPSocket_Private). | |
| 29 class PepperUDPSocket { | |
| 30 public: | |
| 31 PepperUDPSocket(PepperMessageFilter* manager, | |
| 32 int32 routing_id, | |
| 33 uint32 plugin_dispatcher_id, | |
| 34 uint32 socket_id); | |
| 35 ~PepperUDPSocket(); | |
| 36 | |
| 37 int routing_id() { return routing_id_; } | |
| 38 | |
| 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: | |
| 48 void SendRecvFromACKError(); | |
| 49 | |
| 50 void OnBindCompleted(int result); | |
| 51 void OnRecvFromCompleted(int result); | |
| 52 void OnSendToCompleted(int result); | |
| 53 | |
| 54 PepperMessageFilter* manager_; | |
| 55 int32 routing_id_; | |
| 56 uint32 plugin_dispatcher_id_; | |
| 57 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 | |
| 69 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocket); | |
| 70 }; | |
| 71 | |
| 72 } // namespace content | |
| 73 | |
| 74 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ | |
| OLD | NEW |