Bug 751754 - Allow separation between the update-available and start-download states in appcache, r=jduell

This commit is contained in:
Honza Bambas
2012-10-02 15:55:00 +02:00
parent aa943b86b8
commit 8d66114a8b
14 changed files with 374 additions and 45 deletions

View File

@@ -1259,26 +1259,15 @@ AppendJARIdentifier(nsACString &_result, int32_t appId, bool isInBrowserElement)
nsresult
GetJARIdentifier(nsIURI *aURI,
nsILoadContext *aLoadContext,
uint32_t appId, bool isInBrowserElement,
nsACString &_result)
{
_result.Truncate();
if (!aLoadContext)
return NS_OK;
// These lines are here for compatibility only. We must not fill the
// JAR identifier when this is no-app context, otherwise web content
// offline application cache loads would not be satisfied (cache would
// not be found).
bool isInBrowserElement;
nsresult rv = aLoadContext->GetIsInBrowserElement(&isInBrowserElement);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t appId;
rv = aLoadContext->GetAppId(&appId);
NS_ENSURE_SUCCESS(rv, rv);
if (!isInBrowserElement && appId == NECKO_NO_APP_ID)
return NS_OK;
@@ -1291,7 +1280,7 @@ GetJARIdentifier(nsIURI *aURI,
// static
nsresult
nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
nsILoadContext *aLoadContext,
uint32_t appId, bool isInBrowserElement,
nsACString &_result)
{
nsCOMPtr<nsIURI> newURI;
@@ -1305,7 +1294,7 @@ nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
_result.Assign(manifestSpec);
nsAutoCString jarid;
rv = GetJARIdentifier(aManifestURL, aLoadContext, jarid);
rv = GetJARIdentifier(aManifestURL, appId, isInBrowserElement, jarid);
NS_ENSURE_SUCCESS(rv, rv);
// Include JAR ID, i.e. the extended origin if present.
@@ -2442,11 +2431,24 @@ nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
GetStrictFileOriginPolicy()))
return false;
// Get extended origin attributes
uint32_t appId = NECKO_NO_APP_ID;
bool isInBrowserElement = false;
if (loadContext) {
rv = loadContext->GetAppId(&appId);
NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInBrowserElement(&isInBrowserElement);
NS_ENSURE_SUCCESS(rv, false);
}
// Check the groupID we found is equal to groupID based
// on the load context demanding load from app cache.
// This is check of extended origin.
nsAutoCString demandedGroupID;
rv = BuildApplicationCacheGroupID(groupURI, loadContext, demandedGroupID);
rv = BuildApplicationCacheGroupID(groupURI, appId, isInBrowserElement,
demandedGroupID);
NS_ENSURE_SUCCESS(rv, false);
if (groupID != demandedGroupID)