Chromium Code Reviews| 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 PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_H_ | |
| 6 #define PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_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 TCPServerSocketPrivateImpl | |
|
brettw
2012/02/07 00:15:22
This class/file should be PPB_TCPServerSocket_Shar
ygorshenin1
2012/02/07 13:42:59
Done.
| |
| 21 : public thunk::PPB_TCPServerSocket_Private_API, | |
| 22 public Resource { | |
| 23 public: | |
| 24 // C-tor used in Impl case. | |
| 25 TCPServerSocketPrivateImpl(PP_Instance instance, uint32 socket_id); | |
| 26 // C-tor used in Proxy case. | |
| 27 TCPServerSocketPrivateImpl(const HostResource& resource, uint32 socket_id); | |
| 28 | |
| 29 virtual ~TCPServerSocketPrivateImpl(); | |
| 30 | |
| 31 // Resource overrides. | |
| 32 virtual PPB_TCPServerSocket_Private_API* | |
| 33 AsPPB_TCPServerSocket_Private_API() OVERRIDE; | |
| 34 | |
| 35 // PPB_TCPServerSocket_Private_API implementation. | |
| 36 virtual int32_t Listen(const PP_NetAddress_Private* addr, | |
| 37 int32_t backlog, | |
| 38 PP_CompletionCallback callback) OVERRIDE; | |
| 39 virtual int32_t Accept(char* tcp_socket, | |
| 40 PP_CompletionCallback callback) OVERRIDE; | |
| 41 virtual void StopListening() OVERRIDE; | |
| 42 | |
| 43 // Notifications on operations completion. | |
| 44 void OnListenCompleted(bool succeeded); | |
| 45 virtual void OnAcceptCompleted(bool succeeded, | |
| 46 uint32 tcp_socket_id, | |
| 47 const PP_NetAddress_Private& local_addr, | |
| 48 const PP_NetAddress_Private& remote_addr) = 0; | |
| 49 | |
| 50 // Send functions that need to be implemented differently for the | |
| 51 // proxied and non-proxied derived classes. | |
| 52 virtual void SendListen(const PP_NetAddress_Private& addr, | |
| 53 int32_t backlog) = 0; | |
| 54 virtual void SendAccept() = 0; | |
| 55 virtual void SendStopListening() = 0; | |
| 56 | |
| 57 protected: | |
| 58 enum State { | |
| 59 // Before listening (including a listen request is pending or a | |
| 60 // previous listen request failed). | |
| 61 BEFORE_LISTENING, | |
| 62 // Socket is successfully bound and in listening mode. | |
| 63 LISTENING, | |
| 64 // The socket is closed. | |
| 65 CLOSED, | |
| 66 }; | |
| 67 | |
| 68 void Init(uint32 socket_id); | |
| 69 void PostAbortAndClearIfNecessary(scoped_refptr<TrackedCallback>* callback); | |
| 70 | |
| 71 PP_Instance instance_; | |
| 72 uint32 socket_id_; | |
| 73 State state_; | |
| 74 | |
| 75 scoped_refptr<TrackedCallback> listen_callback_; | |
| 76 scoped_refptr<TrackedCallback> accept_callback_; | |
| 77 | |
| 78 char* tcp_socket_buffer_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketPrivateImpl); | |
| 81 }; | |
| 82 | |
| 83 } // namespace ppapi | |
| 84 | |
| 85 #endif // PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_H_ | |
| OLD | NEW |