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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/service_runtime.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 /* 1 /*
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2012 The Chromium 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 #define NACL_LOG_MODULE_NAME "Plugin::ServiceRuntime" 7 #define NACL_LOG_MODULE_NAME "Plugin::ServiceRuntime"
8 8
9 #include "native_client/src/trusted/plugin/service_runtime.h" 9 #include "native_client/src/trusted/plugin/service_runtime.h"
10 10
(...skipping 15 matching lines...) Expand all
26 #include "native_client/src/shared/platform/nacl_log.h" 26 #include "native_client/src/shared/platform/nacl_log.h"
27 #include "native_client/src/shared/platform/nacl_sync.h" 27 #include "native_client/src/shared/platform/nacl_sync.h"
28 #include "native_client/src/shared/platform/nacl_sync_checked.h" 28 #include "native_client/src/shared/platform/nacl_sync_checked.h"
29 #include "native_client/src/shared/platform/nacl_sync_raii.h" 29 #include "native_client/src/shared/platform/nacl_sync_raii.h"
30 #include "native_client/src/shared/platform/scoped_ptr_refcount.h" 30 #include "native_client/src/shared/platform/scoped_ptr_refcount.h"
31 #include "native_client/src/trusted/desc/nacl_desc_imc.h" 31 #include "native_client/src/trusted/desc/nacl_desc_imc.h"
32 #include "native_client/src/trusted/desc/nrd_xfer.h" 32 #include "native_client/src/trusted/desc/nrd_xfer.h"
33 #include "native_client/src/trusted/desc/nrd_xfer_effector.h" 33 #include "native_client/src/trusted/desc/nrd_xfer_effector.h"
34 #include "native_client/src/trusted/handle_pass/browser_handle.h" 34 #include "native_client/src/trusted/handle_pass/browser_handle.h"
35 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" 35 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
36
37 // browser_interface includes portability.h for uintptr_t etc, but it
38 // also transitively includes windows.h, where PostMessage gets
39 // defined as a preprocessor symbol
40 #include "native_client/src/trusted/plugin/browser_interface.h"
41
42 #include "native_client/src/trusted/plugin/manifest.h" 36 #include "native_client/src/trusted/plugin/manifest.h"
43 37
44 // This is here due to a Windows API collision; plugin.h through 38 // This is here due to a Windows API collision; plugin.h through
45 // file_downloader.h transitively includes Instance.h which defines a 39 // file_downloader.h transitively includes Instance.h which defines a
46 // PostMessage method, so this undef must appear before any of those. 40 // PostMessage method, so this undef must appear before any of those.
47 #ifdef PostMessage 41 #ifdef PostMessage
48 #undef PostMessage 42 #undef PostMessage
49 #endif 43 #endif
50 #include "native_client/src/trusted/plugin/plugin.h" 44 #include "native_client/src/trusted/plugin/plugin.h"
51 #include "native_client/src/trusted/plugin/plugin_error.h" 45 #include "native_client/src/trusted/plugin/plugin_error.h"
52 #include "native_client/src/trusted/plugin/scriptable_handle.h"
53 #include "native_client/src/trusted/plugin/srpc_client.h" 46 #include "native_client/src/trusted/plugin/srpc_client.h"
54 #include "native_client/src/trusted/plugin/utility.h" 47 #include "native_client/src/trusted/plugin/utility.h"
55 48
56 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h" 49 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h"
57 50
58 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 51 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
59 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h" 52 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h"
60 53
61 #include "ppapi/c/pp_errors.h" 54 #include "ppapi/c/pp_errors.h"
62 #include "ppapi/cpp/core.h" 55 #include "ppapi/cpp/core.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 129 }
137 } 130 }
138 131
139 void PluginReverseInterface::Log_MainThreadContinuation( 132 void PluginReverseInterface::Log_MainThreadContinuation(
140 LogToJavaScriptConsoleResource* p, 133 LogToJavaScriptConsoleResource* p,
141 int32_t err) { 134 int32_t err) {
142 UNREFERENCED_PARAMETER(err); 135 UNREFERENCED_PARAMETER(err);
143 NaClLog(4, 136 NaClLog(4,
144 "PluginReverseInterface::Log_MainThreadContinuation(%s)\n", 137 "PluginReverseInterface::Log_MainThreadContinuation(%s)\n",
145 p->message.c_str()); 138 p->message.c_str());
146 plugin_->browser_interface()->AddToConsole(static_cast<Plugin*>(plugin_), 139 plugin_->AddToConsole(p->message);
147 p->message);
148 } 140 }
149 void PluginReverseInterface::PostMessage_MainThreadContinuation( 141 void PluginReverseInterface::PostMessage_MainThreadContinuation(
150 PostMessageResource* p, 142 PostMessageResource* p,
151 int32_t err) { 143 int32_t err) {
152 UNREFERENCED_PARAMETER(err); 144 UNREFERENCED_PARAMETER(err);
153 NaClLog(4, 145 NaClLog(4,
154 "PluginReverseInterface::PostMessage_MainThreadContinuation(%s)\n", 146 "PluginReverseInterface::PostMessage_MainThreadContinuation(%s)\n",
155 p->message.c_str()); 147 p->message.c_str());
156 plugin_->PostMessage(std::string("DEBUG_POSTMESSAGE:") + p->message); 148 plugin_->PostMessage(std::string("DEBUG_POSTMESSAGE:") + p->message);
157 } 149 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 service_runtime_->set_exit_status(exit_status); 372 service_runtime_->set_exit_status(exit_status);
381 } 373 }
382 374
383 ServiceRuntime::ServiceRuntime(Plugin* plugin, 375 ServiceRuntime::ServiceRuntime(Plugin* plugin,
384 const Manifest* manifest, 376 const Manifest* manifest,
385 bool should_report_uma, 377 bool should_report_uma,
386 pp::CompletionCallback init_done_cb, 378 pp::CompletionCallback init_done_cb,
387 pp::CompletionCallback crash_cb) 379 pp::CompletionCallback crash_cb)
388 : plugin_(plugin), 380 : plugin_(plugin),
389 should_report_uma_(should_report_uma), 381 should_report_uma_(should_report_uma),
390 browser_interface_(plugin->browser_interface()),
391 reverse_service_(NULL), 382 reverse_service_(NULL),
392 subprocess_(NULL), 383 subprocess_(NULL),
393 async_receive_desc_(NULL),
394 async_send_desc_(NULL),
395 anchor_(new nacl::WeakRefAnchor()), 384 anchor_(new nacl::WeakRefAnchor()),
396 rev_interface_(new PluginReverseInterface(anchor_, plugin, 385 rev_interface_(new PluginReverseInterface(anchor_, plugin,
397 manifest, 386 manifest,
398 this, 387 this,
399 init_done_cb, crash_cb)), 388 init_done_cb, crash_cb)),
400 exit_status_(-1) { 389 exit_status_(-1) {
401 NaClSrpcChannelInitialize(&command_channel_); 390 NaClSrpcChannelInitialize(&command_channel_);
402 NaClXMutexCtor(&mu_); 391 NaClXMutexCtor(&mu_);
403 } 392 }
404 393
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return false; 510 return false;
522 } 511 }
523 nacl::Handle sockets[3]; 512 nacl::Handle sockets[3];
524 if (!tmp_subprocess->Start(NACL_ARRAY_SIZE(sockets), sockets)) { 513 if (!tmp_subprocess->Start(NACL_ARRAY_SIZE(sockets), sockets)) {
525 PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n")); 514 PLUGIN_PRINTF(("ServiceRuntime::Start (start failed)\n"));
526 error_info->SetReport(ERROR_SEL_LDR_LAUNCH, 515 error_info->SetReport(ERROR_SEL_LDR_LAUNCH,
527 "ServiceRuntime: failed to start"); 516 "ServiceRuntime: failed to start");
528 return false; 517 return false;
529 } 518 }
530 519
531 async_receive_desc_.reset(
532 plugin()->wrapper_factory()->MakeImcSock(sockets[1]));
533 async_send_desc_.reset(plugin()->wrapper_factory()->MakeImcSock(sockets[2]));
534
535 subprocess_.reset(tmp_subprocess.release()); 520 subprocess_.reset(tmp_subprocess.release());
536 if (!InitCommunication(nacl_desc, error_info)) { 521 if (!InitCommunication(nacl_desc, error_info)) {
537 subprocess_.reset(NULL); 522 subprocess_.reset(NULL);
538 return false; 523 return false;
539 } 524 }
540 525
541 PLUGIN_PRINTF(("ServiceRuntime::Start (return 1)\n")); 526 PLUGIN_PRINTF(("ServiceRuntime::Start (return 1)\n"));
542 return true; 527 return true;
543 } 528 }
544 529
545 SrpcClient* ServiceRuntime::SetupAppChannel() { 530 SrpcClient* ServiceRuntime::SetupAppChannel() {
546 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", 531 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (subprocess_=%p)\n",
547 reinterpret_cast<void*>(subprocess_.get()))); 532 reinterpret_cast<void*>(subprocess_.get())));
548 nacl::DescWrapper* connect_desc = subprocess_->socket_addr()->Connect(); 533 nacl::DescWrapper* connect_desc = subprocess_->socket_addr()->Connect();
549 if (NULL == connect_desc) { 534 if (NULL == connect_desc) {
550 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (connect failed)\n")); 535 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (connect failed)\n"));
551 return NULL; 536 return NULL;
552 } else { 537 } else {
553 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (conect_desc=%p)\n", 538 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (conect_desc=%p)\n",
554 static_cast<void*>(connect_desc))); 539 static_cast<void*>(connect_desc)));
555 SrpcClient* srpc_client = SrpcClient::New(plugin(), connect_desc); 540 SrpcClient* srpc_client = SrpcClient::New(connect_desc);
556 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (srpc_client=%p)\n", 541 PLUGIN_PRINTF(("ServiceRuntime::SetupAppChannel (srpc_client=%p)\n",
557 static_cast<void*>(srpc_client))); 542 static_cast<void*>(srpc_client)));
558 delete connect_desc; 543 delete connect_desc;
559 return srpc_client; 544 return srpc_client;
560 } 545 }
561 } 546 }
562 547
563 bool ServiceRuntime::Kill() { 548 bool ServiceRuntime::Kill() {
564 return subprocess_->KillChildProcess(); 549 return subprocess_->KillChildProcess();
565 } 550 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 nacl::MutexLocker take(&mu_); 607 nacl::MutexLocker take(&mu_);
623 return exit_status_; 608 return exit_status_;
624 } 609 }
625 610
626 void ServiceRuntime::set_exit_status(int exit_status) { 611 void ServiceRuntime::set_exit_status(int exit_status) {
627 nacl::MutexLocker take(&mu_); 612 nacl::MutexLocker take(&mu_);
628 exit_status_ = exit_status & 0xff; 613 exit_status_ = exit_status & 0xff;
629 } 614 }
630 615
631 } // namespace plugin 616 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698