xpcom/threads/nsProcess.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/threads/nsProcess.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _nsPROCESSWIN_H_
    1.10 +#define _nsPROCESSWIN_H_
    1.11 +
    1.12 +#if defined(XP_WIN)
    1.13 +#define PROCESSMODEL_WINAPI
    1.14 +#endif
    1.15 +
    1.16 +#include "mozilla/Attributes.h"
    1.17 +#include "mozilla/Mutex.h"
    1.18 +#include "nsIProcess.h"
    1.19 +#include "nsIFile.h"
    1.20 +#include "nsIThread.h"
    1.21 +#include "nsIObserver.h"
    1.22 +#include "nsIWeakReferenceUtils.h"
    1.23 +#include "nsIObserver.h"
    1.24 +#include "nsString.h"
    1.25 +#ifndef XP_MACOSX
    1.26 +#include "prproces.h"
    1.27 +#endif
    1.28 +#if defined(PROCESSMODEL_WINAPI)
    1.29 +#include <windows.h>
    1.30 +#include <shellapi.h>
    1.31 +#endif
    1.32 +
    1.33 +#define NS_PROCESS_CID \
    1.34 +{0x7b4eeb20, 0xd781, 0x11d4, \
    1.35 +   {0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca}}
    1.36 +
    1.37 +class nsProcess MOZ_FINAL : public nsIProcess,
    1.38 +                            public nsIObserver
    1.39 +{
    1.40 +public:
    1.41 +
    1.42 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.43 +  NS_DECL_NSIPROCESS
    1.44 +  NS_DECL_NSIOBSERVER
    1.45 +
    1.46 +  nsProcess();
    1.47 +
    1.48 +private:
    1.49 +  ~nsProcess();
    1.50 +  static void Monitor(void *arg);
    1.51 +  void ProcessComplete();
    1.52 +  nsresult CopyArgsAndRunProcess(bool blocking, const char** args,
    1.53 +                                 uint32_t count, nsIObserver* observer,
    1.54 +                                 bool holdWeak);
    1.55 +  nsresult CopyArgsAndRunProcessw(bool blocking, const char16_t** args,
    1.56 +                                  uint32_t count, nsIObserver* observer,
    1.57 +                                  bool holdWeak);
    1.58 +  // The 'args' array is null-terminated.
    1.59 +  nsresult RunProcess(bool blocking, char **args, nsIObserver* observer,
    1.60 +                      bool holdWeak, bool argsUTF8);
    1.61 +
    1.62 +  PRThread* mThread;
    1.63 +  mozilla::Mutex mLock;
    1.64 +  bool mShutdown;
    1.65 +  bool mBlocking;
    1.66 +
    1.67 +  nsCOMPtr<nsIFile> mExecutable;
    1.68 +  nsString mTargetPath;
    1.69 +  int32_t mPid;
    1.70 +  nsCOMPtr<nsIObserver> mObserver;
    1.71 +  nsWeakPtr mWeakObserver;
    1.72 +
    1.73 +  // These members are modified by multiple threads, any accesses should be
    1.74 +  // protected with mLock.
    1.75 +  int32_t mExitValue;
    1.76 +#if defined(PROCESSMODEL_WINAPI)
    1.77 +  HANDLE mProcess;
    1.78 +#elif !defined(XP_MACOSX)
    1.79 +  PRProcess *mProcess;
    1.80 +#endif
    1.81 +};
    1.82 +
    1.83 +#endif

mercurial