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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_udp_socket_private_shared.h

Issue 11441012: PPB_UDPSocket_Private is switched to the new Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 8 years 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 | Annotate | Revision Log
OLDNEW
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_PRIVATE_SHARED_H
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_PRIVATE_SHARED_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
14 #include "net/base/ip_endpoint.h" 15 #include "net/base/ip_endpoint.h"
15 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
16 17
17 struct PP_NetAddress_Private; 18 struct PP_NetAddress_Private;
18 19
19 namespace net { 20 namespace net {
20 class IOBuffer; 21 class IOBuffer;
21 class UDPServerSocket; 22 class UDPServerSocket;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 class PepperMessageFilter;
26 26
27 // PepperUDPSocket is used by PepperMessageFilter to handle requests from 27 // PepperUDPSocket is used by PepperMessageFilter to handle requests from
28 // the Pepper UDP socket API (PPB_UDPSocket_Private). 28 // the Pepper UDP socket API (PPB_UDPSocket_Private).
29 class PepperUDPSocket { 29 class PepperUDPSocketPrivateShared {
30 public: 30 public:
31 PepperUDPSocket(PepperMessageFilter* manager, 31 PepperUDPSocketPrivateShared();
32 int32 routing_id, 32 virtual ~PepperUDPSocketPrivateShared();
33 uint32 plugin_dispatcher_id,
34 uint32 socket_id);
35 ~PepperUDPSocket();
36 33
37 int routing_id() { return routing_id_; } 34 void SetBoolSocketFeature(int32_t name, bool value);
38
39 void AllowAddressReuse(bool value);
40 void AllowBroadcast(bool value);
41 void Bind(const PP_NetAddress_Private& addr); 35 void Bind(const PP_NetAddress_Private& addr);
42 void RecvFrom(int32_t num_bytes); 36 void RecvFrom(int32_t num_bytes);
43 void SendTo(const std::string& data, const PP_NetAddress_Private& addr); 37 void SendTo(const std::string& data, const PP_NetAddress_Private& addr);
44 void SendBindACKError(); 38 void Close();
45 void SendSendToACKError(); 39
40 void SendBindError();
41 void SendRecvFromError();
42 void SendSendToError();
43
44 protected:
45 virtual void SendBindReply(bool succeeded,
46 const PP_NetAddress_Private& addr) = 0;
47 virtual void SendRecvFromReply(bool succeeded,
48 const std::string& data,
49 const PP_NetAddress_Private& addr) = 0;
50 virtual void SendSendToReply(bool succeeded, int32_t bytes_written) = 0;
46 51
47 private: 52 private:
48 void SendRecvFromACKError();
49
50 void OnBindCompleted(int result); 53 void OnBindCompleted(int result);
51 void OnRecvFromCompleted(int result); 54 void OnRecvFromCompleted(int result);
52 void OnSendToCompleted(int result); 55 void OnSendToCompleted(int result);
53 56
54 PepperMessageFilter* manager_; 57 bool closed() { return closed_; }
55 int32 routing_id_; 58
56 uint32 plugin_dispatcher_id_;
57 uint32 socket_id_;
58 bool allow_address_reuse_; 59 bool allow_address_reuse_;
59 bool allow_broadcast_; 60 bool allow_broadcast_;
60 61
61 scoped_ptr<net::UDPServerSocket> socket_; 62 scoped_ptr<net::UDPServerSocket> socket_;
63 bool closed_;
62 64
63 scoped_refptr<net::IOBuffer> recvfrom_buffer_; 65 scoped_refptr<net::IOBuffer> recvfrom_buffer_;
64 scoped_refptr<net::IOBuffer> sendto_buffer_; 66 scoped_refptr<net::IOBuffer> sendto_buffer_;
65 67
66 net::IPEndPoint recvfrom_address_; 68 net::IPEndPoint recvfrom_address_;
67 net::IPEndPoint bound_address_; 69 net::IPEndPoint bound_address_;
68 70
69 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocket); 71 base::WeakPtrFactory<PepperUDPSocketPrivateShared> weak_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(PepperUDPSocketPrivateShared);
70 }; 74 };
71 75
72 } // namespace content 76 } // namespace content
73 77
74 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_H_ 78 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_UDP_SOCKET_PRIVATE_SHARED _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698