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
5 * found in the LICENSE file.
8 // A class containing information regarding a socket connection to a
9 // service runtime instance.
11 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_SERVICE_RUNTIME_H_
12 #define COMPONENTS_NACL_RENDERER_PLUGIN_SERVICE_RUNTIME_H_
14 #include "components/nacl/renderer/plugin/utility.h"
15 #include "native_client/src/include/nacl_macros.h"
16 #include "native_client/src/include/nacl_scoped_ptr.h"
17 #include "native_client/src/public/imc_types.h"
18 #include "native_client/src/shared/platform/nacl_sync.h"
19 #include "native_client/src/shared/srpc/nacl_srpc.h"
20 #include "ppapi/cpp/completion_callback.h"
26 class SelLdrLauncherChrome
;
30 // Struct of params used by StartSelLdr. Use a struct so that callback
31 // creation templates aren't overwhelmed with too many parameters.
32 struct SelLdrStartParams
{
33 SelLdrStartParams(const std::string
& url
,
34 const PP_NaClFileInfo
& file_info
,
35 PP_NaClAppProcessType process_type
)
38 process_type(process_type
) {
41 PP_NaClFileInfo file_info
;
42 PP_NaClAppProcessType process_type
;
45 // ServiceRuntime abstracts a NativeClient sel_ldr instance.
46 class ServiceRuntime
{
48 ServiceRuntime(Plugin
* plugin
,
49 PP_Instance pp_instance
,
50 bool main_service_runtime
,
51 bool uses_nonsfi_mode
);
52 // The destructor terminates the sel_ldr process.
55 // Spawn the sel_ldr instance.
56 void StartSelLdr(const SelLdrStartParams
& params
,
57 pp::CompletionCallback callback
);
59 // Establish an SrpcClient to the sel_ldr instance and start the nexe.
60 // This function must be called on the main thread.
61 // This function must only be called once.
64 // Starts the application channel to the nexe.
65 SrpcClient
* SetupAppChannel();
67 Plugin
* plugin() const { return plugin_
; }
70 bool main_service_runtime() const { return main_service_runtime_
; }
73 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime
);
75 bool SetupCommandChannel();
77 void ReportLoadError(const ErrorInfo
& error_info
);
79 NaClSrpcChannel command_channel_
;
81 PP_Instance pp_instance_
;
82 bool main_service_runtime_
;
83 bool uses_nonsfi_mode_
;
84 nacl::scoped_ptr
<SelLdrLauncherChrome
> subprocess_
;
86 NaClHandle bootstrap_channel_
;
91 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_SERVICE_RUNTIME_H_