toolkit/xre/nsUpdateDriver.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsUpdateDriver_h__
michael@0 8 #define nsUpdateDriver_h__
michael@0 9
michael@0 10 #include "nscore.h"
michael@0 11 #ifdef MOZ_UPDATER
michael@0 12 #include "nsIUpdateService.h"
michael@0 13 #include "nsIThread.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15 #include "nsString.h"
michael@0 16 #include "mozilla/Attributes.h"
michael@0 17 #endif
michael@0 18
michael@0 19 class nsIFile;
michael@0 20
michael@0 21 #if defined(XP_WIN)
michael@0 22 #include <windows.h>
michael@0 23 typedef HANDLE ProcessType;
michael@0 24 #elif defined(XP_MACOSX)
michael@0 25 typedef pid_t ProcessType;
michael@0 26 #else
michael@0 27 #include "prproces.h"
michael@0 28 typedef PRProcess* ProcessType;
michael@0 29 #endif
michael@0 30
michael@0 31 /**
michael@0 32 * This function processes any available updates. As part of that process, it
michael@0 33 * may exit the current process and relaunch it at a later time.
michael@0 34 *
michael@0 35 * Two directories are passed to this function: greDir (where the actual
michael@0 36 * binary resides) and appDir (which contains application.ini for XULRunner
michael@0 37 * apps). If this is not a XULRunner app then appDir is identical to greDir.
michael@0 38 *
michael@0 39 * The argc and argv passed to this function should be what is needed to
michael@0 40 * relaunch the current process.
michael@0 41 *
michael@0 42 * The appVersion param passed to this function is the current application's
michael@0 43 * version and is used to determine if an update's version is older than the
michael@0 44 * current application version.
michael@0 45 *
michael@0 46 * If you want the update to be processed without restarting, set the restart
michael@0 47 * parameter to false.
michael@0 48 *
michael@0 49 * This function does not modify appDir.
michael@0 50 */
michael@0 51 NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
michael@0 52 nsIFile *updRootDir,
michael@0 53 int argc, char **argv,
michael@0 54 const char *appVersion,
michael@0 55 bool restart = true,
michael@0 56 bool isOSUpdate = false,
michael@0 57 nsIFile *osApplyToDir = nullptr,
michael@0 58 ProcessType *pid = nullptr);
michael@0 59
michael@0 60 #ifdef MOZ_UPDATER
michael@0 61 // The implementation of the update processor handles the task of loading the
michael@0 62 // updater application for staging an update.
michael@0 63 // XXX ehsan this is living in this file in order to make use of the existing
michael@0 64 // stuff here, we might want to move it elsewhere in the future.
michael@0 65 class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor
michael@0 66 {
michael@0 67 public:
michael@0 68 nsUpdateProcessor();
michael@0 69
michael@0 70 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 71 NS_DECL_NSIUPDATEPROCESSOR
michael@0 72
michael@0 73 private:
michael@0 74 struct StagedUpdateInfo {
michael@0 75 StagedUpdateInfo()
michael@0 76 : mArgc(0),
michael@0 77 mArgv(nullptr),
michael@0 78 mIsOSUpdate(false)
michael@0 79 {}
michael@0 80 ~StagedUpdateInfo() {
michael@0 81 for (int i = 0; i < mArgc; ++i) {
michael@0 82 delete[] mArgv[i];
michael@0 83 }
michael@0 84 delete[] mArgv;
michael@0 85 }
michael@0 86
michael@0 87 nsCOMPtr<nsIFile> mGREDir;
michael@0 88 nsCOMPtr<nsIFile> mAppDir;
michael@0 89 nsCOMPtr<nsIFile> mUpdateRoot;
michael@0 90 nsCOMPtr<nsIFile> mOSApplyToDir;
michael@0 91 int mArgc;
michael@0 92 char **mArgv;
michael@0 93 nsAutoCString mAppVersion;
michael@0 94 bool mIsOSUpdate;
michael@0 95 };
michael@0 96
michael@0 97 private:
michael@0 98 void StartStagedUpdate();
michael@0 99 void WaitForProcess();
michael@0 100 void UpdateDone();
michael@0 101 void ShutdownWatcherThread();
michael@0 102
michael@0 103 private:
michael@0 104 ProcessType mUpdaterPID;
michael@0 105 nsCOMPtr<nsIThread> mProcessWatcher;
michael@0 106 nsCOMPtr<nsIUpdate> mUpdate;
michael@0 107 StagedUpdateInfo mInfo;
michael@0 108 };
michael@0 109 #endif
michael@0 110
michael@0 111 #endif // nsUpdateDriver_h__

mercurial