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

Unified Diff: ppapi/shared_impl/private/tcp_server_socket_private_impl.h

Issue 9283022: Exposed Listen and Accept methods to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added shared declaration of GetPPB_TCPServerSocketPrivate_0_1_Thunk. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/private/tcp_server_socket_private_impl.h
diff --git a/ppapi/shared_impl/private/tcp_server_socket_private_impl.h b/ppapi/shared_impl/private/tcp_server_socket_private_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..e46ed99277c6bf31346ade0ef6708476f8f0d17f
--- /dev/null
+++ b/ppapi/shared_impl/private/tcp_server_socket_private_impl.h
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_H_
+#define PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_H_
+
+#include "base/compiler_specific.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/shared_impl/resource.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
+
+namespace ppapi {
+
+// This class provides the shared implementation of a
+// PPB_TCPServerSocket_Private. The functions that actually send
+// messages to browser are implemented differently for the proxied and
+// non-proxied derived classes.
+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.
+ : public thunk::PPB_TCPServerSocket_Private_API,
+ public Resource {
+public:
+ // C-tor used in Impl case.
+ TCPServerSocketPrivateImpl(PP_Instance instance, uint32 socket_id);
+ // C-tor used in Proxy case.
+ TCPServerSocketPrivateImpl(const HostResource& resource, uint32 socket_id);
+
+ virtual ~TCPServerSocketPrivateImpl();
+
+ // Resource overrides.
+ virtual PPB_TCPServerSocket_Private_API*
+ AsPPB_TCPServerSocket_Private_API() OVERRIDE;
+
+ // PPB_TCPServerSocket_Private_API implementation.
+ virtual int32_t Listen(const PP_NetAddress_Private* addr,
+ int32_t backlog,
+ PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Accept(char* tcp_socket,
+ PP_CompletionCallback callback) OVERRIDE;
+ virtual void StopListening() OVERRIDE;
+
+ // Notifications on operations completion.
+ void OnListenCompleted(bool succeeded);
+ virtual void OnAcceptCompleted(bool succeeded,
+ uint32 tcp_socket_id,
+ const PP_NetAddress_Private& local_addr,
+ const PP_NetAddress_Private& remote_addr) = 0;
+
+ // Send functions that need to be implemented differently for the
+ // proxied and non-proxied derived classes.
+ virtual void SendListen(const PP_NetAddress_Private& addr,
+ int32_t backlog) = 0;
+ virtual void SendAccept() = 0;
+ virtual void SendStopListening() = 0;
+
+protected:
+ enum State {
+ // Before listening (including a listen request is pending or a
+ // previous listen request failed).
+ BEFORE_LISTENING,
+ // Socket is successfully bound and in listening mode.
+ LISTENING,
+ // The socket is closed.
+ CLOSED,
+ };
+
+ void Init(uint32 socket_id);
+ void PostAbortAndClearIfNecessary(scoped_refptr<TrackedCallback>* callback);
+
+ PP_Instance instance_;
+ uint32 socket_id_;
+ State state_;
+
+ scoped_refptr<TrackedCallback> listen_callback_;
+ scoped_refptr<TrackedCallback> accept_callback_;
+
+ char* tcp_socket_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(TCPServerSocketPrivateImpl);
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PRIVATE_TCP_SERVER_SOCKET_PRIVATE_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698