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 if (!subprocess_->ConnectBootstrapSocket()) { |
62 ErrorInfo error_info; | 61 ErrorInfo error_info; |
63 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, | 62 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, |
64 "ServiceRuntime: command channel creation failed"); | 63 "ServiceRuntime: ConnectBootstrapSocket() failed"); |
65 ReportLoadError(error_info); | 64 ReportLoadError(error_info); |
66 return false; | 65 return false; |
67 } | 66 } |
| 67 if (!subprocess_->RetrieveSockAddr()) { |
| 68 ErrorInfo error_info; |
| 69 error_info.SetReport(PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL, |
| 70 "ServiceRuntime: RetrieveSockAddr() failed"); |
| 71 ReportLoadError(error_info); |
| 72 return false; |
| 73 } |
68 return true; | 74 return true; |
69 } | 75 } |
70 | 76 |
71 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, | 77 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params, |
72 pp::CompletionCallback callback) { | 78 pp::CompletionCallback callback) { |
73 NaClLog(4, "ServiceRuntime::Start\n"); | 79 NaClLog(4, "ServiceRuntime::Start\n"); |
74 | 80 |
75 nacl::scoped_ptr<SelLdrLauncherChrome> | 81 nacl::scoped_ptr<SelLdrLauncherChrome> |
76 tmp_subprocess(new SelLdrLauncherChrome()); | 82 tmp_subprocess(new SelLdrLauncherChrome()); |
77 if (NULL == tmp_subprocess.get()) { | 83 if (NULL == tmp_subprocess.get()) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 void ServiceRuntime::Shutdown() { | 137 void ServiceRuntime::Shutdown() { |
132 // Abandon callbacks, tell service threads to quit if they were | 138 // Abandon callbacks, tell service threads to quit if they were |
133 // blocked waiting for main thread operations to finish. Note that | 139 // blocked waiting for main thread operations to finish. Note that |
134 // some callbacks must still await their completion event, e.g., | 140 // some callbacks must still await their completion event, e.g., |
135 // CallOnMainThread must still wait for the time out, or I/O events | 141 // CallOnMainThread must still wait for the time out, or I/O events |
136 // must finish, so resources associated with pending events cannot | 142 // must finish, so resources associated with pending events cannot |
137 // be deallocated. | 143 // be deallocated. |
138 | 144 |
139 // Note that this does waitpid() to get rid of any zombie subprocess. | 145 // Note that this does waitpid() to get rid of any zombie subprocess. |
140 subprocess_.reset(NULL); | 146 subprocess_.reset(NULL); |
141 | |
142 NaClSrpcDtor(&command_channel_); | |
143 } | 147 } |
144 | 148 |
145 ServiceRuntime::~ServiceRuntime() { | 149 ServiceRuntime::~ServiceRuntime() { |
146 NaClLog(4, "ServiceRuntime::~ServiceRuntime (this=%p)\n", | 150 NaClLog(4, "ServiceRuntime::~ServiceRuntime (this=%p)\n", |
147 static_cast<void*>(this)); | 151 static_cast<void*>(this)); |
148 // We do this just in case Shutdown() was not called. | 152 // We do this just in case Shutdown() was not called. |
149 subprocess_.reset(NULL); | 153 subprocess_.reset(NULL); |
150 } | 154 } |
151 | 155 |
152 } // namespace plugin | 156 } // namespace plugin |
OLD | NEW |