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_UDP_SOCKET_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_UDP_SOCKET_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "net/base/completion_callback.h" | |
15 #include "net/base/ip_endpoint.h" | |
16 #include "ppapi/c/pp_stdint.h" | |
17 | |
18 class PepperMessageFilter; | |
19 struct PP_NetAddress_Private; | |
20 | |
21 namespace net { | |
22 class IOBuffer; | |
23 class UDPServerSocket; | |
24 } | |
25 | |
26 // PepperUDPSocket is used by PepperMessageFilter to handle requests from | |
27 // the Pepper UDP socket API (PPB_UDPSocket_Private). | |
28 class PepperUDPSocket { | |
29 public: | |
30 PepperUDPSocket(PepperMessageFilter* manager, | |
31 int32 routing_id, | |
32 uint32 plugin_dispatcher_id, | |
33 uint32 socket_id); | |
34 ~PepperUDPSocket(); | |
35 | |
36 int routing_id() { return routing_id_; } | |
37 | |
38 void Bind(const PP_NetAddress_Private& addr); | |
39 void RecvFrom(int32_t num_bytes); | |
40 void SendTo(const std::string& data, const PP_NetAddress_Private& addr); | |
41 void SendBindACKError(); | |
42 | |
43 private: | |
44 void SendRecvFromACKError(); | |
45 void SendSendToACKError(); | |
46 | |
47 void OnBindCompleted(int result); | |
48 void OnRecvFromCompleted(int result); | |
49 void OnSendToCompleted(int result); | |
50 | |
51 PepperMessageFilter* manager_; | |
52 int32 routing_id_; | |
53 uint32 plugin_dispatcher_id_; | |
54 uint32 socket_id_; | |
55 | |
56 scoped_ptr<net::UDPServerSocket> socket_; | |
57 | |
58 scoped_refptr<net::IOBuffer> recvfrom_buffer_; | |
59 scoped_refptr<net::IOBuffer> sendto_buffer_; | |
60 | |
61 net::IPEndPoint recvfrom_address_; | |
62 net::IPEndPoint bound_address_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocket); | |
65 }; | |
66 | |
67 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_UDP_SOCKET_H_ | |
OLD | NEW |