Skip to content

Commit fb151d0

Browse files
author
Robert Strong
committed
Part 2 - Bug 951662 - remove test code that is no longer needed and change background to staging for consistency. r=bbondy
1 parent bd77281 commit fb151d0

File tree

3 files changed

+28
-54
lines changed

3 files changed

+28
-54
lines changed

toolkit/xre/nsUpdateDriver.cpp

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir,
368368
}
369369

370370
/**
371-
* Switch an existing application directory to an updated version which has been
372-
* previously constructed in the background.
371+
* Switch an existing application directory to an updated version that has been
372+
* staged.
373373
*
374374
* @param greDir the GRE dir
375375
* @param updateDir the update root dir
@@ -640,7 +640,7 @@ SetOSApplyToDir(nsIUpdate* update, const nsACString& osApplyToDir)
640640
#endif
641641

642642
/**
643-
* Apply an update, possibly in the background.
643+
* Apply an update. This applies to both normal and staged updates.
644644
*
645645
* @param greDir the GRE dir
646646
* @param updateDir the update root dir
@@ -649,10 +649,10 @@ SetOSApplyToDir(nsIUpdate* update, const nsACString& osApplyToDir)
649649
* @param appArgc the number of args to the application
650650
* @param appArgv the args to the application, used for restarting if needed
651651
* @param restart if true, apply the update in the foreground and restart the
652-
* application when done. otherwise, apply the update in the
653-
* background and don't restart the application.
652+
* application when done. otherwise, stage the update and don't
653+
* restart the application.
654654
* @param outpid out parameter holding the handle to the updater application for
655-
* background updates.
655+
* staging updates.
656656
*/
657657
static void
658658
ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
@@ -731,8 +731,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
731731
if (NS_FAILED(rv))
732732
return;
733733
if (restart) {
734-
// Use the correct directory if we're not applying the update in the
735-
// background.
734+
// Use the correct directory if we're not staging the update.
736735
rv = parentDir2->GetNativePath(applyToDir);
737736
} else {
738737
if (!GetFile(parentDir2, NS_LITERAL_CSTRING("Updated.app"), updatedDir))
@@ -742,8 +741,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
742741
}
743742
#else
744743
if (restart) {
745-
// Use the correct directory if we're not applying the update in the
746-
// background.
744+
// Use the correct directory if we're not staging the update.
747745
updatedDir = do_QueryInterface(appDir);
748746
} else if (!GetFile(appDir, NS_LITERAL_CSTRING("updated"), updatedDir)) {
749747
return;
@@ -807,8 +805,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
807805
// we pass "0" which is then ignored by the updater.
808806
nsAutoCString pid;
809807
if (!restart) {
810-
// Signal the updater application that it should apply the update in the
811-
// background.
808+
// Signal the updater application that it should stage the update.
812809
pid.AssignASCII("-1");
813810
} else {
814811
#if defined(USE_EXECV)
@@ -876,7 +873,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
876873
LOG(("spawning updater process [%s]\n", updaterPath.get()));
877874

878875
#if defined(USE_EXECV)
879-
// Don't use execv for background updates.
876+
// Don't use execv when staging updates.
880877
if (restart) {
881878
execv(updaterPath.get(), argv);
882879
} else {
@@ -950,34 +947,12 @@ ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
950947
if (NS_FAILED(rv))
951948
return rv;
952949

953-
ProcessType dummyPID; // this will only be used for MOZ_UPDATE_BACKGROUND
950+
ProcessType dummyPID; // this will only be used for MOZ_UPDATE_STAGING
954951
const char *processingUpdates = PR_GetEnv("MOZ_PROCESS_UPDATES");
955952
if (processingUpdates && *processingUpdates) {
956-
// Enable the tests to request us to use a different update root directory
957-
const char *updRootOverride = PR_GetEnv("MOZ_UPDATE_ROOT_OVERRIDE");
958-
if (updRootOverride && *updRootOverride) {
959-
nsCOMPtr<nsIFile> overrideDir;
960-
nsAutoCString path(updRootOverride);
961-
rv = NS_NewNativeLocalFile(path, false, getter_AddRefs(overrideDir));
962-
if (NS_FAILED(rv)) {
963-
return rv;
964-
}
965-
updatesDir = do_QueryInterface(overrideDir);
966-
}
967-
// Enable the tests to request us to use a different app directory
968-
const char *appDirOverride = PR_GetEnv("MOZ_UPDATE_APPDIR_OVERRIDE");
969-
if (appDirOverride && *appDirOverride) {
970-
nsCOMPtr<nsIFile> overrideDir;
971-
nsAutoCString path(appDirOverride);
972-
rv = NS_NewNativeLocalFile(path, false, getter_AddRefs(overrideDir));
973-
if (NS_FAILED(rv)) {
974-
return rv;
975-
}
976-
NS_ADDREF(appDir = overrideDir);
977-
}
978-
// Enable the tests to request us to perform a background update
979-
const char *backgroundUpdate = PR_GetEnv("MOZ_UPDATE_BACKGROUND");
980-
if (backgroundUpdate && *backgroundUpdate) {
953+
// Enable the tests to request an update to be staged.
954+
const char *stagingUpdate = PR_GetEnv("MOZ_UPDATE_STAGING");
955+
if (stagingUpdate && *stagingUpdate) {
981956
restart = false;
982957
pid = &dummyPID;
983958
}
@@ -1003,8 +978,8 @@ ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir,
1003978
}
1004979
case eAppliedUpdate:
1005980
case eAppliedService:
1006-
// An update was applied in the background, so we need to switch to using
1007-
// it now.
981+
// An update was staged and needs to be switched so the updated application
982+
// is used.
1008983
SwitchToUpdatedApp(greDir, updatesDir, statusFile,
1009984
appDir, argc, argv);
1010985
break;
@@ -1108,7 +1083,7 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
11081083
binary->GetNativePath(binPath);
11091084
}
11101085

1111-
// Copy the parameters to the BackgroundUpdateInfo structure shared with the
1086+
// Copy the parameters to the StagedUpdateInfo structure shared with the
11121087
// watcher thread.
11131088
mInfo.mGREDir = greDir;
11141089
mInfo.mAppDir = appDir;
@@ -1155,13 +1130,13 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
11551130

11561131
NS_ABORT_IF_FALSE(NS_IsMainThread(), "not main thread");
11571132
return NS_NewThread(getter_AddRefs(mProcessWatcher),
1158-
NS_NewRunnableMethod(this, &nsUpdateProcessor::StartBackgroundUpdate));
1133+
NS_NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate));
11591134
}
11601135

