зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1621116: Make the version and build ID of the previous instance of Firefox to use the current profile available. r=froydnj
We cache this information in compatibility.ini so we can just expose it on nsIXULRuntime. Differential Revision: https://phabricator.services.mozilla.com/D66112 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
275c8c791c
Коммит
096dde646f
|
@ -690,6 +690,39 @@ nsXULAppInfo::GetRemoteType(nsAString& aRemoteType) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsCString gLastAppVersion;
|
||||
static nsCString gLastAppBuildID;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::GetLastAppVersion(nsACString& aResult) {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!gLastAppVersion.IsVoid() && gLastAppVersion.IsEmpty()) {
|
||||
NS_WARNING("Attempt to retrieve lastAppVersion before it has been set.");
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
aResult.Assign(gLastAppVersion);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::GetLastAppBuildID(nsACString& aResult) {
|
||||
if (XRE_IsContentProcess()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!gLastAppBuildID.IsVoid() && gLastAppBuildID.IsEmpty()) {
|
||||
NS_WARNING("Attempt to retrieve lastAppBuildID before it has been set.");
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
aResult.Assign(gLastAppBuildID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool gBrowserTabsRemoteAutostart = false;
|
||||
static uint64_t gBrowserTabsRemoteStatus = 0;
|
||||
static bool gBrowserTabsRemoteAutostartInitialized = false;
|
||||
|
@ -2450,8 +2483,14 @@ static int32_t CompareBuildIDs(nsACString& oldID, nsACString& newID) {
|
|||
*/
|
||||
int32_t CompareCompatVersions(const nsACString& aOldCompatVersion,
|
||||
const nsACString& aNewCompatVersion) {
|
||||
NS_ASSERTION(gLastAppVersion.IsVoid() && gLastAppBuildID.IsVoid(),
|
||||
"lastAppVersion and lastAppBuildID should be void.");
|
||||
|
||||
// Quick path for the common case.
|
||||
if (aOldCompatVersion.Equals(aNewCompatVersion)) {
|
||||
gLastAppVersion.Assign(gAppData->version);
|
||||
gLastAppBuildID.Assign(gAppData->buildID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2465,10 +2504,8 @@ int32_t CompareCompatVersions(const nsACString& aOldCompatVersion,
|
|||
return -1;
|
||||
}
|
||||
|
||||
nsCString oldVersion;
|
||||
nsCString oldAppBuildID;
|
||||
nsCString oldPlatformBuildID;
|
||||
ExtractCompatVersionInfo(aOldCompatVersion, oldVersion, oldAppBuildID,
|
||||
ExtractCompatVersionInfo(aOldCompatVersion, gLastAppVersion, gLastAppBuildID,
|
||||
oldPlatformBuildID);
|
||||
|
||||
nsCString newVersion;
|
||||
|
@ -2478,13 +2515,13 @@ int32_t CompareCompatVersions(const nsACString& aOldCompatVersion,
|
|||
newPlatformBuildID);
|
||||
|
||||
// In most cases the app version will differ and this is an easy check.
|
||||
int32_t result = CompareVersions(oldVersion.get(), newVersion.get());
|
||||
int32_t result = CompareVersions(gLastAppVersion.get(), newVersion.get());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Fall back to build ID comparison.
|
||||
result = CompareBuildIDs(oldAppBuildID, newAppBuildID);
|
||||
result = CompareBuildIDs(gLastAppBuildID, newAppBuildID);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
|
@ -2508,6 +2545,8 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
|
|||
nsCString& aLastVersion) {
|
||||
*aCachesOK = false;
|
||||
*aIsDowngrade = false;
|
||||
gLastAppVersion.SetIsVoid(true);
|
||||
gLastAppBuildID.SetIsVoid(true);
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aProfileDir->Clone(getter_AddRefs(file));
|
||||
|
|
|
@ -212,4 +212,20 @@ interface nsIXULRuntime : nsISupports
|
|||
* |mozilla::LauncherRegistryInfo::EnabledState| values.
|
||||
*/
|
||||
readonly attribute uint32_t launcherProcessState;
|
||||
|
||||
/**
|
||||
* Returns the last application version that used the current profile or null
|
||||
* if the last version could not be found (compatibility.ini was either
|
||||
* missing or invalid). Throws NS_ERROR_UNAVAILABLE if called from a content
|
||||
* process.
|
||||
*/
|
||||
readonly attribute ACString lastAppVersion;
|
||||
|
||||
/**
|
||||
* Returns the last application build ID that used the current profile or null
|
||||
* if the last build ID could not be found (compatibility.ini was either
|
||||
* missing or invalid). Throws NS_ERROR_UNAVAILABLE if called from a content
|
||||
* process.
|
||||
*/
|
||||
readonly attribute ACString lastAppBuildID;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче