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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/nacl_subprocess.cc

Issue 9390028: Remove browser support for non-PPAPI nexes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "native_client/src/trusted/plugin/nacl_subprocess.h" 5 #include "native_client/src/trusted/plugin/nacl_subprocess.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "native_client/src/trusted/plugin/browser_interface.h"
10 #include "native_client/src/trusted/plugin/method_map.h"
11 #include "native_client/src/trusted/plugin/plugin_error.h" 9 #include "native_client/src/trusted/plugin/plugin_error.h"
12 #include "native_client/src/trusted/plugin/scriptable_handle.h" 10 #include "native_client/src/trusted/plugin/scriptable_handle.h"
13 #include "native_client/src/trusted/plugin/service_runtime.h" 11 #include "native_client/src/trusted/plugin/service_runtime.h"
12 #include "native_client/src/trusted/plugin/srpc_params.h"
14 13
15 namespace plugin { 14 namespace plugin {
16 15
17 nacl::string NaClSubprocess::description() const {
18 return description_;
19 }
20
21 nacl::string NaClSubprocess::detailed_description() const { 16 nacl::string NaClSubprocess::detailed_description() const {
22 nacl::stringstream ss; 17 nacl::stringstream ss;
23 ss << description() 18 ss << description()
24 << "={ this=" << static_cast<const void*>(this) 19 << "={ this=" << static_cast<const void*>(this)
25 << ", srpc_client=" << static_cast<void*>(srpc_client_.get()) 20 << ", srpc_client=" << static_cast<void*>(srpc_client_.get())
26 << ", service_runtime=" << static_cast<void*>(service_runtime_.get()) 21 << ", service_runtime=" << static_cast<void*>(service_runtime_.get())
27 << " }"; 22 << " }";
28 return ss.str(); 23 return ss.str();
29 } 24 }
30 25
(...skipping 12 matching lines...) Expand all
43 38
44 bool NaClSubprocess::StartSrpcServices() { 39 bool NaClSubprocess::StartSrpcServices() {
45 srpc_client_.reset(service_runtime_->SetupAppChannel()); 40 srpc_client_.reset(service_runtime_->SetupAppChannel());
46 return NULL != srpc_client_.get(); 41 return NULL != srpc_client_.get();
47 } 42 }
48 43
49 bool NaClSubprocess::StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info) { 44 bool NaClSubprocess::StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info) {
50 return srpc_client_->StartJSObjectProxy(plugin, error_info); 45 return srpc_client_->StartJSObjectProxy(plugin, error_info);
51 } 46 }
52 47
53 bool NaClSubprocess::HasMethod(uintptr_t method_id) const {
54 if (NULL == srpc_client_.get()) {
55 return false;
56 }
57 return srpc_client_->HasMethod(method_id);
58 }
59
60 bool NaClSubprocess::InitParams(uintptr_t method_id, SrpcParams* params) const {
61 if (NULL == srpc_client_.get()) {
62 return false;
63 }
64 return srpc_client_->InitParams(method_id, params);
65 }
66
67 bool NaClSubprocess::Invoke(uintptr_t method_id, SrpcParams* params) const {
68 if (NULL == srpc_client_.get()) {
69 return false;
70 }
71 return srpc_client_->Invoke(method_id, params);
72 }
73
74 bool NaClSubprocess::InvokeSrpcMethod(const nacl::string& method_name, 48 bool NaClSubprocess::InvokeSrpcMethod(const nacl::string& method_name,
75 const nacl::string& input_signature, 49 const nacl::string& input_signature,
76 SrpcParams* params, 50 SrpcParams* params,
77 ...) { 51 ...) {
78 va_list vl; 52 va_list vl;
79 va_start(vl, params); 53 va_start(vl, params);
80 bool result = VInvokeSrpcMethod(method_name, input_signature, params, vl); 54 bool result = VInvokeSrpcMethod(method_name, input_signature, params, vl);
81 va_end(vl); 55 va_end(vl);
82 return result; 56 return result;
83 } 57 }
84 58
85 bool NaClSubprocess::VInvokeSrpcMethod(const nacl::string& method_name, 59 bool NaClSubprocess::VInvokeSrpcMethod(const nacl::string& method_name,
86 const nacl::string& input_signature, 60 const nacl::string& input_signature,
87 SrpcParams* params, 61 SrpcParams* params,
88 va_list vl) { 62 va_list vl) {
89 uintptr_t method_ident; 63 if (NULL == srpc_client_.get()) {
90 if (!SetupSrpcInvocation(method_name, params, &method_ident)) { 64 PLUGIN_PRINTF(("VInvokeSrpcMethod (no srpc_client_)\n"));
91 return false; 65 return false;
92 } 66 }
93 67 if (!srpc_client_->HasMethod(method_name)) {
94 // Set up inputs. 68 PLUGIN_PRINTF(("VInvokeSrpcMethod (no %s method found)\n",
69 method_name.c_str()));
70 return false;
71 }
72 if (!srpc_client_->InitParams(method_name, params)) {
73 PLUGIN_PRINTF(("VInvokeSrpcMethod (InitParams failed)\n"));
74 return false;
75 }
76 // Marshall inputs.
95 for (size_t i = 0; i < input_signature.length(); ++i) { 77 for (size_t i = 0; i < input_signature.length(); ++i) {
96 char c = input_signature[i]; 78 char c = input_signature[i];
97 // Only handle the limited number of SRPC types used for PNaCl. 79 // Only handle the limited number of SRPC types used for PNaCl.
98 // Add more as needed. 80 // Add more as needed.
99 switch (c) { 81 switch (c) {
100 default: 82 default:
101 PLUGIN_PRINTF(("PnaclSrpcLib::InvokeSrpcMethod unhandled type: %c\n", 83 PLUGIN_PRINTF(("PnaclSrpcLib::InvokeSrpcMethod unhandled type: %c\n",
102 c)); 84 c));
103 return false; 85 return false;
104 case NACL_SRPC_ARG_TYPE_BOOL: { 86 case NACL_SRPC_ARG_TYPE_BOOL: {
(...skipping 23 matching lines...) Expand all
128 params->ins()[i]->u.ival = input; 110 params->ins()[i]->u.ival = input;
129 break; 111 break;
130 } 112 }
131 case NACL_SRPC_ARG_TYPE_LONG: { 113 case NACL_SRPC_ARG_TYPE_LONG: {
132 int64_t input = va_arg(vl, int64_t); 114 int64_t input = va_arg(vl, int64_t);
133 params->ins()[i]->u.lval = input; 115 params->ins()[i]->u.lval = input;
134 break; 116 break;
135 } 117 }
136 } 118 }
137 } 119 }
138 120 return srpc_client_->Invoke(method_name, params);
139 return Invoke(method_ident, params);
140 }
141
142 bool NaClSubprocess::SetupSrpcInvocation(const nacl::string& method_name,
143 SrpcParams* params,
144 uintptr_t* method_ident) {
145 *method_ident = browser_interface_->StringToIdentifier(method_name);
146 if (!HasMethod(*method_ident)) {
147 PLUGIN_PRINTF(("SetupSrpcInvocation (no %s method found)\n",
148 method_name.c_str()));
149 return false;
150 }
151 return InitParams(*method_ident, params);
152 } 121 }
153 122
154 } // namespace plugin 123 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698