Componentize component_updater: Copy over test data with executable bit.
[chromium-blink-merge.git] / ppapi / native_client / src / trusted / plugin / nacl_subprocess.h
bloba5380375ff7e71c4dda881a1358e2e386042dde4
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Instances of NaCl modules spun up within the plugin as a subprocess.
6 // This may represent the "main" nacl module, or it may represent helpers
7 // that perform various tasks within the plugin, for example,
8 // a NaCl module for a compiler could be loaded to translate LLVM bitcode
9 // into native code.
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_
14 #include <stdarg.h>
16 #include "native_client/src/include/nacl_macros.h"
17 #include "native_client/src/include/nacl_string.h"
18 #include "native_client/src/include/portability.h"
20 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h"
21 #include "ppapi/native_client/src/trusted/plugin/srpc_client.h"
23 namespace plugin {
25 class Plugin;
26 class ServiceRuntime;
27 class SrpcParams;
30 // A class representing an instance of a NaCl module, loaded by the plugin.
31 class NaClSubprocess {
32 public:
33 NaClSubprocess(const nacl::string& description,
34 ServiceRuntime* service_runtime,
35 SrpcClient* srpc_client)
36 : description_(description),
37 service_runtime_(service_runtime),
38 srpc_client_(srpc_client) {
40 virtual ~NaClSubprocess();
42 ServiceRuntime* service_runtime() const { return service_runtime_.get(); }
43 void set_service_runtime(ServiceRuntime* service_runtime) {
44 service_runtime_.reset(service_runtime);
47 // The socket used for communicating w/ the NaCl module.
48 SrpcClient* srpc_client() const { return srpc_client_.get(); }
50 // A basic description of the subprocess.
51 nacl::string description() const { return description_; }
53 // A detailed description of the subprocess that may contain addresses.
54 // Only use for debugging, but do not expose this to untrusted webapps.
55 nacl::string detailed_description() const;
57 // Start up interfaces.
58 bool StartSrpcServices();
60 // Invoke an Srpc Method. |out_params| must be allocated and cleaned up
61 // outside of this function, but it will be initialized by this function, and
62 // on success any out-params (if any) will be placed in |out_params|.
63 // Input types must be listed in |input_signature|, with the actual
64 // arguments passed in as var-args. Returns |true| on success.
65 bool InvokeSrpcMethod(const nacl::string& method_name,
66 const nacl::string& input_signature,
67 SrpcParams* out_params,
68 ...);
70 // Fully shut down the subprocess.
71 void Shutdown();
73 private:
74 NACL_DISALLOW_COPY_AND_ASSIGN(NaClSubprocess);
76 bool VInvokeSrpcMethod(const nacl::string& method_name,
77 const nacl::string& signature,
78 SrpcParams* params,
79 va_list vl);
81 nacl::string description_;
83 // The service runtime representing the NaCl module instance.
84 nacl::scoped_ptr<ServiceRuntime> service_runtime_;
85 // Ownership of srpc_client taken from the service runtime.
86 nacl::scoped_ptr<SrpcClient> srpc_client_;
89 } // namespace plugin
91 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_SUBPROCESS_H_