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

Side by Side Diff: ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h

Issue 9283022: Exposed Listen and Accept methods to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Changed type of tcp_socket_buffer_ field of PPB_TCPServerSocket_Private class. Created 8 years, 10 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
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_PPB_TCP_SERVER_SOCKET_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_TCP_SERVER_SOCKET_SHARED_H_
7
8 #include "base/compiler_specific.h"
9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/shared_impl/resource.h"
11 #include "ppapi/shared_impl/tracked_callback.h"
12 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
13
14 namespace ppapi {
15
16 // This class provides the shared implementation of a
17 // PPB_TCPServerSocket_Private. The functions that actually send
18 // messages to browser are implemented differently for the proxied and
19 // non-proxied derived classes.
20 class PPAPI_SHARED_EXPORT PPB_TCPServerSocket_Shared
21 : public thunk::PPB_TCPServerSocket_Private_API,
22 public Resource {
23 public:
brettw 2012/02/09 00:13:48 Style: public/protected should be indented one spa
ygorshenin1 2012/02/09 15:00:10 Done.
24 // C-tor used in Impl case.
25 PPB_TCPServerSocket_Shared(PP_Instance instance);
26 // C-tor used in Proxy case.
27 PPB_TCPServerSocket_Shared(const HostResource& resource);
28
29 virtual ~PPB_TCPServerSocket_Shared();
30
31 // Resource overrides.
32 virtual PPB_TCPServerSocket_Private_API*
33 AsPPB_TCPServerSocket_Private_API() OVERRIDE;
34
35 // Must be called for proper initialization of TCPServerSocket object before
36 // any other calls, such as Listen, Accept of StopListening.
37 int32_t Initialize(PP_CompletionCallback callback);
38
39 // PPB_TCPServerSocket_Private_API implementation.
40 virtual int32_t Listen(const PP_NetAddress_Private* addr,
41 int32_t backlog,
42 PP_CompletionCallback callback) OVERRIDE;
43 virtual int32_t Accept(PP_Resource* tcp_socket,
44 PP_CompletionCallback callback) OVERRIDE;
45 virtual void StopListening() OVERRIDE;
46
47 // Notifications on operations completion.
48 void OnInitializeCompleted(uint32 socket_id);
49 void OnListenCompleted(bool succeeded);
50 virtual void OnAcceptCompleted(bool succeeded,
51 uint32 tcp_socket_id,
52 const PP_NetAddress_Private& local_addr,
53 const PP_NetAddress_Private& remote_addr) = 0;
54
55 // Send functions that need to be implemented differently for the
56 // proxied and non-proxied derived classes.
57 virtual void SendInitialize() = 0;
58 virtual void SendListen(const PP_NetAddress_Private& addr,
59 int32_t backlog) = 0;
60 virtual void SendAccept() = 0;
61 virtual void SendStopListening() = 0;
62
63 protected:
64 enum State {
65 // Object of this class is created, but not initialized with
66 // correct value of socket_id_.
67 NOT_INITIALIZED,
68 // Before listening (including a listen request is pending or a
69 // previous listen request failed).
70 BEFORE_LISTENING,
71 // Socket is successfully bound and in listening mode.
72 LISTENING,
73 // The socket is closed.
74 CLOSED,
brettw 2012/02/09 00:13:48 The nacl toolchain (which we'll eventually compile
ygorshenin1 2012/02/09 15:00:10 Done.
75 };
76
77 void InternalInitialize(uint32 socket_id);
78 void PostAbortAndClearIfNecessary(scoped_refptr<TrackedCallback>* callback);
79
80 PP_Instance instance_;
brettw 2012/02/09 00:13:48 The resource base class will keep track of the ins
ygorshenin1 2012/02/09 15:00:10 Done.
81 uint32 socket_id_;
82 State state_;
83
84 scoped_refptr<TrackedCallback> initialize_callback_;
85 scoped_refptr<TrackedCallback> listen_callback_;
86 scoped_refptr<TrackedCallback> accept_callback_;
87
88 PP_Resource* tcp_socket_buffer_;
89
90 DISALLOW_COPY_AND_ASSIGN(PPB_TCPServerSocket_Shared);
91 };
92
93 } // namespace ppapi
94
95 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_TCP_SERVER_SOCKET_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698