Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / components / nacl / renderer / plugin / service_runtime.h
blobb280e67c15f5ed85da2e54a6ba7fe4db8bcf14ed
1 /* -*- c++ -*- */
2 /*
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.
6 */
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"
22 namespace plugin {
24 class ErrorInfo;
25 class Plugin;
26 class SelLdrLauncherChrome;
27 class SrpcClient;
28 class ServiceRuntime;
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)
36 : url(url),
37 file_info(file_info),
38 process_type(process_type) {
40 std::string url;
41 PP_NaClFileInfo file_info;
42 PP_NaClAppProcessType process_type;
45 // ServiceRuntime abstracts a NativeClient sel_ldr instance.
46 class ServiceRuntime {
47 public:
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.
53 ~ServiceRuntime();
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.
62 void StartNexe();
64 // Starts the application channel to the nexe.
65 SrpcClient* SetupAppChannel();
67 Plugin* plugin() const { return plugin_; }
68 void Shutdown();
70 bool main_service_runtime() const { return main_service_runtime_; }
72 private:
73 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime);
75 bool SetupCommandChannel();
77 void ReportLoadError(const ErrorInfo& error_info);
79 NaClSrpcChannel command_channel_;
80 Plugin* plugin_;
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_;
89 } // namespace plugin
91 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_SERVICE_RUNTIME_H_