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_
11 # define PROCESSMODEL_WINAPI
14 #include "mozilla/Attributes.h"
15 #include "mozilla/Mutex.h"
16 #include "nsIProcess.h"
17 #include "nsIObserver.h"
18 #include "nsMaybeWeakPtr.h"
21 # include "prproces.h"
23 #if defined(PROCESSMODEL_WINAPI)
25 # include <shellapi.h>
28 #define NS_PROCESS_CID \
30 0x7b4eeb20, 0xd781, 0x11d4, { \
31 0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca \
37 class nsProcess final
: public nsIProcess
, public nsIObserver
{
39 NS_DECL_THREADSAFE_ISUPPORTS
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
,
53 nsresult
CopyArgsAndRunProcessw(bool aBlocking
, const char16_t
** aArgs
,
54 uint32_t aCount
, nsIObserver
* aObserver
,
56 // The 'args' array is null-terminated.
57 nsresult
RunProcess(bool aBlocking
, char** aArgs
, nsIObserver
* aObserver
,
58 bool aHoldWeak
, bool aArgsUTF8
);
62 bool mShutdown
MOZ_GUARDED_BY(mLock
);
67 nsCOMPtr
<nsIFile
> mExecutable
;
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
);