| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |