Index: apps/app_host/operation_launcher.h |
diff --git a/apps/app_host/operation_launcher.h b/apps/app_host/operation_launcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d95fffe78db7d1f6f8d65899912c03d48792c8c0 |
--- /dev/null |
+++ b/apps/app_host/operation_launcher.h |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+// |
+// Operations are command-line invocations. Like a process, they can have output |
+// and an exit code. But an operation does not necessarily correspond to a |
+// single process. For example, the operation can complete while the launched |
+// process continues to perform other tasks, or the launched process might exit |
+// while the operation is completed by other processes. |
+// |
+// An executable implements an operation by accepting three additional arguments |
+// on the command-line: |
+// |
+// switches::kTaskRemoteProcessId |
+// The process ID of the operation client |
+// |
+// switches::kTaskOutputHandle |
+// A writable HANDLE, valid in the client process, which should be used to |
+// write the operation output. |
+// |
+// switches::kTaskResultHandle |
+// A writable HANDLE, valid in the client process, which should be used to |
+// write the operation exit code (as a binary DWORD). |
+// |
+// LaunchOperation (declared below) will add these parameters to the operation |
+// command-line before invoking it to launch the original operation process. The |
+// HANDLEs will only be valid during the lifetime of the original operation |
+// process; therefore the operation implementation MUST be sure to duplicate |
+// them before it exits if it is delegating to a tertiary process. |
+ |
+#ifndef APPS_APP_HOST_OPERATION_LAUNCHER_H_ |
+#define APPS_APP_HOST_OPERATION_LAUNCHER_H_ |
+ |
+#include <windows.h> |
+ |
+class CommandLine; |
+ |
+namespace app_host { |
+ |
+// Runs |command_line|, passing anonymous pipes to be used for operation output |
+// and exit code. To prevent deadlocks, |output_write| must be drained somehow |
+// (otherwise the operation may block while writing its output if the pipe's |
+// buffer is full). In production code it will typically be the terminal of the |
+// current process. |
+// Returns true if the operation is successfully launched and its exit code |
+// received. |
+bool LaunchOperation(const CommandLine& command_line, |
+ HANDLE output_write, |
+ DWORD* exit_code); |
+ |
+} // namespace app_host |
+ |
+#endif // APPS_APP_HOST_OPERATION_LAUNCHER_H_ |