| 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/plugin.h" | 7 #include "native_client/src/trusted/plugin/plugin.h" |
| 8 | 8 |
| 9 #include <assert.h> | 9 #include <assert.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 plugin::SharedMemory::New(plugin, params->ins()[0]->u.ival); | 59 plugin::SharedMemory::New(plugin, params->ins()[0]->u.ival); |
| 60 plugin::ScriptableHandle* shared_memory = | 60 plugin::ScriptableHandle* shared_memory = |
| 61 plugin->browser_interface()->NewScriptableHandle(portable_shared_memory); | 61 plugin->browser_interface()->NewScriptableHandle(portable_shared_memory); |
| 62 if (NULL == shared_memory) { | 62 if (NULL == shared_memory) { |
| 63 params->set_exception_string("out of memory"); | 63 params->set_exception_string("out of memory"); |
| 64 portable_shared_memory->Delete(); | 64 portable_shared_memory->Delete(); |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT; | 68 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT; |
| 69 params->outs()[0]->u.oval = shared_memory; | 69 params->outs()[0]->arrays.oval = shared_memory; |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool DefaultSocketAddress(void* obj, plugin::SrpcParams* params) { | 73 bool DefaultSocketAddress(void* obj, plugin::SrpcParams* params) { |
| 74 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); | 74 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); |
| 75 if (NULL == plugin->socket_address()) { | 75 if (NULL == plugin->socket_address()) { |
| 76 params->set_exception_string("no socket address"); | 76 params->set_exception_string("no socket address"); |
| 77 return false; | 77 return false; |
| 78 } | 78 } |
| 79 // Plug the scriptable object into the return values. | 79 // Plug the scriptable object into the return values. |
| 80 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT; | 80 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_OBJECT; |
| 81 params->outs()[0]->u.oval = plugin->socket_address()->AddRef(); | 81 params->outs()[0]->arrays.oval = plugin->socket_address()->AddRef(); |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // A method to test the cost of invoking a method in a plugin without | 85 // A method to test the cost of invoking a method in a plugin without |
| 86 // making an RPC to the service runtime. Used for performance evaluation. | 86 // making an RPC to the service runtime. Used for performance evaluation. |
| 87 bool NullPluginMethod(void* obj, plugin::SrpcParams* params) { | 87 bool NullPluginMethod(void* obj, plugin::SrpcParams* params) { |
| 88 UNREFERENCED_PARAMETER(obj); | 88 UNREFERENCED_PARAMETER(obj); |
| 89 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_INT; | 89 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_INT; |
| 90 params->outs()[0]->u.ival = 0; | 90 params->outs()[0]->u.ival = 0; |
| 91 return true; | 91 return true; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 UNREFERENCED_PARAMETER(obj); | 111 UNREFERENCED_PARAMETER(obj); |
| 112 UNREFERENCED_PARAMETER(params); | 112 UNREFERENCED_PARAMETER(params); |
| 113 params->set_exception_string("__nexes is a write-only property"); | 113 params->set_exception_string("__nexes is a write-only property"); |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Update "nexes", a write-only property that computes a value to | 117 // Update "nexes", a write-only property that computes a value to |
| 118 // assign to the "src" property based on the supported sandbox. | 118 // assign to the "src" property based on the supported sandbox. |
| 119 bool SetNexesProperty(void* obj, plugin::SrpcParams* params) { | 119 bool SetNexesProperty(void* obj, plugin::SrpcParams* params) { |
| 120 return reinterpret_cast<plugin::Plugin*>(obj)-> | 120 return reinterpret_cast<plugin::Plugin*>(obj)-> |
| 121 SetNexesPropertyImpl(params->ins()[0]->u.sval.str); | 121 SetNexesPropertyImpl(params->ins()[0]->arrays.str); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool GetSrcProperty(void* obj, plugin::SrpcParams* params) { | 124 bool GetSrcProperty(void* obj, plugin::SrpcParams* params) { |
| 125 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); | 125 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); |
| 126 const char* url = plugin->nacl_module_url().c_str(); | 126 const char* url = plugin->nacl_module_url().c_str(); |
| 127 PLUGIN_PRINTF(("GetSrcProperty ('src'='%s')\n", url)); | 127 PLUGIN_PRINTF(("GetSrcProperty ('src'='%s')\n", url)); |
| 128 if (NACL_NO_URL != plugin->nacl_module_url()) { | 128 if (NACL_NO_URL != plugin->nacl_module_url()) { |
| 129 params->outs()[0]->u.sval.str = strdup(url); | 129 params->outs()[0]->arrays.str = strdup(url); |
| 130 return true; | 130 return true; |
| 131 } else { | 131 } else { |
| 132 // No url to set 'src' to. | 132 // No url to set 'src' to. |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool SetSrcProperty(void* obj, plugin::SrpcParams* params) { | 137 bool SetSrcProperty(void* obj, plugin::SrpcParams* params) { |
| 138 PLUGIN_PRINTF(("SetSrcProperty ()\n")); | 138 PLUGIN_PRINTF(("SetSrcProperty ()\n")); |
| 139 return reinterpret_cast<plugin::Plugin*>(obj)-> | 139 return reinterpret_cast<plugin::Plugin*>(obj)-> |
| 140 SetSrcPropertyImpl(params->ins()[0]->u.sval.str); | 140 SetSrcPropertyImpl(params->ins()[0]->arrays.str); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool GetHeightProperty(void* obj, plugin::SrpcParams* params) { | 143 bool GetHeightProperty(void* obj, plugin::SrpcParams* params) { |
| 144 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); | 144 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); |
| 145 params->outs()[0]->u.ival = plugin->height(); | 145 params->outs()[0]->u.ival = plugin->height(); |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool SetHeightProperty(void* obj, plugin::SrpcParams* params) { | 149 bool SetHeightProperty(void* obj, plugin::SrpcParams* params) { |
| 150 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); | 150 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 bool Plugin::SendAsyncMessage(void* obj, SrpcParams* params, | 190 bool Plugin::SendAsyncMessage(void* obj, SrpcParams* params, |
| 191 nacl::DescWrapper** fds, int fds_count) { | 191 nacl::DescWrapper** fds, int fds_count) { |
| 192 Plugin* plugin = reinterpret_cast<Plugin*>(obj); | 192 Plugin* plugin = reinterpret_cast<Plugin*>(obj); |
| 193 if (plugin->service_runtime_ == NULL) { | 193 if (plugin->service_runtime_ == NULL) { |
| 194 params->set_exception_string("No subprocess running"); | 194 params->set_exception_string("No subprocess running"); |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 | 197 |
| 198 // TODO(mseaborn): Handle strings containing NULLs. This might | 198 // TODO(mseaborn): Handle strings containing NULLs. This might |
| 199 // involve using a different SRPC type. | 199 // involve using a different SRPC type. |
| 200 char* utf8string = params->ins()[0]->u.sval.str; | 200 char* utf8string = params->ins()[0]->arrays.str; |
| 201 char* data; | 201 char* data; |
| 202 size_t data_size; | 202 size_t data_size; |
| 203 if (!ByteStringFromUTF8(utf8string, strlen(utf8string), &data, &data_size)) { | 203 if (!ByteStringFromUTF8(utf8string, strlen(utf8string), &data, &data_size)) { |
| 204 params->set_exception_string("Invalid string"); | 204 params->set_exception_string("Invalid string"); |
| 205 return false; | 205 return false; |
| 206 } | 206 } |
| 207 nacl::DescWrapper::MsgIoVec iov; | 207 nacl::DescWrapper::MsgIoVec iov; |
| 208 nacl::DescWrapper::MsgHeader message; | 208 nacl::DescWrapper::MsgHeader message; |
| 209 iov.base = data; | 209 iov.base = data; |
| 210 iov.length = static_cast<nacl_abi_size_t>(data_size); | 210 iov.length = static_cast<nacl_abi_size_t>(data_size); |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 743 |
| 744 void VideoGlobalLock() { | 744 void VideoGlobalLock() { |
| 745 g_VideoMutex.Lock(); | 745 g_VideoMutex.Lock(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void VideoGlobalUnlock() { | 748 void VideoGlobalUnlock() { |
| 749 g_VideoMutex.Unlock(); | 749 g_VideoMutex.Unlock(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 } // namespace plugin | 752 } // namespace plugin |
| OLD | NEW |