Index: src/trusted/nonnacl_util/sel_ldr_launcher.h |
diff --git a/src/trusted/nonnacl_util/sel_ldr_launcher.h b/src/trusted/nonnacl_util/sel_ldr_launcher.h |
index 778906d36e5da6a2c05191ca2c6b6be8d96852c3..d0fb3d0e46522822dc2efd21142a4b32b3ff76d7 100644 |
--- a/src/trusted/nonnacl_util/sel_ldr_launcher.h |
+++ b/src/trusted/nonnacl_util/sel_ldr_launcher.h |
@@ -66,39 +66,16 @@ class PluginSelLdrLocator : public SelLdrLocator { |
* The sel_ldr process can be forked directly using a command line of args |
* or by sending a message to the (Chrome) browser process. |
*/ |
-struct SelLdrLauncher { |
+class SelLdrLauncherBase { |
public: |
- SelLdrLauncher(); |
- |
- explicit SelLdrLauncher(SelLdrLocator* sel_ldr_locator); |
- ~SelLdrLauncher(); |
- |
- ///////////////////////////////////////////////////////////////////////////// |
- // Command line start-up: (Only used by sel_universal.) |
- // |
- // The command line must include a file path for the nexe application or an |
- // indicator that a reference will be supplied after the launch over RPC. |
- ///////////////////////////////////////////////////////////////////////////// |
- |
- // Starts a sel_ldr process. If |prefix| is not empty, adds prefix arguments, |
- // like using 'time', to run the sel_ldr within. This is primarily intended |
- // to provide a hook for qemu emulation or for timing. |sel_ldr_argv| |
- // specifies the arguments to be passed to sel_ldr itself, while |
- // |application_argv| specifies the arguments to be passed to the nexe. |
- // If subprocess creation fails, returns false and both child_process_ and |
- // channel_ are set to kInvalidHandle. |
- bool StartViaCommandLine(const std::vector<nacl::string>& prefix, |
- const std::vector<nacl::string>& sel_ldr_argv, |
- const std::vector<nacl::string>& application_argv); |
+ SelLdrLauncherBase(); |
+ virtual ~SelLdrLauncherBase(); |
///////////////////////////////////////////////////////////////////////////// |
// Browser start-up: (used by the plugin inside or outside of Chrome build.) |
///////////////////////////////////////////////////////////////////////////// |
- bool Start(const char* url); |
- // TODO(sehr): remove this obsolete interface. The parameters are useless. |
- bool Start(int socket_count, Handle* result_sockets, const char* url); |
- |
+ virtual bool Start(const char* url) = 0; |
///////////////////////////////////////////////////////////////////////////// |
// After starting the sel_ldr process. |
@@ -112,10 +89,6 @@ struct SelLdrLauncher { |
bool StartModuleAndSetupAppChannel(NaClSrpcChannel* command, |
NaClSrpcChannel* out_app_chan); |
- // Kill the child process. The channel() remains valid, but nobody |
- // is talking on the other end. Returns true if successful. |
- bool KillChildProcess(); |
- |
// Returns the socket address used to connect to the sel_ldr. |
DescWrapper* socket_addr() const { return socket_addr_.get(); } |
@@ -126,6 +99,42 @@ struct SelLdrLauncher { |
// As above, but raw_desc is Unref'd on failure. |
DescWrapper* WrapCleanup(NaClDesc* raw_desc); |
+ protected: |
+ Handle channel_; |
+ |
+ private: |
+ // lifetime of bootstrap_socket_ must be at least that of factory_ |
+ scoped_ptr<DescWrapperFactory> factory_; |
+ scoped_ptr<DescWrapper> bootstrap_socket_; |
+ // The socket address returned from sel_ldr for connects. |
+ scoped_ptr<DescWrapper> socket_addr_; |
+}; |
+ |
+class SelLdrLauncherStandalone : public SelLdrLauncherBase { |
+ public: |
+ SelLdrLauncherStandalone(); |
+ ~SelLdrLauncherStandalone(); |
+ |
+ virtual bool Start(const char* url); |
+ |
+ ///////////////////////////////////////////////////////////////////////////// |
+ // Command line start-up: (Only used by sel_universal.) |
+ // |
+ // The command line must include a file path for the nexe application or an |
+ // indicator that a reference will be supplied after the launch over RPC. |
+ ///////////////////////////////////////////////////////////////////////////// |
+ |
+ // Starts a sel_ldr process. If |prefix| is not empty, adds prefix arguments, |
+ // like using 'time', to run the sel_ldr within. This is primarily intended |
+ // to provide a hook for qemu emulation or for timing. |sel_ldr_argv| |
+ // specifies the arguments to be passed to sel_ldr itself, while |
+ // |application_argv| specifies the arguments to be passed to the nexe. |
+ // If subprocess creation fails, returns false and both child_process_ and |
+ // channel_ are set to kInvalidHandle. |
+ bool StartViaCommandLine(const std::vector<nacl::string>& prefix, |
+ const std::vector<nacl::string>& sel_ldr_argv, |
+ const std::vector<nacl::string>& application_argv); |
+ |
private: |
// Builds a command line out of the prepopulated args. |
void BuildCommandLine(std::vector<nacl::string>* command); |
@@ -148,14 +157,13 @@ struct SelLdrLauncher { |
nacl::string GetSelLdrBootstrapPathName(); |
void CloseHandlesAfterLaunch(); |
+ // Kill the child process. The channel() remains valid, but nobody |
+ // is talking on the other end. Returns true if successful. |
+ bool KillChildProcess(); |
+ |
// On Windows, child_process_ is a handle for the process. On Unix, |
- // child_process_ is a process ID. Inside Chromium, we don't get a |
- // handle or a process ID for the process. |
-#if defined(NACL_STANDALONE) |
+ // child_process_ is a process ID. |
Handle child_process_; |
-#endif |
- |
- Handle channel_; |
// The following members are used to initialize and build the command line. |
// The detailed magic is in BuildCommandLine() but roughly we run |
@@ -173,14 +181,27 @@ struct SelLdrLauncher { |
std::vector<Handle> close_after_launch_; |
- // lifetime of bootstrap_socket_ must be at least that of factory_ |
- scoped_ptr<DescWrapperFactory> factory_; |
- scoped_ptr<DescWrapper> bootstrap_socket_; |
- // The socket address returned from sel_ldr for connects. |
- scoped_ptr<DescWrapper> socket_addr_; |
scoped_ptr<SelLdrLocator> sel_ldr_locator_; |
}; |
+// TODO(mseaborn): Move this class (and sel_ldr_launcher_chrome.cc) |
+// into the Chromium repo. There will be two copies present during |
+// this process, but there should not be a naming conflict because |
+// this copy is in the "nacl" namespace. |
+class SelLdrLauncherChrome : public SelLdrLauncherBase { |
+ public: |
+ virtual bool Start(const char* url); |
+}; |
+ |
+// TODO(mseaborn): Remove this typedef. This typedef is currently |
+// provided because the NaCl plugin in the Chromium repo refers to |
+// SelLdrLauncher. |
+#if defined(NACL_STANDALONE) |
+typedef SelLdrLauncherStandalone SelLdrLauncher; |
+#else |
+typedef SelLdrLauncherChrome SelLdrLauncher; |
+#endif |
+ |
} // namespace nacl |
#endif // NATIVE_CLIENT_SRC_TRUSTED_NONNACL_UTIL_SEL_LDR_LAUNCHER_H_ |