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

Unified Diff: ppapi/proxy/tcp_socket_resource.cc

Issue 22923014: TCPSockets are switched to the new Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 7 years, 4 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
« no previous file with comments | « ppapi/proxy/tcp_socket_resource.h ('k') | ppapi/proxy/tcp_socket_resource_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/tcp_socket_resource.cc
diff --git a/ppapi/proxy/tcp_socket_resource.cc b/ppapi/proxy/tcp_socket_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..085aab3cf335bc16c2ff6dd03a6290511deb4f50
--- /dev/null
+++ b/ppapi/proxy/tcp_socket_resource.cc
@@ -0,0 +1,92 @@
+// Copyright 2013 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.
+
+#include "ppapi/proxy/tcp_socket_resource.h"
+
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_net_address_api.h"
+
+namespace ppapi {
+namespace proxy {
+
+namespace {
+
+typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API>
+ EnterNetAddressNoLock;
+
+} // namespace
+
+TCPSocketResource::TCPSocketResource(Connection connection,
+ PP_Instance instance)
+ : TCPSocketResourceBase(connection, instance, false) {
+ SendCreate(BROWSER, PpapiHostMsg_TCPSocket_Create());
+}
+
+TCPSocketResource::~TCPSocketResource() {
+ DisconnectImpl();
+}
+
+thunk::PPB_TCPSocket_API* TCPSocketResource::AsPPB_TCPSocket_API() {
+ return this;
+}
+
+int32_t TCPSocketResource::Connect(PP_Resource addr,
+ scoped_refptr<TrackedCallback> callback) {
+ EnterNetAddressNoLock enter(addr, true);
+ if (enter.failed())
+ return PP_ERROR_BADARGUMENT;
+
+ return ConnectWithNetAddressImpl(&enter.object()->GetNetAddressPrivate(),
+ callback);
+}
+
+PP_Resource TCPSocketResource::GetLocalAddress() {
+ PP_NetAddress_Private addr_private;
+ if (!GetLocalAddressImpl(&addr_private))
+ return 0;
+
+ thunk::EnterResourceCreationNoLock enter(pp_instance());
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateNetAddressFromNetAddressPrivate(
+ pp_instance(), addr_private);
+}
+
+PP_Resource TCPSocketResource::GetRemoteAddress() {
+ PP_NetAddress_Private addr_private;
+ if (!GetRemoteAddressImpl(&addr_private))
+ return 0;
+
+ thunk::EnterResourceCreationNoLock enter(pp_instance());
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateNetAddressFromNetAddressPrivate(
+ pp_instance(), addr_private);
+}
+
+int32_t TCPSocketResource::Read(char* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr<TrackedCallback> callback) {
+ return ReadImpl(buffer, bytes_to_read, callback);
+}
+
+int32_t TCPSocketResource::Write(const char* buffer,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) {
+ return WriteImpl(buffer, bytes_to_write, callback);
+}
+
+void TCPSocketResource::Close() {
+ DisconnectImpl();
+}
+
+int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name,
+ const PP_Var& value,
+ scoped_refptr<TrackedCallback> callback) {
+ return SetOptionImpl(name, value, callback);
+}
+
+} // namespace proxy
+} // namespace ppapi
« no previous file with comments | « ppapi/proxy/tcp_socket_resource.h ('k') | ppapi/proxy/tcp_socket_resource_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698