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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/service_runtime.h

Issue 338353008: NaCl: clean up nexe loading logic in trusted plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // to start. Otherwise, returns |true| if StartSelLdr is complete 178 // to start. Otherwise, returns |true| if StartSelLdr is complete
179 // (either successfully or unsuccessfully). 179 // (either successfully or unsuccessfully).
180 bool WaitForSelLdrStart(); 180 bool WaitForSelLdrStart();
181 181
182 // Signal to waiting threads that StartSelLdr is complete (either 182 // Signal to waiting threads that StartSelLdr is complete (either
183 // successfully or unsuccessfully). 183 // successfully or unsuccessfully).
184 void SignalStartSelLdrDone(); 184 void SignalStartSelLdrDone();
185 185
186 // If starting the nexe from a background thread, wait for the nexe to 186 // If starting the nexe from a background thread, wait for the nexe to
187 // actually start. 187 // actually start.
188 void WaitForNexeStart(); 188 bool WaitForNexeStart();
hidehiko 2014/06/18 05:07:04 Could you document the return value?
Nick Bray (chromium) 2014/06/18 18:29:44 Done.
189 189
190 // Signal to waiting threads that LoadNexeAndStart is complete (either 190 // Signal to waiting threads that LoadNexeAndStart is complete (either
191 // successfully or unsuccessfully). 191 // successfully or unsuccessfully).
192 void SignalNexeStarted(); 192 void SignalNexeStarted(bool ok);
193 193
194 // Establish an SrpcClient to the sel_ldr instance and load the nexe. 194 // Establish an SrpcClient to the sel_ldr instance and load the nexe.
195 // The nexe to be started is passed through |file_info|. 195 // The nexe to be started is passed through |file_info|.
196 // Upon completion |callback| is invoked with status code.
197 // This function must be called on the main thread. 196 // This function must be called on the main thread.
198 void LoadNexeAndStart(PP_NaClFileInfo file_info, 197 void LoadNexeAndStart(PP_NaClFileInfo file_info);
199 const pp::CompletionCallback& callback);
200 198
201 // Starts the application channel to the nexe. 199 // Starts the application channel to the nexe.
202 SrpcClient* SetupAppChannel(); 200 SrpcClient* SetupAppChannel();
203 201
204 bool Log(int severity, const nacl::string& msg); 202 bool Log(int severity, const nacl::string& msg);
205 Plugin* plugin() const { return plugin_; } 203 Plugin* plugin() const { return plugin_; }
206 void Shutdown(); 204 void Shutdown();
207 205
208 // exit_status is -1 when invalid; when we set it, we will ensure 206 // exit_status is -1 when invalid; when we set it, we will ensure
209 // that it is non-negative (the portion of the exit status from the 207 // that it is non-negative (the portion of the exit status from the
210 // nexe that is transferred is the low 8 bits of the argument to the 208 // nexe that is transferred is the low 8 bits of the argument to the
211 // exit syscall). 209 // exit syscall).
212 int exit_status(); // const, but grabs mutex etc. 210 int exit_status(); // const, but grabs mutex etc.
213 void set_exit_status(int exit_status); 211 void set_exit_status(int exit_status);
214 212
215 nacl::string GetCrashLogOutput(); 213 nacl::string GetCrashLogOutput();
216 214
217 bool main_service_runtime() const { return main_service_runtime_; } 215 bool main_service_runtime() const { return main_service_runtime_; }
218 216
219 private: 217 private:
220 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); 218 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime);
221 struct LoadNexeAndStartData; 219 bool LoadNexeAndStartInternal(PP_NaClFileInfo file_info);
222 void LoadNexeAndStartAfterLoadModule(
223 LoadNexeAndStartData* data, int32_t pp_error);
224 void DidLoadNexeAndStart(LoadNexeAndStartData* data, int32_t pp_error);
225 220
226 bool SetupCommandChannel(); 221 bool SetupCommandChannel();
227 bool InitReverseService(); 222 bool InitReverseService();
228 void LoadModule(PP_NaClFileInfo file_info,
229 pp::CompletionCallback callback);
230 void DidLoadModule(pp::CompletionCallback callback, int32_t pp_error);
231 bool StartModule(); 223 bool StartModule();
224 void ReapLogs();
232 225
233 NaClSrpcChannel command_channel_; 226 NaClSrpcChannel command_channel_;
234 Plugin* plugin_; 227 Plugin* plugin_;
235 bool main_service_runtime_; 228 bool main_service_runtime_;
236 bool uses_nonsfi_mode_; 229 bool uses_nonsfi_mode_;
237 nacl::ReverseService* reverse_service_; 230 nacl::ReverseService* reverse_service_;
238 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; 231 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_;
239 232
240 nacl::WeakRefAnchor* anchor_; 233 nacl::WeakRefAnchor* anchor_;
241 234
242 PluginReverseInterface* rev_interface_; 235 PluginReverseInterface* rev_interface_;
243 236
244 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_. 237 // Mutex and CondVar to protect start_sel_ldr_done_ and nexe_started_.
245 NaClMutex mu_; 238 NaClMutex mu_;
246 NaClCondVar cond_; 239 NaClCondVar cond_;
247 bool start_sel_ldr_done_; 240 bool start_sel_ldr_done_;
248 bool nexe_started_; 241 bool nexe_started_;
242 bool nexe_started_ok_;
249 }; 243 };
250 244
251 } // namespace plugin 245 } // namespace plugin
252 246
253 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 247 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698