Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsISupports.idl" |
michael@0 | 6 | |
michael@0 | 7 | interface nsIFile; |
michael@0 | 8 | interface nsIObserver; |
michael@0 | 9 | |
michael@0 | 10 | [scriptable, uuid(609610de-9954-4a63-8a7c-346350a86403)] |
michael@0 | 11 | interface nsIProcess : nsISupports |
michael@0 | 12 | { |
michael@0 | 13 | /** |
michael@0 | 14 | * Initialises the process with an executable to be run. Call the run method |
michael@0 | 15 | * to run the executable. |
michael@0 | 16 | * @param executable The executable to run. |
michael@0 | 17 | */ |
michael@0 | 18 | void init(in nsIFile executable); |
michael@0 | 19 | |
michael@0 | 20 | /** |
michael@0 | 21 | * Kills the running process. After exiting the process will either have |
michael@0 | 22 | * been killed or a failure will have been returned. |
michael@0 | 23 | */ |
michael@0 | 24 | void kill(); |
michael@0 | 25 | |
michael@0 | 26 | /** |
michael@0 | 27 | * Executes the file this object was initialized with |
michael@0 | 28 | * @param blocking Whether to wait until the process terminates before |
michael@0 | 29 | returning or not. |
michael@0 | 30 | * @param args An array of arguments to pass to the process in the |
michael@0 | 31 | * native character set. |
michael@0 | 32 | * @param count The length of the args array. |
michael@0 | 33 | */ |
michael@0 | 34 | void run(in boolean blocking, [array, size_is(count)] in string args, |
michael@0 | 35 | in unsigned long count); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Executes the file this object was initialized with optionally calling |
michael@0 | 39 | * an observer after the process has finished running. |
michael@0 | 40 | * @param args An array of arguments to pass to the process in the |
michael@0 | 41 | * native character set. |
michael@0 | 42 | * @param count The length of the args array. |
michael@0 | 43 | * @param observer An observer to notify when the process has completed. It |
michael@0 | 44 | * will receive this process instance as the subject and |
michael@0 | 45 | * "process-finished" or "process-failed" as the topic. The |
michael@0 | 46 | * observer will be notified on the main thread. |
michael@0 | 47 | * @param holdWeak Whether to use a weak reference to hold the observer. |
michael@0 | 48 | */ |
michael@0 | 49 | void runAsync([array, size_is(count)] in string args, in unsigned long count, |
michael@0 | 50 | [optional] in nsIObserver observer, [optional] in boolean holdWeak); |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Executes the file this object was initialized with |
michael@0 | 54 | * @param blocking Whether to wait until the process terminates before |
michael@0 | 55 | returning or not. |
michael@0 | 56 | * @param args An array of arguments to pass to the process in UTF-16 |
michael@0 | 57 | * @param count The length of the args array. |
michael@0 | 58 | */ |
michael@0 | 59 | void runw(in boolean blocking, [array, size_is(count)] in wstring args, |
michael@0 | 60 | in unsigned long count); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Executes the file this object was initialized with optionally calling |
michael@0 | 64 | * an observer after the process has finished running. |
michael@0 | 65 | * @param args An array of arguments to pass to the process in UTF-16 |
michael@0 | 66 | * @param count The length of the args array. |
michael@0 | 67 | * @param observer An observer to notify when the process has completed. It |
michael@0 | 68 | * will receive this process instance as the subject and |
michael@0 | 69 | * "process-finished" or "process-failed" as the topic. The |
michael@0 | 70 | * observer will be notified on the main thread. |
michael@0 | 71 | * @param holdWeak Whether to use a weak reference to hold the observer. |
michael@0 | 72 | */ |
michael@0 | 73 | void runwAsync([array, size_is(count)] in wstring args, |
michael@0 | 74 | in unsigned long count, |
michael@0 | 75 | [optional] in nsIObserver observer, [optional] in boolean holdWeak); |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * The process identifier of the currently running process. This will only |
michael@0 | 79 | * be available after the process has started and may not be available on |
michael@0 | 80 | * some platforms. |
michael@0 | 81 | */ |
michael@0 | 82 | readonly attribute unsigned long pid; |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * The exit value of the process. This is only valid after the process has |
michael@0 | 86 | * exited. |
michael@0 | 87 | */ |
michael@0 | 88 | readonly attribute long exitValue; |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * Returns whether the process is currently running or not. |
michael@0 | 92 | */ |
michael@0 | 93 | readonly attribute boolean isRunning; |
michael@0 | 94 | }; |
michael@0 | 95 | |
michael@0 | 96 | %{C++ |
michael@0 | 97 | |
michael@0 | 98 | #define NS_PROCESS_CONTRACTID "@mozilla.org/process/util;1" |
michael@0 | 99 | %} |