michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsPROCESSWIN_H_ michael@0: #define _nsPROCESSWIN_H_ michael@0: michael@0: #if defined(XP_WIN) michael@0: #define PROCESSMODEL_WINAPI michael@0: #endif michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/Mutex.h" michael@0: #include "nsIProcess.h" michael@0: #include "nsIFile.h" michael@0: #include "nsIThread.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsIWeakReferenceUtils.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsString.h" michael@0: #ifndef XP_MACOSX michael@0: #include "prproces.h" michael@0: #endif michael@0: #if defined(PROCESSMODEL_WINAPI) michael@0: #include michael@0: #include michael@0: #endif michael@0: michael@0: #define NS_PROCESS_CID \ michael@0: {0x7b4eeb20, 0xd781, 0x11d4, \ michael@0: {0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca}} michael@0: michael@0: class nsProcess MOZ_FINAL : public nsIProcess, michael@0: public nsIObserver michael@0: { michael@0: public: michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIPROCESS michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: nsProcess(); michael@0: michael@0: private: michael@0: ~nsProcess(); michael@0: static void Monitor(void *arg); michael@0: void ProcessComplete(); michael@0: nsresult CopyArgsAndRunProcess(bool blocking, const char** args, michael@0: uint32_t count, nsIObserver* observer, michael@0: bool holdWeak); michael@0: nsresult CopyArgsAndRunProcessw(bool blocking, const char16_t** args, michael@0: uint32_t count, nsIObserver* observer, michael@0: bool holdWeak); michael@0: // The 'args' array is null-terminated. michael@0: nsresult RunProcess(bool blocking, char **args, nsIObserver* observer, michael@0: bool holdWeak, bool argsUTF8); michael@0: michael@0: PRThread* mThread; michael@0: mozilla::Mutex mLock; michael@0: bool mShutdown; michael@0: bool mBlocking; michael@0: michael@0: nsCOMPtr mExecutable; michael@0: nsString mTargetPath; michael@0: int32_t mPid; michael@0: nsCOMPtr mObserver; michael@0: nsWeakPtr mWeakObserver; michael@0: michael@0: // These members are modified by multiple threads, any accesses should be michael@0: // protected with mLock. michael@0: int32_t mExitValue; michael@0: #if defined(PROCESSMODEL_WINAPI) michael@0: HANDLE mProcess; michael@0: #elif !defined(XP_MACOSX) michael@0: PRProcess *mProcess; michael@0: #endif michael@0: }; michael@0: michael@0: #endif