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

Side by Side Diff: src/trusted/plugin/service_runtime.cc

Issue 7108031: this patch adds the manifest proxy server to sel_ldr and the manifest (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 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/service_runtime.h ('k') | src/trusted/reverse_service/manifest_rpc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/trusted/plugin/service_runtime.h" 7 #include "native_client/src/trusted/plugin/service_runtime.h"
8 8
9 #include <utility> 9 #include <utility>
10 #include <map> 10 #include <map>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (p == NULL) { 63 if (p == NULL) {
64 NaClLog(1, "LogToJavaScriptConsole: Weak ref died\n"); 64 NaClLog(1, "LogToJavaScriptConsole: Weak ref died\n");
65 return; 65 return;
66 } 66 }
67 NaClLog(1, "LogToJavaScriptConsole: Weak ref okay: %p\n", 67 NaClLog(1, "LogToJavaScriptConsole: Weak ref okay: %p\n",
68 reinterpret_cast<void*>(p.get())); 68 reinterpret_cast<void*>(p.get()));
69 p->plugin->browser_interface()->AddToConsole(p->plugin->instance_id(), 69 p->plugin->browser_interface()->AddToConsole(p->plugin->instance_id(),
70 p->message); 70 p->message);
71 } 71 }
72 72
73 void LogToJavaScriptConsoleInterface::Log(nacl::string message) { 73 void PluginReverseInterface::Log(nacl::string message) {
74 (void) WeakRefCompletionCallback(anchor_, 0, 74 (void) WeakRefCompletionCallback(anchor_, 0,
75 LogToJavaScriptConsole, 75 LogToJavaScriptConsole,
76 new LogToJavaScriptConsoleResource( 76 new LogToJavaScriptConsoleResource(
77 message, plugin_)); 77 message, plugin_));
78 } 78 }
79 79
80 ServiceRuntime::ServiceRuntime(Plugin* plugin) 80 ServiceRuntime::ServiceRuntime(Plugin* plugin)
81 : default_socket_address_(NULL), 81 : default_socket_address_(NULL),
82 plugin_(plugin), 82 plugin_(plugin),
83 browser_interface_(plugin->browser_interface()), 83 browser_interface_(plugin->browser_interface()),
84 runtime_channel_(NULL), 84 runtime_channel_(NULL),
85 reverse_service_(NULL), 85 reverse_service_(NULL),
86 subprocess_(NULL), 86 subprocess_(NULL),
87 async_receive_desc_(NULL), 87 async_receive_desc_(NULL),
88 async_send_desc_(NULL), 88 async_send_desc_(NULL),
89 anchor_(new nacl::WeakRefAnchor()), 89 anchor_(new nacl::WeakRefAnchor()),
90 log_interface_(new LogToJavaScriptConsoleInterface(anchor_, plugin)) { 90 rev_interface_(new PluginReverseInterface(anchor_, plugin)) {
91 } 91 }
92 92
93 bool ServiceRuntime::InitCommunication(nacl::Handle bootstrap_socket, 93 bool ServiceRuntime::InitCommunication(nacl::Handle bootstrap_socket,
94 nacl::DescWrapper* nacl_desc, 94 nacl::DescWrapper* nacl_desc,
95 nacl::string* error_string) { 95 nacl::string* error_string) {
96 // TODO(sehr): this should use the new 96 // TODO(sehr): this should use the new
97 // SelLdrLauncher::OpenSrpcChannels interface, which should be free 97 // SelLdrLauncher::OpenSrpcChannels interface, which should be free
98 // of resource leaks. 98 // of resource leaks.
99 // bootstrap_socket was opened to communicate with the sel_ldr instance. 99 // bootstrap_socket was opened to communicate with the sel_ldr instance.
100 // Get the first IMC message and receive a socket address FD from it. 100 // Get the first IMC message and receive a socket address FD from it.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 PLUGIN_PRINTF(("ServiceRuntime: got 0x%"NACL_PRIxPTR"\n", 150 PLUGIN_PRINTF(("ServiceRuntime: got 0x%"NACL_PRIxPTR"\n",
151 (uintptr_t) out_conn_cap)); 151 (uintptr_t) out_conn_cap));
152 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( 152 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup(
153 out_conn_cap); 153 out_conn_cap);
154 if (conn_cap == NULL) { 154 if (conn_cap == NULL) {
155 *error_string = "ServiceRuntime: wrapper allocation failure"; 155 *error_string = "ServiceRuntime: wrapper allocation failure";
156 return false; 156 return false;
157 } 157 }
158 out_conn_cap = NULL; // ownership passed 158 out_conn_cap = NULL; // ownership passed
159 reverse_service_ = new nacl::ReverseService(conn_cap, log_interface_->Ref()); 159 reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref());
160 if (!reverse_service_->Start()) { 160 if (!reverse_service_->Start()) {
161 *error_string = "ServiceRuntime: starting reverse services failed"; 161 *error_string = "ServiceRuntime: starting reverse services failed";
162 return false; 162 return false;
163 } 163 }
164 164
165 if (nacl_desc != NULL) { 165 if (nacl_desc != NULL) {
166 // This is executed only if we already launched sel_ldr process and 166 // This is executed only if we already launched sel_ldr process and
167 // now have an open communication channel to it, so we can send 167 // now have an open communication channel to it, so we can send
168 // the descriptor for nexe over. 168 // the descriptor for nexe over.
169 if (!runtime_channel_->LoadModule(nacl_desc->desc())) { 169 if (!runtime_channel_->LoadModule(nacl_desc->desc())) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 PLUGIN_PRINTF(("ServiceRuntime::~ServiceRuntime (this=%p)\n", 334 PLUGIN_PRINTF(("ServiceRuntime::~ServiceRuntime (this=%p)\n",
335 static_cast<void*>(this))); 335 static_cast<void*>(this)));
336 336
337 // We do this just in case Terminate() was not called. 337 // We do this just in case Terminate() was not called.
338 delete subprocess_; 338 delete subprocess_;
339 delete runtime_channel_; 339 delete runtime_channel_;
340 if (reverse_service_ != NULL) { 340 if (reverse_service_ != NULL) {
341 reverse_service_->Unref(); 341 reverse_service_->Unref();
342 } 342 }
343 343
344 log_interface_->Unref(); 344 rev_interface_->Unref();
345 345
346 // TODO(sehr,mseaborn): use scoped_ptr for management of DescWrappers. 346 // TODO(sehr,mseaborn): use scoped_ptr for management of DescWrappers.
347 delete async_receive_desc_; 347 delete async_receive_desc_;
348 delete async_send_desc_; 348 delete async_send_desc_;
349 349
350 anchor_->Abandon(); 350 anchor_->Abandon();
351 anchor_->Unref(); 351 anchor_->Unref();
352 } 352 }
353 353
354 ScriptableHandle* ServiceRuntime::default_socket_address() const { 354 ScriptableHandle* ServiceRuntime::default_socket_address() const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 SocketAddress::New(plugin, descs[0])); 400 SocketAddress::New(plugin, descs[0]));
401 cleanup: 401 cleanup:
402 // TODO(sehr,mseaborn): use scoped_ptr for management of DescWrappers. 402 // TODO(sehr,mseaborn): use scoped_ptr for management of DescWrappers.
403 delete imc_desc; 403 delete imc_desc;
404 PLUGIN_PRINTF(("ServiceRuntime::GetSocketAddress (return %p)\n", 404 PLUGIN_PRINTF(("ServiceRuntime::GetSocketAddress (return %p)\n",
405 static_cast<void*>(retval))); 405 static_cast<void*>(retval)));
406 return retval; 406 return retval;
407 } 407 }
408 408
409 } // namespace plugin 409 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/service_runtime.h ('k') | src/trusted/reverse_service/manifest_rpc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698