Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "components/nacl/renderer/plugin/service_runtime.h" | 9 #include "components/nacl/renderer/plugin/service_runtime.h" |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 ServiceRuntime::ServiceRuntime(Plugin* plugin, | 36 ServiceRuntime::ServiceRuntime(Plugin* plugin, |
| 37 PP_Instance pp_instance, | 37 PP_Instance pp_instance, |
| 38 bool main_service_runtime, | 38 bool main_service_runtime, |
| 39 bool uses_nonsfi_mode) | 39 bool uses_nonsfi_mode) |
| 40 : plugin_(plugin), | 40 : plugin_(plugin), |
| 41 pp_instance_(pp_instance), | 41 pp_instance_(pp_instance), |
| 42 main_service_runtime_(main_service_runtime), | 42 main_service_runtime_(main_service_runtime), |
| 43 uses_nonsfi_mode_(uses_nonsfi_mode), | 43 uses_nonsfi_mode_(uses_nonsfi_mode), |
| 44 bootstrap_channel_(NACL_INVALID_HANDLE) { | 44 bootstrap_channel_(NACL_INVALID_HANDLE) { |
| 45 NaClSrpcChannelInitialize(&command_channel_); | |
| 46 } | 45 } |
| 47 | 46 |
| 48 bool ServiceRuntime::SetupCommandChannel() { | 47 bool ServiceRuntime::SetupCommandChannel() { |
| 49 NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n", | 48 NaClLog(4, "ServiceRuntime::SetupCommand (this=%p, subprocess=%p)\n", |
| 50 static_cast<void*>(this), | 49 static_cast<void*>(this), |
| 51 static_cast<void*>(subprocess_.get())); | 50 static_cast<void*>(subprocess_.get())); |
| 52 // Set up the bootstrap channel in our subprocess so that we can establish | 51 // Set up the bootstrap channel in our subprocess so that we can establish |
| 53 // SRPC. | 52 // SRPC. |
| 54 subprocess_->set_channel(bootstrap_channel_); | 53 subprocess_->set_channel(bootstrap_channel_); |
| 55 | 54 |
| 56 if (uses_nonsfi_mode_) { | 55 if (uses_nonsfi_mode_) { |
| 57 // In non-SFI mode, no SRPC is used. Just skips and returns success. | 56 // In non-SFI mode, no SRPC is used. Just skips and returns success. |
| 58 return true; | 57 return true; |
| 59 } | 58 } |
| 60 | 59 |
| 61 if (!subprocess_->SetupCommand(&command_channel_)) { | 60 return subprocess_->ConnectBootstrapSocket() && |
| 62 ErrorInfo error_info; | 61 subprocess_->RetrieveSockAddr(); |
| 63 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, | |
|
jvoung (off chromium)
2015/06/09 15:43:44
If want to keep this UMA stat (it's about 0.01%),
Mark Seaborn
2015/06/10 00:31:04
Oh, good point! I was deleting code without reall
| |
| 64 "ServiceRuntime: command channel creation failed"); | |
| 65 ReportLoadError(error_info); | |
| 66 return false; | |
| 67 } | |
| 68 return true; | |
| 69 } | 62 } |
| 70 | 63 |
| 71 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, | 64 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, |
| 72 pp::CompletionCallback callback) { | 65 pp::CompletionCallback callback) { |
| 73 NaClLog(4, "ServiceRuntime::Start\n"); | 66 NaClLog(4, "ServiceRuntime::Start\n"); |
| 74 | 67 |
| 75 nacl::scoped_ptr<SelLdrLauncherChrome> | 68 nacl::scoped_ptr<SelLdrLauncherChrome> |
| 76 tmp_subprocess(new SelLdrLauncherChrome()); | 69 tmp_subprocess(new SelLdrLauncherChrome()); |
| 77 if (NULL == tmp_subprocess.get()) { | 70 if (NULL == tmp_subprocess.get()) { |
| 78 NaClLog(LOG_ERROR, "ServiceRuntime::Start (subprocess create failed)\n"); | 71 NaClLog(LOG_ERROR, "ServiceRuntime::Start (subprocess create failed)\n"); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 void ServiceRuntime::Shutdown() { | 124 void ServiceRuntime::Shutdown() { |
| 132 // Abandon callbacks, tell service threads to quit if they were | 125 // Abandon callbacks, tell service threads to quit if they were |
| 133 // blocked waiting for main thread operations to finish. Note that | 126 // blocked waiting for main thread operations to finish. Note that |
| 134 // some callbacks must still await their completion event, e.g., | 127 // some callbacks must still await their completion event, e.g., |
| 135 // CallOnMainThread must still wait for the time out, or I/O events | 128 // CallOnMainThread must still wait for the time out, or I/O events |
| 136 // must finish, so resources associated with pending events cannot | 129 // must finish, so resources associated with pending events cannot |
| 137 // be deallocated. | 130 // be deallocated. |
| 138 | 131 |
| 139 // Note that this does waitpid() to get rid of any zombie subprocess. | 132 // Note that this does waitpid() to get rid of any zombie subprocess. |
| 140 subprocess_.reset(NULL); | 133 subprocess_.reset(NULL); |
| 141 | |
| 142 NaClSrpcDtor(&command_channel_); | |
| 143 } | 134 } |
| 144 | 135 |
| 145 ServiceRuntime::~ServiceRuntime() { | 136 ServiceRuntime::~ServiceRuntime() { |
| 146 NaClLog(4, "ServiceRuntime::~ServiceRuntime (this=%p)\n", | 137 NaClLog(4, "ServiceRuntime::~ServiceRuntime (this=%p)\n", |
| 147 static_cast<void*>(this)); | 138 static_cast<void*>(this)); |
| 148 // We do this just in case Shutdown() was not called. | 139 // We do this just in case Shutdown() was not called. |
| 149 subprocess_.reset(NULL); | 140 subprocess_.reset(NULL); |
| 150 } | 141 } |
| 151 | 142 |
| 152 } // namespace plugin | 143 } // namespace plugin |
| OLD | NEW |