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

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

Issue 149403005: Pepper: Make StartSelLdr asynchronous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CompletionCallback cleanup in service_runtime Created 6 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
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
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
13 13
14 #include <set> 14 #include <set>
15 15
16 #include "native_client/src/include/nacl_macros.h" 16 #include "native_client/src/include/nacl_macros.h"
17 #include "native_client/src/include/nacl_scoped_ptr.h" 17 #include "native_client/src/include/nacl_scoped_ptr.h"
18 #include "native_client/src/include/nacl_string.h" 18 #include "native_client/src/include/nacl_string.h"
19 #include "native_client/src/shared/platform/nacl_sync.h" 19 #include "native_client/src/shared/platform/nacl_sync.h"
20 #include "native_client/src/shared/srpc/nacl_srpc.h" 20 #include "native_client/src/shared/srpc/nacl_srpc.h"
21 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 21 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
22 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" 22 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
23 #include "native_client/src/trusted/reverse_service/reverse_service.h" 23 #include "native_client/src/trusted/reverse_service/reverse_service.h"
24 #include "native_client/src/trusted/weak_ref/weak_ref.h" 24 #include "native_client/src/trusted/weak_ref/weak_ref.h"
25 25
26 #include "ppapi/cpp/completion_callback.h" 26 #include "ppapi/cpp/completion_callback.h"
27
28 #include "ppapi/native_client/src/trusted/plugin/utility.h" 27 #include "ppapi/native_client/src/trusted/plugin/utility.h"
28 #include "ppapi/utility/completion_callback_factory.h"
29 29
30 struct NaClFileInfo; 30 struct NaClFileInfo;
31 31
32 namespace nacl { 32 namespace nacl {
33 class DescWrapper; 33 class DescWrapper;
34 } // namespace 34 } // namespace
35 35
36 namespace pp { 36 namespace pp {
37 class FileIO; 37 class FileIO;
38 } // namespace 38 } // namespace
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // TODO(sehr): This class should also implement factory methods, using the 222 // TODO(sehr): This class should also implement factory methods, using the
223 // Start method below. 223 // Start method below.
224 ServiceRuntime(Plugin* plugin, 224 ServiceRuntime(Plugin* plugin,
225 const Manifest* manifest, 225 const Manifest* manifest,
226 bool should_report_uma, 226 bool should_report_uma,
227 pp::CompletionCallback init_done_cb, 227 pp::CompletionCallback init_done_cb,
228 pp::CompletionCallback crash_cb); 228 pp::CompletionCallback crash_cb);
229 // The destructor terminates the sel_ldr process. 229 // The destructor terminates the sel_ldr process.
230 ~ServiceRuntime(); 230 ~ServiceRuntime();
231 231
232 // Spawn the sel_ldr instance. On success, returns true. 232 // Spawn the sel_ldr instance.
233 // On failure, returns false and |error_string| is set to something 233 void StartSelLdr(const SelLdrStartParams& params,
234 // describing the error. 234 pp::CompletionCallback callback);
235 bool StartSelLdr(const SelLdrStartParams& params);
236 235
237 // If starting sel_ldr from a background thread, wait for sel_ldr to 236 // If starting sel_ldr from a background thread, wait for sel_ldr to
238 // actually start. 237 // actually start.
239 void WaitForSelLdrStart(); 238 void WaitForSelLdrStart();
240 239
241 // Signal to waiting threads that StartSelLdr is complete. 240 // Signal to waiting threads that StartSelLdr is complete.
242 // Done externally, in case external users want to write to shared 241 // Done externally, in case external users want to write to shared
243 // memory that is yet to be fenced. 242 // memory that is yet to be fenced.
244 void SignalStartSelLdrDone(); 243 void SignalStartSelLdrDone();
245 244
(...skipping 21 matching lines...) Expand all
267 266
268 // To establish quota callbacks the pnacl coordinator needs to communicate 267 // To establish quota callbacks the pnacl coordinator needs to communicate
269 // with the reverse interface. 268 // with the reverse interface.
270 PluginReverseInterface* rev_interface() const { return rev_interface_; } 269 PluginReverseInterface* rev_interface() const { return rev_interface_; }
271 270
272 private: 271 private:
273 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); 272 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime);
274 bool LoadModule(nacl::DescWrapper* shm, ErrorInfo* error_info); 273 bool LoadModule(nacl::DescWrapper* shm, ErrorInfo* error_info);
275 bool InitReverseService(ErrorInfo* error_info); 274 bool InitReverseService(ErrorInfo* error_info);
276 bool StartModule(ErrorInfo* error_info); 275 bool StartModule(ErrorInfo* error_info);
276 void StartSelLdrContinuation(int32_t pp_error,
277 pp::CompletionCallback callback);
277 278
278 NaClSrpcChannel command_channel_; 279 NaClSrpcChannel command_channel_;
279 Plugin* plugin_; 280 Plugin* plugin_;
280 bool main_service_runtime_; 281 bool main_service_runtime_;
281 nacl::ReverseService* reverse_service_; 282 nacl::ReverseService* reverse_service_;
282 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_; 283 nacl::scoped_ptr<nacl::SelLdrLauncherBase> subprocess_;
283 284
284 nacl::WeakRefAnchor* anchor_; 285 nacl::WeakRefAnchor* anchor_;
285 286
286 PluginReverseInterface* rev_interface_; 287 PluginReverseInterface* rev_interface_;
287 288
288 // Mutex to protect exit_status_. 289 // Mutex to protect exit_status_.
289 // Also, in conjunction with cond_ it is used to signal when 290 // Also, in conjunction with cond_ it is used to signal when
290 // StartSelLdr is complete with either success or error. 291 // StartSelLdr is complete with either success or error.
291 NaClMutex mu_; 292 NaClMutex mu_;
292 NaClCondVar cond_; 293 NaClCondVar cond_;
293 int exit_status_; 294 int exit_status_;
294 bool start_sel_ldr_done_; 295 bool start_sel_ldr_done_;
296
297 PP_Var start_sel_ldr_error_message_;
298 pp::CompletionCallbackFactory<ServiceRuntime> callback_factory_;
295 }; 299 };
296 300
297 } // namespace plugin 301 } // namespace plugin
298 302
299 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 303 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698