Bug 1700051: part 49) Add some documentation to `Selection::GetRangesForInterval...
[gecko.git] / xpcom / threads / nsProcess.h
blobc7cd0a3d055f8b5b07bd85452d40ec4fe0c5e267
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _nsPROCESSWIN_H_
8 #define _nsPROCESSWIN_H_
10 #if defined(XP_WIN)
11 # define PROCESSMODEL_WINAPI
12 #endif
14 #include "mozilla/Attributes.h"
15 #include "mozilla/Mutex.h"
16 #include "nsIProcess.h"
17 #include "nsIObserver.h"
18 #include "nsMaybeWeakPtr.h"
19 #include "nsString.h"
20 #ifndef XP_UNIX
21 # include "prproces.h"
22 #endif
23 #if defined(PROCESSMODEL_WINAPI)
24 # include <windows.h>
25 # include <shellapi.h>
26 #endif
28 #define NS_PROCESS_CID \
29 { \
30 0x7b4eeb20, 0xd781, 0x11d4, { \
31 0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca \
32 } \
35 class nsIFile;
37 class nsProcess final : public nsIProcess, public nsIObserver {
38 public:
39 NS_DECL_THREADSAFE_ISUPPORTS
40 NS_DECL_NSIPROCESS
41 NS_DECL_NSIOBSERVER
43 nsProcess();
45 private:
46 ~nsProcess();
47 static void Monitor(void* aArg);
48 void ProcessComplete();
49 nsresult CopyArgsAndRunProcess(bool aBlocking, const char** aArgs,
50 uint32_t aCount, nsIObserver* aObserver,
51 bool aHoldWeak);
52 nsresult CopyArgsAndRunProcessw(bool aBlocking, const char16_t** aArgs,
53 uint32_t aCount, nsIObserver* aObserver,
54 bool aHoldWeak);
55 // The 'args' array is null-terminated.
56 nsresult RunProcess(bool aBlocking, char** aArgs, nsIObserver* aObserver,
57 bool aHoldWeak, bool aArgsUTF8);
59 PRThread* mThread;
60 mozilla::Mutex mLock;
61 bool mShutdown;
62 bool mBlocking;
63 bool mStartHidden;
64 bool mNoShell;
66 nsCOMPtr<nsIFile> mExecutable;
67 nsString mTargetPath;
68 int32_t mPid;
69 nsMaybeWeakPtr<nsIObserver> mObserver;
71 // These members are modified by multiple threads, any accesses should be
72 // protected with mLock.
73 int32_t mExitValue;
74 #if defined(PROCESSMODEL_WINAPI)
75 HANDLE mProcess;
76 #elif !defined(XP_UNIX)
77 PRProcess* mProcess;
78 #endif
81 #endif