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

Side by Side Diff: src/trusted/plugin/srpc/socket_address.cc

Issue 2981011: Move plugin/srpc contents to the more appropriately named plugin/common.... (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 10 years, 5 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
« no previous file with comments | « src/trusted/plugin/srpc/socket_address.h ('k') | src/trusted/plugin/srpc/srpc_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file.
5 */
6
7
8 #include <signal.h>
9 #include <string.h>
10 #include "native_client/src/trusted/plugin/srpc/browser_interface.h"
11 #include "native_client/src/trusted/plugin/srpc/connected_socket.h"
12 #include "native_client/src/trusted/plugin/srpc/plugin.h"
13 #include "native_client/src/trusted/plugin/srpc/socket_address.h"
14
15 #include "native_client/src/trusted/plugin/srpc/scriptable_handle.h"
16
17 #include "native_client/src/trusted/plugin/srpc/utility.h"
18
19 namespace {
20
21 bool RpcConnect(void* obj, plugin::SrpcParams *params) {
22 plugin::SocketAddress* socket_addr =
23 reinterpret_cast<plugin::SocketAddress*>(obj);
24 plugin::ScriptableHandle* connected_socket = socket_addr->Connect();
25 if (NULL == connected_socket) {
26 return false;
27 }
28 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT;
29 params->outs()[0]->u.oval = connected_socket;
30 return true;
31 }
32
33 } // namespace
34
35 namespace plugin {
36
37 SocketAddress* SocketAddress::New(Plugin* plugin, nacl::DescWrapper* wrapper) {
38 PLUGIN_PRINTF(("SocketAddress::New()\n"));
39 SocketAddress* socket_address = new(std::nothrow) SocketAddress();
40 if (socket_address == NULL || !socket_address->Init(plugin, wrapper)) {
41 delete socket_address;
42 return NULL;
43 }
44 return socket_address;
45 }
46
47 bool SocketAddress::Init(Plugin* plugin, nacl::DescWrapper* wrapper) {
48 if (!DescBasedHandle::Init(plugin, wrapper)) {
49 return false;
50 }
51 LoadMethods();
52 return true;
53 }
54
55 void SocketAddress::LoadMethods() {
56 // Methods implemented by SocketAddresses.
57 AddMethodCall(RpcConnect, "connect", "", "h");
58 }
59
60 SocketAddress::SocketAddress() {
61 PLUGIN_PRINTF(("SocketAddress::SocketAddress(%p)\n",
62 static_cast<void*>(this)));
63 }
64
65 SocketAddress::~SocketAddress() {
66 PLUGIN_PRINTF(("SocketAddress::~SocketAddress(%p)\n",
67 static_cast<void*>(this)));
68 }
69
70 // Returns a connected socket for the address.
71 ScriptableHandle* SocketAddress::Connect() {
72 PLUGIN_PRINTF(("SocketAddress::Connect()\n"));
73 nacl::DescWrapper* con_desc = wrapper()->Connect();
74 if (NULL == con_desc) {
75 PLUGIN_PRINTF(("SocketAddress::Connect: connect failed\n"));
76 return NULL;
77 } else {
78 PLUGIN_PRINTF(("SocketAddress::Connect: take returned %p\n",
79 static_cast<void*>(con_desc)));
80 ConnectedSocket* portable_connected_socket =
81 ConnectedSocket::New(plugin(), con_desc);
82 ScriptableHandle* connected_socket =
83 plugin()->browser_interface()->NewScriptableHandle(
84 portable_connected_socket);
85 PLUGIN_PRINTF(("SocketAddress::Connect: CS returned %p\n",
86 static_cast<void*>(connected_socket)));
87 return connected_socket;
88 }
89 }
90
91 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/srpc/socket_address.h ('k') | src/trusted/plugin/srpc/srpc_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698