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

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

Issue 2961004: Plugin: Remove __socketAddressFactory() and toString() on SocketAddresses (Closed)
Patch Set: Apply HTML changes to copies in "prebuilt" too 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
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Native Client Authors. All rights reserved. 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 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/trusted/plugin/srpc/plugin.h" 7 #include "native_client/src/trusted/plugin/srpc/plugin.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // A method to test the cost of invoking a method in a plugin without 81 // A method to test the cost of invoking a method in a plugin without
82 // making an RPC to the service runtime. Used for performance evaluation. 82 // making an RPC to the service runtime. Used for performance evaluation.
83 bool NullPluginMethod(void* obj, plugin::SrpcParams* params) { 83 bool NullPluginMethod(void* obj, plugin::SrpcParams* params) {
84 UNREFERENCED_PARAMETER(obj); 84 UNREFERENCED_PARAMETER(obj);
85 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_INT; 85 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_INT;
86 params->outs()[0]->u.ival = 0; 86 params->outs()[0]->u.ival = 0;
87 return true; 87 return true;
88 } 88 }
89 89
90 bool SocketAddressFactory(void* obj, plugin::SrpcParams* params) {
91 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj);
92 // Type check the input parameter.
93 if (NACL_SRPC_ARG_TYPE_STRING != params->ins()[0]->tag) {
94 return false;
95 }
96 char* str = params->ins()[0]->u.sval;
97 nacl::DescWrapper* wrapper =
98 plugin->wrapper_factory()->MakeSocketAddress(str);
99 if (NULL == wrapper) {
100 return false;
101 }
102 // Create a scriptable object to return.
103 plugin::SocketAddress* portable_socket_address =
104 plugin::SocketAddress::New(plugin, wrapper);
105 plugin::ScriptableHandle* socket_address =
106 plugin->browser_interface()->NewScriptableHandle(portable_socket_address);
107 if (NULL == socket_address) {
108 wrapper->Delete();
109 params->set_exception_string("out of memory");
110 portable_socket_address->Delete();
111 return false;
112 }
113 // Plug the scriptable object into the return values.
114 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT;
115 params->outs()[0]->u.oval = socket_address;
116 return true;
117 }
118
119 bool GetModuleReadyProperty(void* obj, plugin::SrpcParams* params) { 90 bool GetModuleReadyProperty(void* obj, plugin::SrpcParams* params) {
120 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); 91 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj);
121 if (plugin->socket()) { 92 if (plugin->socket()) {
122 params->outs()[0]->u.ival = 1; 93 params->outs()[0]->u.ival = 1;
123 } else { 94 } else {
124 params->outs()[0]->u.ival = 0; 95 params->outs()[0]->u.ival = 0;
125 } 96 }
126 return true; 97 return true;
127 } 98 }
128 99
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 180
210 } // namespace 181 } // namespace
211 182
212 namespace plugin { 183 namespace plugin {
213 184
214 static int const kAbiHeaderBuffer = 256; // must be at least EI_ABIVERSION + 1 185 static int const kAbiHeaderBuffer = 256; // must be at least EI_ABIVERSION + 1
215 186
216 void Plugin::LoadMethods() { 187 void Plugin::LoadMethods() {
217 // Methods supported by Plugin. 188 // Methods supported by Plugin.
218 AddMethodCall(ShmFactory, "__shmFactory", "i", "h"); 189 AddMethodCall(ShmFactory, "__shmFactory", "i", "h");
219 AddMethodCall(SocketAddressFactory, "__socketAddressFactory", "s", "h");
220 AddMethodCall(DefaultSocketAddress, "__defaultSocketAddress", "", "h"); 190 AddMethodCall(DefaultSocketAddress, "__defaultSocketAddress", "", "h");
221 AddMethodCall(NullPluginMethod, "__nullPluginMethod", "s", "i"); 191 AddMethodCall(NullPluginMethod, "__nullPluginMethod", "s", "i");
222 // Properties implemented by Plugin. 192 // Properties implemented by Plugin.
223 AddPropertyGet(GetHeightProperty, "height", "i"); 193 AddPropertyGet(GetHeightProperty, "height", "i");
224 AddPropertySet(SetHeightProperty, "height", "i"); 194 AddPropertySet(SetHeightProperty, "height", "i");
225 AddPropertyGet(GetModuleReadyProperty, "__moduleReady", "i"); 195 AddPropertyGet(GetModuleReadyProperty, "__moduleReady", "i");
226 AddPropertySet(SetModuleReadyProperty, "__moduleReady", "i"); 196 AddPropertySet(SetModuleReadyProperty, "__moduleReady", "i");
227 AddPropertyGet(GetNexesProperty, "nexes", "s"); 197 AddPropertyGet(GetNexesProperty, "nexes", "s");
228 AddPropertySet(SetNexesProperty, "nexes", "s"); 198 AddPropertySet(SetNexesProperty, "nexes", "s");
229 AddPropertyGet(GetSrcProperty, "src", "s"); 199 AddPropertyGet(GetSrcProperty, "src", "s");
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 558
589 void VideoGlobalLock() { 559 void VideoGlobalLock() {
590 g_VideoMutex.Lock(); 560 g_VideoMutex.Lock();
591 } 561 }
592 562
593 void VideoGlobalUnlock() { 563 void VideoGlobalUnlock() {
594 g_VideoMutex.Unlock(); 564 g_VideoMutex.Unlock();
595 } 565 }
596 566
597 } // namespace plugin 567 } // namespace plugin
OLDNEW
« no previous file with comments | « src/native_client/src/trusted/desc/nacl_desc_wrapper.cc ('k') | src/native_client/src/trusted/plugin/srpc/socket_address.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698