11611136

11621137

11631138
void
1164-
nsUpdateProcessor::StartBackgroundUpdate()
1139+
nsUpdateProcessor::StartStagedUpdate()
11651140
{
11661141
NS_ABORT_IF_FALSE(!NS_IsMainThread(), "main thread");
11671142

@@ -1178,11 +1153,11 @@ nsUpdateProcessor::StartBackgroundUpdate()
11781153
NS_ENSURE_SUCCESS_VOID(rv);
11791154

11801155
if (mUpdaterPID) {
1181-
// Track the state of the background updater process
1156+
// Track the state of the updater process while it is staging an update.
11821157
rv = NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &nsUpdateProcessor::WaitForProcess));
11831158
NS_ENSURE_SUCCESS_VOID(rv);
11841159
} else {
1185-
// Failed to launch the background updater process for some reason.
1160+
// Failed to launch the updater process for some reason.
11861161
// We need to shutdown the current thread as there isn't anything more for
11871162
// us to do...
11881163
rv = NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsUpdateProcessor::ShutdownWatcherThread));

toolkit/xre/nsUpdateDriver.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ NS_HIDDEN_(nsresult) ProcessUpdates(nsIFile *greDir, nsIFile *appDir,
5959

6060
#ifdef MOZ_UPDATER
6161
// The implementation of the update processor handles the task of loading the
62-
// updater application in the background for applying an update.
62+
// updater application for staging an update.
6363
// XXX ehsan this is living in this file in order to make use of the existing
6464
// stuff here, we might want to move it elsewhere in the future.
6565
class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor
@@ -71,13 +71,13 @@ class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor
7171
NS_DECL_NSIUPDATEPROCESSOR
7272

7373
private:
74-
struct BackgroundUpdateInfo {
75-
BackgroundUpdateInfo()
74+
struct StagedUpdateInfo {
75+
StagedUpdateInfo()
7676
: mArgc(0),
7777
mArgv(nullptr),
7878
mIsOSUpdate(false)
7979
{}
80-
~BackgroundUpdateInfo() {
80+
~StagedUpdateInfo() {
8181
for (int i = 0; i < mArgc; ++i) {
8282
delete[] mArgv[i];
8383
}
@@ -95,7 +95,7 @@ class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor
9595
};
9696

9797
private:
98-
void StartBackgroundUpdate();
98+
void StartStagedUpdate();
9999
void WaitForProcess();
100100
void UpdateDone();
101101
void ShutdownWatcherThread();
@@ -104,7 +104,7 @@ class nsUpdateProcessor MOZ_FINAL : public nsIUpdateProcessor
104104
ProcessType mUpdaterPID;
105105
nsCOMPtr<nsIThread> mProcessWatcher;
106106
nsCOMPtr<nsIUpdate> mUpdate;
107-
BackgroundUpdateInfo mInfo;
107+
StagedUpdateInfo mInfo;
108108
};
109109
#endif
110110

toolkit/xre/nsXREDirProvider.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,7 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult)
10031003
bool pathHashResult = false;
10041004

10051005
nsAutoString appDirPath;
1006-
if (gAppData->vendor && !getenv("MOZ_UPDATE_NO_HASH_DIR") &&
1007-
SUCCEEDED(updRoot->GetPath(appDirPath))) {
1006+
if (gAppData->vendor && SUCCEEDED(updRoot->GetPath(appDirPath))) {
10081007

10091008
// Figure out where we should check for a cached hash value
10101009
wchar_t regPath[1024] = { L'\0' };

0 commit comments

Comments
 (0)