Bug 1883861 - Part 1: Move visitMemoryBarrier into the common CodeGenerator file...
[gecko.git] / xpcom / threads / nsProcess.h
blob95d6748640aae507366b33391338053ecce122cd
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 PRThread* CreateMonitorThread();
48 static void Monitor(void* aArg);
49 void ProcessComplete();
50 nsresult CopyArgsAndRunProcess(bool aBlocking, const char** aArgs,
51 uint32_t aCount, nsIObserver* aObserver,
52 bool aHoldWeak);
53 nsresult CopyArgsAndRunProcessw(bool aBlocking, const char16_t** aArgs,
54 uint32_t aCount, nsIObserver* aObserver,
55 bool aHoldWeak);
56 // The 'args' array is null-terminated.
57 nsresult RunProcess(bool aBlocking, char** aArgs, nsIObserver* aObserver,
58 bool aHoldWeak, bool aArgsUTF8);
60 PRThread* mThread;
61 mozilla::Mutex mLock;
62 bool mShutdown MOZ_GUARDED_BY(mLock);
63 bool mBlocking;
64 bool mStartHidden;
65 bool mNoShell;
67 nsCOMPtr<nsIFile> mExecutable;
68 nsString mTargetPath;
69 int32_t mPid;
70 nsMaybeWeakPtr<nsIObserver> mObserver;
72 // These members are modified by multiple threads, any accesses should be
73 // protected with mLock.
74 int32_t mExitValue MOZ_GUARDED_BY(mLock);
75 #if defined(PROCESSMODEL_WINAPI)
76 HANDLE mProcess MOZ_GUARDED_BY(mLock);
77 #elif !defined(XP_UNIX)
78 PRProcess* mProcess MOZ_GUARDED_BY(mLock);
79 #endif
82 #endif