mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
ab9253304f
When Firefox downloads an update, it previously kept the update around to apply it on the next restart. This patch changes this so that the updater program is launched in the background as soon as the update has finished downloading in order to stage the updated version of the application by copying the existing installation directory to a temporary location and applying the update on top of it, and replace the existing installation directory with the staged directory on the next restart. Because the replacing step is typically very fast, this patch eliminates the wait for the update to be applied on restart, making it unnecessary to show a progress dialog when restarting. --HG-- rename : toolkit/mozapps/update/test/chrome/test_0092_finishedBackground.xul => toolkit/mozapps/update/test/chrome/test_0093_stagedBackground.xul rename : toolkit/mozapps/update/test/unit/test_0110_general.js => toolkit/mozapps/update/test/unit/test_0113_general.js rename : toolkit/mozapps/update/test/unit/test_0111_general.js => toolkit/mozapps/update/test/unit/test_0114_general.js rename : toolkit/mozapps/update/test/unit/test_0112_general.js => toolkit/mozapps/update/test/unit/test_0115_general.js rename : toolkit/mozapps/update/test/unit/test_0170_fileLocked_xp_win_complete.js => toolkit/mozapps/update/test/unit/test_0172_fileLocked_xp_win_complete.js rename : toolkit/mozapps/update/test/unit/test_0171_fileLocked_xp_win_partial.js => toolkit/mozapps/update/test/unit/test_0173_fileLocked_xp_win_partial.js rename : toolkit/mozapps/update/test/unit/test_0110_general.js => toolkit/mozapps/update/test_svc/unit/test_0113_general_svc.js rename : toolkit/mozapps/update/test/unit/test_0111_general.js => toolkit/mozapps/update/test_svc/unit/test_0114_general_svc.js rename : toolkit/mozapps/update/test/unit/test_0112_general.js => toolkit/mozapps/update/test_svc/unit/test_0115_general_svc.js rename : toolkit/mozapps/update/test/unit/test_0170_fileLocked_xp_win_complete.js => toolkit/mozapps/update/test_svc/unit/test_0172_fileLocked_xp_win_complete_svc.js rename : toolkit/mozapps/update/test/unit/test_0171_fileLocked_xp_win_partial.js => toolkit/mozapps/update/test_svc/unit/test_0173_fileLocked_xp_win_partial_svc.js
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef nsUpdateDriver_h__
|
|
#define nsUpdateDriver_h__
|
|
|
|
#include "nscore.h"
|
|
#ifdef MOZ_UPDATER
|
|
#include "nsIUpdateService.h"
|
|
#include "nsIThread.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsString.h"
|
|
#endif
|
|
|
|
class nsIFile;
|
|
|
|
#if defined(XP_WIN)
|
|
#include <windows.h>
|
|
typedef HANDLE ProcessType;
|
|
#elif defined(XP_MACOSX)
|
|
typedef pid_t ProcessType;
|
|
#else
|
|
#include "prproces.h"
|
|
typedef PRProcess* ProcessType;
|
|
#endif
|
|
|
|
/**
|
|
* This function processes any available updates. As part of that process, it
|
|
* may exit the current process and relaunch it at a later time.
|
|
*
|
|
* Two directories are passed to this function: greDir (where the actual
|
|
* binary resides) and appDir (which contains application.ini for XULRunner
|
|
* apps). If this is not a XULRunner app then appDir is identical to greDir.
|
|
*
|
|
* The argc and argv passed to this function should be what is needed to
|
|
* relaunch the current process.
|
|
*
|
|
* The appVersion param passed to this function is the current application's
|
|
* version and is used to determine if an update's version is older than the
|
|
* current application version.
|
|
*
|
|
* If you want the update to be processed without restarting, set the restart
|
|
* parameter to false.
|
|
*
|
|
* This function does not modify appDir.
|
|
*/
|
|
NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
|
|
nsIFile *updRootDir,
|
|
int argc, char **argv,
|
|
const char *appVersion,
|
|
bool restart = true,
|
|
ProcessType *pid = nsnull);
|
|
|
|
#ifdef MOZ_UPDATER
|
|
// The implementation of the update processor handles the task of loading the
|
|
// updater application in the background for applying an update.
|
|
// XXX ehsan this is living in this file in order to make use of the existing
|
|
// stuff here, we might want to move it elsewhere in the future.
|
|
class nsUpdateProcessor : public nsIUpdateProcessor
|
|
{
|
|
public:
|
|
nsUpdateProcessor();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIUPDATEPROCESSOR
|
|
|
|
private:
|
|
struct BackgroundUpdateInfo {
|
|
BackgroundUpdateInfo()
|
|
: mArgc(0),
|
|
mArgv(nsnull)
|
|
{}
|
|
~BackgroundUpdateInfo() {
|
|
for (int i = 0; i < mArgc; ++i) {
|
|
delete[] mArgv[i];
|
|
}
|
|
delete[] mArgv;
|
|
}
|
|
|
|
nsCOMPtr<nsIFile> mGREDir;
|
|
nsCOMPtr<nsIFile> mAppDir;
|
|
nsCOMPtr<nsIFile> mUpdateRoot;
|
|
int mArgc;
|
|
char **mArgv;
|
|
nsCAutoString mAppVersion;
|
|
};
|
|
|
|
private:
|
|
void StartBackgroundUpdate();
|
|
void WaitForProcess();
|
|
void UpdateDone();
|
|
void ShutdownWatcherThread();
|
|
|
|
private:
|
|
ProcessType mUpdaterPID;
|
|
nsCOMPtr<nsIThread> mProcessWatcher;
|
|
nsCOMPtr<nsIUpdate> mUpdate;
|
|
BackgroundUpdateInfo mInfo;
|
|
};
|
|
#endif
|
|
|
|
#endif // nsUpdateDriver_h__
|