OLD | NEW |
1 /* -*- c++ -*- */ | 1 /* -*- c++ -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // A class containing information regarding a socket connection to a | 8 // A class containing information regarding a socket connection to a |
9 // service runtime instance. | 9 // service runtime instance. |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // actually start. Returns |false| if timed out waiting for the process | 163 // actually start. Returns |false| if timed out waiting for the process |
164 // to start. Otherwise, returns |true| if StartSelLdr is complete | 164 // to start. Otherwise, returns |true| if StartSelLdr is complete |
165 // (either successfully or unsuccessfully). | 165 // (either successfully or unsuccessfully). |
166 bool WaitForSelLdrStart(); | 166 bool WaitForSelLdrStart(); |
167 | 167 |
168 // Signal to waiting threads that StartSelLdr is complete (either | 168 // Signal to waiting threads that StartSelLdr is complete (either |
169 // successfully or unsuccessfully). | 169 // successfully or unsuccessfully). |
170 void SignalStartSelLdrDone(); | 170 void SignalStartSelLdrDone(); |
171 | 171 |
172 // If starting the nexe from a background thread, wait for the nexe to | 172 // If starting the nexe from a background thread, wait for the nexe to |
173 // actually start. | 173 // actually start. Returns |true| is the nexe started successfully. |
174 void WaitForNexeStart(); | 174 bool WaitForNexeStart(); |
175 | 175 |
176 // Signal to waiting threads that LoadNexeAndStart is complete (either | 176 // Signal to waiting threads that LoadNexeAndStart is complete (either |
177 // successfully or unsuccessfully). | 177 // successfully or unsuccessfully). |
178 void SignalNexeStarted(); | 178 void SignalNexeStarted(bool ok); |
179 | 179 |
180 // Establish an SrpcClient to the sel_ldr instance and load the nexe. | 180 // Establish an SrpcClient to the sel_ldr instance and load the nexe. |
181 // The nexe to be started is passed through |file_info|. | 181 // The nexe to be started is passed through |file_info|. |
182 // Upon completion |callback| is invoked with status code. | |
183 // This function must be called on the main thread. | 182 // This function must be called on the main thread. |
184 void LoadNexeAndStart(PP_NaClFileInfo file_info, | 183 // This function must only be called once. |
185 const pp::CompletionCallback& callback); | 184 void LoadNexeAndStart(PP_NaClFileInfo file_info); |
186 | 185 |
187 // Starts the application channel to the nexe. | 186 // Starts the application channel to the nexe. |
188 SrpcClient* SetupAppChannel(); | 187 SrpcClient* SetupAppChannel(); |
189 | 188 |
190 bool Log(int severity, const nacl::string& msg); | 189 bool RemoteLog(int severity, const nacl::string& msg); |
191 Plugin* plugin() const { return plugin_; } | 190 Plugin* plugin() const { return plugin_; } |
192 void Shutdown(); | 191 void Shutdown(); |
193 | 192 |
194 // exit_status is -1 when invalid; when we set it, we will ensure | 193 // exit_status is -1 when invalid; when we set it, we will ensure |
195 // that it is non-negative (the portion of the exit status from the | 194 // that it is non-negative (the portion of the exit status from the |
196 // nexe that is transferred is the low 8 bits of the argument to the | 195 // nexe that is transferred is the low 8 bits of the argument to the |
197 // exit syscall). | 196 // exit syscall). |
198 int exit_status(); // const, but grabs mutex etc. | 197 int exit_status(); // const, but grabs mutex etc. |
199 void set_exit_status(int exit_status); | 198 void set_exit_status(int exit_status); |
200 | 199 |
201 nacl::string GetCrashLogOutput(); | 200 nacl::string GetCrashLogOutput(); |
202 | 201 |
203 bool main_service_runtime() const { return main_service_runtime_; } | 202 bool main_service_runtime() const { return main_service_runtime_; } |
204 | 203 |
205 private: | 204 private: |
206 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); | 205 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); |
207 struct LoadNexeAndStartData; | 206 bool LoadNexeAndStartInternal(const PP_NaClFileInfo& file_info); |
208 void LoadNexeAndStartAfterLoadModule( | |
209 LoadNexeAndStartData* data, int32_t pp_error); | |
210 void DidLoadNexeAndStart(LoadNexeAndStartData* data, int32_t pp_error); | |
211 | 207 |
212 bool SetupCommandChannel(); | 208 bool SetupCommandChannel(); |
213 bool InitReverseService(); | 209 bool InitReverseService(); |
214 void LoadModule(PP_NaClFileInfo file_info, | 210 bool LoadModule(const PP_NaClFileInfo& file_info); |
215 pp::CompletionCallback callback); | |
216 void DidLoadModule(pp::CompletionCallback callback, int32_t pp_error); | |
217 bool StartModule(); | 211 bool StartModule(); |
| 212 void ReapLogs(); |
218 | 213 |
219 NaClSrpcChannel command_channel_; | 214 NaClSrpcChannel command_channel_; |
220 Plugin* plugin_; | 215 Plugin* plugin_; |
221 bool main_service_runtime_; | 216 bool main_service_runtime_; |
222 bool uses_nonsfi_mode_; | 217 bool uses_nonsfi_mode_; |
223 nacl::ReverseService* reverse_service_; | 218 nacl::ReverseService* reverse_service_; |
224 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; | 219 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; |
225 | 220 |
226 nacl::WeakRefAnchor* anchor_; | 221 nacl::WeakRefAnchor* anchor_; |
227 | 222 |
228 PluginReverseInterface* rev_interface_; | 223 PluginReverseInterface* rev_interface_; |
229 | 224 |
230 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. | 225 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. |
231 NaClMutex mu_; | 226 NaClMutex mu_; |
232 NaClCondVar cond_; | 227 NaClCondVar cond_; |
233 bool start_sel_ldr_done_; | 228 bool start_sel_ldr_done_; |
234 bool nexe_started_; | 229 bool start_nexe_done_; |
| 230 bool nexe_started_ok_; |
235 }; | 231 }; |
236 | 232 |
237 } // namespace plugin | 233 } // namespace plugin |
238 | 234 |
239 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ | 235 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ |
OLD | NEW |