xpcom/threads/nsProcess.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef _nsPROCESSWIN_H_
     7 #define _nsPROCESSWIN_H_
     9 #if defined(XP_WIN)
    10 #define PROCESSMODEL_WINAPI
    11 #endif
    13 #include "mozilla/Attributes.h"
    14 #include "mozilla/Mutex.h"
    15 #include "nsIProcess.h"
    16 #include "nsIFile.h"
    17 #include "nsIThread.h"
    18 #include "nsIObserver.h"
    19 #include "nsIWeakReferenceUtils.h"
    20 #include "nsIObserver.h"
    21 #include "nsString.h"
    22 #ifndef XP_MACOSX
    23 #include "prproces.h"
    24 #endif
    25 #if defined(PROCESSMODEL_WINAPI)
    26 #include <windows.h>
    27 #include <shellapi.h>
    28 #endif
    30 #define NS_PROCESS_CID \
    31 {0x7b4eeb20, 0xd781, 0x11d4, \
    32    {0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca}}
    34 class nsProcess MOZ_FINAL : public nsIProcess,
    35                             public nsIObserver
    36 {
    37 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 *arg);
    48   void ProcessComplete();
    49   nsresult CopyArgsAndRunProcess(bool blocking, const char** args,
    50                                  uint32_t count, nsIObserver* observer,
    51                                  bool holdWeak);
    52   nsresult CopyArgsAndRunProcessw(bool blocking, const char16_t** args,
    53                                   uint32_t count, nsIObserver* observer,
    54                                   bool holdWeak);
    55   // The 'args' array is null-terminated.
    56   nsresult RunProcess(bool blocking, char **args, nsIObserver* observer,
    57                       bool holdWeak, bool argsUTF8);
    59   PRThread* mThread;
    60   mozilla::Mutex mLock;
    61   bool mShutdown;
    62   bool mBlocking;
    64   nsCOMPtr<nsIFile> mExecutable;
    65   nsString mTargetPath;
    66   int32_t mPid;
    67   nsCOMPtr<nsIObserver> mObserver;
    68   nsWeakPtr mWeakObserver;
    70   // These members are modified by multiple threads, any accesses should be
    71   // protected with mLock.
    72   int32_t mExitValue;
    73 #if defined(PROCESSMODEL_WINAPI)
    74   HANDLE mProcess;
    75 #elif !defined(XP_MACOSX)
    76   PRProcess *mProcess;
    77 #endif
    78 };
    80 #endif

mercurial