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

Side by Side Diff: ppapi/shared_impl/private/udp_socket_private_impl.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 7 years, 11 months 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
(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 PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "ppapi/shared_impl/resource.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
14
15 namespace ppapi {
16
17 // This class provides the shared implementation of a
18 // PPB_UDPSocket_Private. The functions that actually send messages
19 // to browser are implemented differently for the proxied and
20 // non-proxied derived classes.
21 class PPAPI_SHARED_EXPORT UDPSocketPrivateImpl
22 : public thunk::PPB_UDPSocket_Private_API,
23 public Resource {
24 public:
25 // C-tor used in Impl case.
26 UDPSocketPrivateImpl(PP_Instance instance, uint32 socket_id);
27 // C-tor used in Proxy case.
28 UDPSocketPrivateImpl(const HostResource& resource, uint32 socket_id);
29
30 virtual ~UDPSocketPrivateImpl();
31
32 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_RecvFrom
33 // message is allowed to request.
34 static const int32_t kMaxReadSize;
35 // The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
36 // message is allowed to carry.
37 static const int32_t kMaxWriteSize;
38
39 // Resource overrides.
40 virtual PPB_UDPSocket_Private_API* AsPPB_UDPSocket_Private_API() OVERRIDE;
41
42 // PPB_UDPSocket_Private_API implementation.
43 virtual int32_t SetSocketFeature(PP_UDPSocketFeature_Private name,
44 PP_Var value) OVERRIDE;
45 virtual int32_t Bind(const PP_NetAddress_Private* addr,
46 scoped_refptr<TrackedCallback> callback) OVERRIDE;
47 virtual PP_Bool GetBoundAddress(PP_NetAddress_Private* addr) OVERRIDE;
48 virtual int32_t RecvFrom(char* buffer,
49 int32_t num_bytes,
50 scoped_refptr<TrackedCallback> callback) OVERRIDE;
51 virtual PP_Bool GetRecvFromAddress(PP_NetAddress_Private* addr) OVERRIDE;
52 virtual int32_t SendTo(const char* buffer,
53 int32_t num_bytes,
54 const PP_NetAddress_Private* addr,
55 scoped_refptr<TrackedCallback> callback) OVERRIDE;
56 virtual void Close() OVERRIDE;
57
58 // Notifications from the proxy.
59 void OnBindCompleted(bool succeeded,
60 const PP_NetAddress_Private& bound_addr);
61 void OnRecvFromCompleted(bool succeeded,
62 const std::string& data,
63 const PP_NetAddress_Private& addr);
64 void OnSendToCompleted(bool succeeded, int32_t bytes_written);
65
66 // Send functions that need to be implemented differently for
67 // the proxied and non-proxied derived classes.
68 virtual void SendBoolSocketFeature(int32_t name, bool value) = 0;
69 virtual void SendBind(const PP_NetAddress_Private& addr) = 0;
70 virtual void SendRecvFrom(int32_t num_bytes) = 0;
71 virtual void SendSendTo(const std::string& buffer,
72 const PP_NetAddress_Private& addr) = 0;
73 virtual void SendClose() = 0;
74
75 protected:
76 void Init(uint32 socket_id);
77 void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback);
78
79 uint32 socket_id_;
80
81 bool bound_;
82 bool closed_;
83
84 scoped_refptr<TrackedCallback> bind_callback_;
85 scoped_refptr<TrackedCallback> recvfrom_callback_;
86 scoped_refptr<TrackedCallback> sendto_callback_;
87
88 char* read_buffer_;
89 int32_t bytes_to_read_;
90
91 PP_NetAddress_Private recvfrom_addr_;
92 PP_NetAddress_Private bound_addr_;
93
94 DISALLOW_COPY_AND_ASSIGN(UDPSocketPrivateImpl);
95 };
96
97 } // namespace ppapi
98
99 #endif // PPAPI_SHARED_IMPL_PRIVATE_UDP_SOCKET_PRIVATE_IMPL_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/udp_socket_private_resource.cc ('k') | ppapi/shared_impl/private/udp_socket_private_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698