mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1165256 - Make appcache fully work with OriginAttribues. r=jduell
This commit is contained in:
parent
7ae949cacd
commit
21b84bf0aa
@ -554,7 +554,7 @@ add_task(function* test_offline_cache() {
|
||||
// Store something to the offline cache
|
||||
var appcacheserv = Cc["@mozilla.org/network/application-cache-service;1"]
|
||||
.getService(Ci.nsIApplicationCacheService);
|
||||
var appcachegroupid = appcacheserv.buildGroupID(makeURI(URL + "/manifest"), LoadContextInfo.default);
|
||||
var appcachegroupid = appcacheserv.buildGroupIDForInfo(makeURI(URL + "/manifest"), LoadContextInfo.default);
|
||||
var appcache = appcacheserv.createApplicationCache(appcachegroupid);
|
||||
var storage = Services.cache2.appCacheStorage(LoadContextInfo.default, appcache);
|
||||
|
||||
|
@ -2051,7 +2051,7 @@ this.DOMApplicationRegistry = {
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(appURI,
|
||||
{appId: aApp.localId});
|
||||
let cacheUpdate = updateSvc.scheduleAppUpdate(
|
||||
appcacheURI, docURI, principal, aApp.localId, false, aProfileDir);
|
||||
appcacheURI, docURI, principal, aProfileDir);
|
||||
|
||||
// We save the download details for potential further usage like
|
||||
// cancelling it.
|
||||
@ -2205,7 +2205,7 @@ this.DOMApplicationRegistry = {
|
||||
Services.scriptSecurityManager.createCodebasePrincipal(appURI,
|
||||
{appId: aApp.localId});
|
||||
updateSvc.checkForUpdate(Services.io.newURI(helper.fullAppcachePath(), null, null),
|
||||
principal, app.localId, false, updateObserver);
|
||||
principal, updateObserver);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -2479,8 +2479,7 @@ this.DOMApplicationRegistry = {
|
||||
{appId: aApp.localId});
|
||||
|
||||
updateSvc.checkForUpdate(Services.io.newURI(manifest.fullAppcachePath(), null, null),
|
||||
principal, aApp.localId, false,
|
||||
(aSubject, aTopic, aData) => updateDeferred.resolve(aTopic));
|
||||
principal, (aSubject, aTopic, aData) => updateDeferred.resolve(aTopic));
|
||||
|
||||
let topic = yield updateDeferred.promise;
|
||||
|
||||
|
@ -2813,8 +2813,7 @@ POfflineCacheUpdateChild*
|
||||
ContentChild::AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
|
||||
const URIParams& documentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo,
|
||||
const bool& stickDocument,
|
||||
const TabId& aTabId)
|
||||
const bool& stickDocument)
|
||||
{
|
||||
NS_RUNTIMEABORT("unused");
|
||||
return nullptr;
|
||||
|
@ -574,8 +574,7 @@ public:
|
||||
AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
|
||||
const URIParams& documentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo,
|
||||
const bool& stickDocument,
|
||||
const TabId& aTabId) override;
|
||||
const bool& stickDocument) override;
|
||||
|
||||
virtual bool
|
||||
DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* offlineCacheUpdate) override;
|
||||
|
@ -5246,17 +5246,10 @@ mozilla::docshell::POfflineCacheUpdateParent*
|
||||
ContentParent::AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo,
|
||||
const bool& aStickDocument,
|
||||
const TabId& aTabId)
|
||||
const bool& aStickDocument)
|
||||
{
|
||||
TabContext tabContext;
|
||||
if (!ContentProcessManager::GetSingleton()->
|
||||
GetTabContextByProcessAndTabId(this->ChildID(), aTabId, &tabContext)) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
||||
new mozilla::docshell::OfflineCacheUpdateParent(
|
||||
tabContext.OriginAttributesRef());
|
||||
new mozilla::docshell::OfflineCacheUpdateParent();
|
||||
// Use this reference as the IPDL reference.
|
||||
return update.forget().take();
|
||||
}
|
||||
@ -5266,8 +5259,7 @@ ContentParent::RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aAc
|
||||
const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipal,
|
||||
const bool& aStickDocument,
|
||||
const TabId& aTabId)
|
||||
const bool& aStickDocument)
|
||||
{
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -457,16 +457,14 @@ public:
|
||||
AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipalInfo,
|
||||
const bool& aStickDocument,
|
||||
const TabId& aTabId) override;
|
||||
const bool& aStickDocument) override;
|
||||
|
||||
virtual bool
|
||||
RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
|
||||
const URIParams& aManifestURI,
|
||||
const URIParams& aDocumentURI,
|
||||
const PrincipalInfo& aLoadingPrincipal,
|
||||
const bool& stickDocument,
|
||||
const TabId& aTabId) override;
|
||||
const bool& stickDocument) override;
|
||||
|
||||
virtual bool
|
||||
DeallocPOfflineCacheUpdateParent(POfflineCacheUpdateParent* aActor) override;
|
||||
|
@ -1085,8 +1085,7 @@ parent:
|
||||
* To identify which tab owns the app.
|
||||
*/
|
||||
POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI,
|
||||
PrincipalInfo loadingPrincipal, bool stickDocument,
|
||||
TabId tabId);
|
||||
PrincipalInfo loadingPrincipal, bool stickDocument);
|
||||
|
||||
/**
|
||||
* Sets "offline-app" permission for the principal. Called when we hit
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mozilla/dom/OfflineResourceListBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
#define IS_CHILD_PROCESS() \
|
||||
@ -813,16 +814,18 @@ nsDOMOfflineResourceList::CacheKeys()
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(window);
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
|
||||
|
||||
uint32_t appId = 0;
|
||||
bool inBrowser = false;
|
||||
nsAutoCString originSuffix;
|
||||
if (loadContext) {
|
||||
loadContext->GetAppId(&appId);
|
||||
loadContext->GetIsInBrowserElement(&inBrowser);
|
||||
mozilla::DocShellOriginAttributes oa;
|
||||
bool ok = loadContext->GetOriginAttributes(oa);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
|
||||
|
||||
oa.CreateSuffix(originSuffix);
|
||||
}
|
||||
|
||||
nsAutoCString groupID;
|
||||
mApplicationCacheService->BuildGroupIDForApp(
|
||||
mManifestURI, appId, inBrowser, groupID);
|
||||
mApplicationCacheService->BuildGroupIDForSuffix(
|
||||
mManifestURI, originSuffix, groupID);
|
||||
|
||||
nsCOMPtr<nsIApplicationCache> appCache;
|
||||
mApplicationCacheService->GetActiveCache(groupID,
|
||||
|
@ -324,7 +324,7 @@ getActiveCache: function(overload)
|
||||
// one associated with this window.
|
||||
var serv = Cc["@mozilla.org/network/application-cache-service;1"]
|
||||
.getService(Ci.nsIApplicationCacheService);
|
||||
var groupID = serv.buildGroupID(this.manifestURL(overload), this.loadContextInfo());
|
||||
var groupID = serv.buildGroupIDForInfo(this.manifestURL(overload), this.loadContextInfo());
|
||||
return serv.getActiveCache(groupID);
|
||||
},
|
||||
|
||||
|
@ -34,7 +34,7 @@ var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrin
|
||||
function manifestCached()
|
||||
{
|
||||
// Run first check for an update
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, 0, false, {
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, {
|
||||
observe: function(subject, topic, data) {
|
||||
OfflineTest.is(topic, "offline-cache-update-unavailable", "No update avail");
|
||||
|
||||
@ -42,13 +42,13 @@ function manifestCached()
|
||||
OfflineTest.setSJSState(manifest, "second");
|
||||
|
||||
// Check we now get notification on update ready
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, 0, false, {
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, {
|
||||
observe: function(subject, topic, data) {
|
||||
OfflineTest.is(topic, "offline-cache-update-available", "Update avail (1)");
|
||||
|
||||
// Do the check again. We must get the same result. Double check is here
|
||||
// to make sure we don't overwrite any data in the cache by the check it self.
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, 0, false, {
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, {
|
||||
observe: function(subject, topic, data) {
|
||||
OfflineTest.is(topic, "offline-cache-update-available", "Update avail (2)");
|
||||
|
||||
@ -66,7 +66,7 @@ function manifestCached()
|
||||
function manifestUpdated()
|
||||
{
|
||||
// Check for an update after manifest has been updated
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, 0, false, {
|
||||
updateService.checkForUpdate(manifestURI, systemPrincipal, {
|
||||
observe: function(subject, topic, data) {
|
||||
OfflineTest.is(topic, "offline-cache-update-unavailable", "No update avail (2)");
|
||||
|
||||
|
@ -167,6 +167,7 @@ EXPORTS += [
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'LoadContextInfo.h',
|
||||
'LoadInfo.h',
|
||||
'LoadTainting.h',
|
||||
]
|
||||
|
@ -15,22 +15,17 @@ interface nsILoadContextInfo;
|
||||
* The application cache service manages the set of application cache
|
||||
* groups.
|
||||
*/
|
||||
[scriptable, uuid(03b41c3d-0816-4134-8b2e-4f5afbdb1f06)]
|
||||
[scriptable, uuid(b8b6546c-6cec-4bda-82df-08e006a97b56)]
|
||||
interface nsIApplicationCacheService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Create group string identifying cache group according the manifest
|
||||
* URL and the given load context.
|
||||
* URL and the given principal.
|
||||
*/
|
||||
ACString buildGroupID(in nsIURI aManifestURL,
|
||||
in nsILoadContextInfo aLoadContextInfo);
|
||||
|
||||
/**
|
||||
* Same as buildGroupID method, just doesn't require load context.
|
||||
*/
|
||||
ACString buildGroupIDForApp(in nsIURI aManifestURL,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser);
|
||||
ACString buildGroupIDForInfo(in nsIURI aManifestURL,
|
||||
in nsILoadContextInfo aLoadContextInfo);
|
||||
ACString buildGroupIDForSuffix(in nsIURI aManifestURL,
|
||||
in ACString aOriginSuffix);
|
||||
|
||||
/**
|
||||
* Create a new, empty application cache for the given cache
|
||||
@ -70,18 +65,15 @@ interface nsIApplicationCacheService : nsISupports
|
||||
void deactivateGroup(in ACString group);
|
||||
|
||||
/**
|
||||
* Deletes some or all of an application's cache entries.
|
||||
*
|
||||
* @param appId
|
||||
* The mozIApplication.localId of the application.
|
||||
*
|
||||
* @param discardOnlyBrowserEntries
|
||||
* If true, only entries marked as 'inBrowserElement' are deleted
|
||||
* (this is used by browser applications to delete user browsing
|
||||
* data/history.). If false, *all* entries for the given appId are
|
||||
* deleted (this is used for application uninstallation).
|
||||
* Evict offline cache entries, either all of them or those belonging
|
||||
* to the given origin.
|
||||
*/
|
||||
void discardByAppId(in int32_t appID, in boolean discardOnlyBrowserEntries);
|
||||
void evict(in nsILoadContextInfo aLoadContextInfo);
|
||||
|
||||
/**
|
||||
* Delete caches whom origin attributes matches the given pattern.
|
||||
*/
|
||||
void evictMatchingOriginAttributes(in AString aPattern);
|
||||
|
||||
/**
|
||||
* Try to find the best application cache to serve a resource.
|
||||
|
76
netwerk/cache/nsApplicationCacheService.cpp
vendored
76
netwerk/cache/nsApplicationCacheService.cpp
vendored
@ -11,7 +11,8 @@
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsILoadContextInfo.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "mozilla/LoadContextInfo.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -34,34 +35,35 @@ nsApplicationCacheService::~nsApplicationCacheService()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsApplicationCacheService::BuildGroupID(nsIURI *aManifestURL,
|
||||
nsILoadContextInfo *aLoadContextInfo,
|
||||
nsACString &_result)
|
||||
nsApplicationCacheService::BuildGroupIDForInfo(
|
||||
nsIURI *aManifestURL,
|
||||
nsILoadContextInfo *aLoadContextInfo,
|
||||
nsACString &_result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mozilla::NeckoOriginAttributes const *oa = aLoadContextInfo
|
||||
? aLoadContextInfo->OriginAttributesPtr()
|
||||
: nullptr;
|
||||
nsAutoCString originSuffix;
|
||||
if (aLoadContextInfo) {
|
||||
aLoadContextInfo->OriginAttributesPtr()->CreateSuffix(originSuffix);
|
||||
}
|
||||
|
||||
rv = nsOfflineCacheDevice::BuildApplicationCacheGroupID(
|
||||
aManifestURL, oa, _result);
|
||||
aManifestURL, originSuffix, _result);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsApplicationCacheService::BuildGroupIDForApp(nsIURI *aManifestURL,
|
||||
uint32_t aAppId,
|
||||
bool aIsInBrowser,
|
||||
nsACString &_result)
|
||||
nsApplicationCacheService::BuildGroupIDForSuffix(
|
||||
nsIURI *aManifestURL,
|
||||
nsACString const &aOriginSuffix,
|
||||
nsACString &_result)
|
||||
{
|
||||
NeckoOriginAttributes oa;
|
||||
oa.mAppId = aAppId;
|
||||
oa.mInBrowser = aIsInBrowser;
|
||||
nsresult rv = nsOfflineCacheDevice::BuildApplicationCacheGroupID(
|
||||
aManifestURL, &oa, _result);
|
||||
nsresult rv;
|
||||
|
||||
rv = nsOfflineCacheDevice::BuildApplicationCacheGroupID(
|
||||
aManifestURL, aOriginSuffix, _result);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
@ -164,7 +166,7 @@ nsApplicationCacheService::CacheOpportunistically(nsIApplicationCache* cache,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsApplicationCacheService::DiscardByAppId(int32_t appID, bool isInBrowser)
|
||||
nsApplicationCacheService::Evict(nsILoadContextInfo *aInfo)
|
||||
{
|
||||
if (!mCacheService)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
@ -172,7 +174,26 @@ nsApplicationCacheService::DiscardByAppId(int32_t appID, bool isInBrowser)
|
||||
RefPtr<nsOfflineCacheDevice> device;
|
||||
nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return device->DiscardByAppId(appID, isInBrowser);
|
||||
return device->Evict(aInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsApplicationCacheService::EvictMatchingOriginAttributes(nsAString const &aPattern)
|
||||
{
|
||||
if (!mCacheService)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
RefPtr<nsOfflineCacheDevice> device;
|
||||
nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mozilla::OriginAttributesPattern pattern;
|
||||
if (!pattern.Init(aPattern)) {
|
||||
NS_ERROR("Could not parse OriginAttributesPattern JSON in clear-origin-data notification");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return device->Evict(pattern);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -216,19 +237,15 @@ public:
|
||||
NS_IMETHODIMP
|
||||
Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) override
|
||||
{
|
||||
MOZ_ASSERT(!nsCRT::strcmp(aTopic, TOPIC_WEB_APP_CLEAR_DATA));
|
||||
MOZ_ASSERT(!nsCRT::strcmp(aTopic, "clear-origin-data"));
|
||||
|
||||
uint32_t appId = NECKO_UNKNOWN_APP_ID;
|
||||
bool browserOnly = false;
|
||||
nsresult rv = NS_GetAppInfoFromClearDataNotification(aSubject, &appId,
|
||||
&browserOnly);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIApplicationCacheService> cacheService =
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return cacheService->DiscardByAppId(appId, browserOnly);
|
||||
return cacheService->EvictMatchingOriginAttributes(nsDependentString(aData));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -245,10 +262,7 @@ nsApplicationCacheService::AppClearDataObserverInit()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
||||
if (observerService) {
|
||||
RefPtr<AppCacheClearDataObserver> obs
|
||||
= new AppCacheClearDataObserver();
|
||||
observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA,
|
||||
/*holdsWeak=*/ false);
|
||||
RefPtr<AppCacheClearDataObserver> obs = new AppCacheClearDataObserver();
|
||||
observerService->AddObserver(obs, "clear-origin-data", /*holdsWeak=*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
|
223
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
223
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@ -48,6 +48,8 @@
|
||||
|
||||
#include "sqlite3.h"
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsVariant.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::storage;
|
||||
@ -1305,21 +1307,12 @@ GetGroupForCache(const nsCSubstring &clientID, nsCString &group)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
AppendJARIdentifier(nsACString &_result, NeckoOriginAttributes const *aOriginAttributes)
|
||||
{
|
||||
nsAutoCString suffix;
|
||||
aOriginAttributes->CreateSuffix(suffix);
|
||||
_result.Append('#');
|
||||
_result.Append(suffix);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
|
||||
NeckoOriginAttributes const *aOriginAttributes,
|
||||
nsACString const &aOriginSuffix,
|
||||
nsACString &_result)
|
||||
{
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
@ -1331,10 +1324,8 @@ nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
_result.Assign(manifestSpec);
|
||||
|
||||
if (aOriginAttributes) {
|
||||
AppendJARIdentifier(_result, aOriginAttributes);
|
||||
}
|
||||
_result.Append('#');
|
||||
_result.Append(aOriginSuffix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2405,55 +2396,156 @@ nsOfflineCacheDevice::DeactivateGroup(const nsACString &group)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheDevice::DiscardByAppId(int32_t appID, bool browserEntriesOnly)
|
||||
nsOfflineCacheDevice::Evict(nsILoadContextInfo *aInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(aInfo);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
mozilla::OriginAttributes const *oa = aInfo->OriginAttributesPtr();
|
||||
|
||||
if (oa->mAppId == NECKO_NO_APP_ID && oa->mInBrowser == false) {
|
||||
nsCOMPtr<nsICacheService> serv = do_GetService(kCacheServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return nsCacheService::GlobalInstance()->EvictEntriesInternal(nsICache::STORE_OFFLINE);
|
||||
}
|
||||
|
||||
nsAutoCString jaridsuffix;
|
||||
jaridsuffix.Append('%');
|
||||
|
||||
nsAutoCString suffix;
|
||||
oa->CreateSuffix(suffix);
|
||||
jaridsuffix.Append('#');
|
||||
jaridsuffix.Append(suffix);
|
||||
|
||||
AutoResetStatement statement(mStatement_EnumerateApps);
|
||||
rv = statement->BindUTF8StringByIndex(0, jaridsuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hasRows;
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (hasRows) {
|
||||
nsAutoCString group;
|
||||
rv = statement->GetUTF8String(0, group);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString clientID;
|
||||
rv = statement->GetUTF8String(1, clientID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsOfflineCacheDiscardCache(this, group, clientID);
|
||||
|
||||
rv = nsCacheService::DispatchToCacheIOThread(ev);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace { // anon
|
||||
|
||||
class OriginMatch final : public mozIStorageFunction
|
||||
{
|
||||
~OriginMatch() {}
|
||||
mozilla::OriginAttributesPattern const mPattern;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_MOZISTORAGEFUNCTION
|
||||
explicit OriginMatch(mozilla::OriginAttributesPattern const &aPattern)
|
||||
: mPattern(aPattern) {}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(OriginMatch, mozIStorageFunction)
|
||||
|
||||
NS_IMETHODIMP
|
||||
OriginMatch::OnFunctionCall(mozIStorageValueArray* aFunctionArguments, nsIVariant** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoCString jaridsuffix;
|
||||
nsAutoCString groupId;
|
||||
rv = aFunctionArguments->GetUTF8String(0, groupId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
jaridsuffix.Append('%');
|
||||
|
||||
// TODO - this method should accept NeckoOriginAttributes* from outside instead.
|
||||
// If passed null, we should then delegate to
|
||||
// nsCacheService::GlobalInstance()->EvictEntriesInternal(nsICache::STORE_OFFLINE);
|
||||
|
||||
NeckoOriginAttributes oa;
|
||||
oa.mAppId = appID;
|
||||
oa.mInBrowser = browserEntriesOnly;
|
||||
AppendJARIdentifier(jaridsuffix, &oa);
|
||||
|
||||
{
|
||||
AutoResetStatement statement(mStatement_EnumerateApps);
|
||||
rv = statement->BindUTF8StringByIndex(0, jaridsuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool hasRows;
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (hasRows) {
|
||||
nsAutoCString group;
|
||||
rv = statement->GetUTF8String(0, group);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString clientID;
|
||||
rv = statement->GetUTF8String(1, clientID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsOfflineCacheDiscardCache(this, group, clientID);
|
||||
|
||||
rv = nsCacheService::DispatchToCacheIOThread(ev);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
int32_t hash = groupId.Find(NS_LITERAL_CSTRING("#"));
|
||||
if (hash == kNotFound) {
|
||||
// Just ignore...
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!browserEntriesOnly) {
|
||||
// If deleting app, delete any 'inBrowserElement' entries too
|
||||
rv = DiscardByAppId(appID, true);
|
||||
++hash;
|
||||
|
||||
nsDependentCSubstring suffix(groupId.BeginReading() + hash, groupId.Length() - hash);
|
||||
|
||||
mozilla::NeckoOriginAttributes oa;
|
||||
bool ok = oa.PopulateFromSuffix(suffix);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
|
||||
|
||||
bool match = mPattern.Matches(oa);
|
||||
|
||||
RefPtr<nsVariant> outVar(new nsVariant());
|
||||
rv = outVar->SetAsUint32(match ? 1 : 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
outVar.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // anon
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheDevice::Evict(mozilla::OriginAttributesPattern const &aPattern)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<mozIStorageFunction> function1(new OriginMatch(aPattern));
|
||||
rv = mDB->CreateFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"), 1, function1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
class AutoRemoveFunc {
|
||||
public:
|
||||
mozIStorageConnection* mDB;
|
||||
explicit AutoRemoveFunc(mozIStorageConnection* aDB) : mDB(aDB) {}
|
||||
~AutoRemoveFunc() {
|
||||
mDB->RemoveFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"));
|
||||
}
|
||||
};
|
||||
AutoRemoveFunc autoRemove(mDB);
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> statement;
|
||||
rv = mDB->CreateStatement(
|
||||
NS_LITERAL_CSTRING("SELECT GroupID, ActiveClientID FROM moz_cache_groups WHERE ORIGIN_MATCH(GroupID);"),
|
||||
getter_AddRefs(statement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AutoResetStatement statementScope(statement);
|
||||
|
||||
bool hasRows;
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (hasRows) {
|
||||
nsAutoCString group;
|
||||
rv = statement->GetUTF8String(0, group);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString clientID;
|
||||
rv = statement->GetUTF8String(1, clientID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsOfflineCacheDiscardCache(this, group, clientID);
|
||||
|
||||
rv = nsCacheService::DispatchToCacheIOThread(ev);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = statement->ExecuteStep(&hasRows);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -2495,12 +2587,12 @@ nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
|
||||
// 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;
|
||||
|
||||
const NeckoOriginAttributes *oa = loadContextInfo
|
||||
? loadContextInfo->OriginAttributesPtr()
|
||||
: nullptr;
|
||||
rv = BuildApplicationCacheGroupID(groupURI, oa, demandedGroupID);
|
||||
nsAutoCString originSuffix;
|
||||
loadContextInfo->OriginAttributesPtr()->CreateSuffix(originSuffix);
|
||||
|
||||
nsAutoCString demandedGroupID;
|
||||
rv = BuildApplicationCacheGroupID(groupURI, originSuffix, demandedGroupID);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
if (groupID != demandedGroupID) {
|
||||
@ -2516,10 +2608,14 @@ nsOfflineCacheDevice::ChooseApplicationCache(const nsACString &key,
|
||||
nsILoadContextInfo *loadContextInfo,
|
||||
nsIApplicationCache **out)
|
||||
{
|
||||
NS_ENSURE_ARG(loadContextInfo);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
*out = nullptr;
|
||||
|
||||
nsCOMPtr<nsIURI> keyURI;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(keyURI), key);
|
||||
rv = NS_NewURI(getter_AddRefs(keyURI), key);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// First try to find a matching cache entry.
|
||||
@ -2700,6 +2796,7 @@ nsOfflineCacheDevice::AutoShutdown(nsIApplicationCache * aAppCache)
|
||||
|
||||
Shutdown();
|
||||
|
||||
nsCOMPtr<nsICacheService> serv = do_GetService(kCacheServiceCID);
|
||||
RefPtr<nsCacheService> cacheService = nsCacheService::GlobalInstance();
|
||||
cacheService->RemoveCustomOfflineDevice(this);
|
||||
|
||||
|
8
netwerk/cache/nsDiskCacheDeviceSQL.h
vendored
8
netwerk/cache/nsDiskCacheDeviceSQL.h
vendored
@ -25,7 +25,8 @@
|
||||
class nsIURI;
|
||||
class nsOfflineCacheDevice;
|
||||
class mozIStorageService;
|
||||
namespace mozilla { class NeckoOriginAttributes; }
|
||||
class nsILoadContextInfo;
|
||||
namespace mozilla { class OriginAttributesPattern; }
|
||||
|
||||
class nsApplicationCacheNamespace final : public nsIApplicationCacheNamespace
|
||||
{
|
||||
@ -141,7 +142,7 @@ public:
|
||||
nsresult EvictUnownedEntries(const char *clientID);
|
||||
|
||||
static nsresult BuildApplicationCacheGroupID(nsIURI *aManifestURL,
|
||||
mozilla::NeckoOriginAttributes const *aOriginAttributes,
|
||||
nsACString const &aOriginSuffix,
|
||||
nsACString &_result);
|
||||
|
||||
nsresult ActivateCache(const nsCSubstring &group,
|
||||
@ -168,7 +169,8 @@ public:
|
||||
nsresult CacheOpportunistically(nsIApplicationCache* cache,
|
||||
const nsACString &key);
|
||||
|
||||
nsresult DiscardByAppId(int32_t appID, bool isInBrowser);
|
||||
nsresult Evict(nsILoadContextInfo *aInfo);
|
||||
nsresult Evict(mozilla::OriginAttributesPattern const &aPattern);
|
||||
|
||||
nsresult GetGroups(uint32_t *count,char ***keys);
|
||||
|
||||
|
@ -119,30 +119,15 @@ NS_IMETHODIMP AppCacheStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCal
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIApplicationCacheService> appCacheService =
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mAppCache) {
|
||||
// TODO - bug 1165256, have an API on nsIApplicationCacheService that takes
|
||||
// optional OAs and decides internally what to do.
|
||||
const NeckoOriginAttributes* oa = LoadInfo()->OriginAttributesPtr();
|
||||
if (oa->mAppId == nsILoadContextInfo::NO_APP_ID && !oa->mInBrowser) {
|
||||
// Clear everything.
|
||||
nsCOMPtr<nsICacheService> serv =
|
||||
do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// Discard everything under this storage context
|
||||
nsCOMPtr<nsIApplicationCacheService> appCacheService =
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsCacheService::GlobalInstance()->EvictEntriesInternal(nsICache::STORE_OFFLINE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
// Clear app or inbrowser staff.
|
||||
rv = appCacheService->DiscardByAppId(oa->mAppId, oa->mInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rv = appCacheService->Evict(LoadInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// Discard the group
|
||||
RefPtr<_OldStorage> old = new _OldStorage(
|
||||
LoadInfo(), WriteToDisk(), LookupAppCache(), true, mAppCache);
|
||||
|
@ -995,71 +995,48 @@ NS_IMETHODIMP _OldStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCallbac
|
||||
nsresult rv;
|
||||
|
||||
if (!mAppCache && mOfflineStorage) {
|
||||
// TODO - bug 1165256, have an API on nsIApplicationCacheService that takes
|
||||
// optional OAs and decides internally what to do.
|
||||
nsCOMPtr<nsIApplicationCacheService> appCacheService =
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Special casing for pure offline storage
|
||||
if (mLoadInfo->OriginAttributesPtr()->mAppId == nsILoadContextInfo::NO_APP_ID &&
|
||||
!mLoadInfo->OriginAttributesPtr()->mInBrowser) {
|
||||
rv = appCacheService->Evict(mLoadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (mAppCache) {
|
||||
nsCOMPtr<nsICacheSession> session;
|
||||
rv = GetCacheSession(EmptyCString(),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Clear everything.
|
||||
nsCOMPtr<nsICacheService> serv =
|
||||
do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// Oh, I'll be so happy when session names are gone...
|
||||
nsCOMPtr<nsICacheSession> session;
|
||||
rv = GetCacheSession(NS_LITERAL_CSTRING("http"),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nsCacheService::GlobalInstance()->EvictEntriesInternal(nsICache::STORE_OFFLINE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
// Clear app or inbrowser staff.
|
||||
nsCOMPtr<nsIApplicationCacheService> appCacheService =
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = appCacheService->DiscardByAppId(mLoadInfo->OriginAttributesPtr()->mAppId,
|
||||
mLoadInfo->OriginAttributesPtr()->mInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mAppCache) {
|
||||
nsCOMPtr<nsICacheSession> session;
|
||||
rv = GetCacheSession(EmptyCString(),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = GetCacheSession(NS_LITERAL_CSTRING("wyciwyg"),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
// Oh, I'll be so happy when session names are gone...
|
||||
nsCOMPtr<nsICacheSession> session;
|
||||
rv = GetCacheSession(NS_LITERAL_CSTRING("http"),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// This clears any data from scheme other then http, wyciwyg or ftp
|
||||
rv = GetCacheSession(EmptyCString(),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = GetCacheSession(NS_LITERAL_CSTRING("wyciwyg"),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This clears any data from scheme other then http, wyciwyg or ftp
|
||||
rv = GetCacheSession(EmptyCString(),
|
||||
mWriteToDisk, mLoadInfo, mAppCache,
|
||||
getter_AddRefs(session));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = session->EvictEntries();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aCallback) {
|
||||
|
@ -127,7 +127,6 @@ function run_test()
|
||||
make_uri("http://localhost:4444/manifest"),
|
||||
make_uri("http://localhost:4444/masterEntry"),
|
||||
systemPrincipal,
|
||||
0 /* no AppID */, false /* not in browser*/,
|
||||
customDir);
|
||||
|
||||
var expectedStates = [
|
||||
|
@ -77,8 +77,6 @@ OfflineCacheUpdateChild::OfflineCacheUpdateChild(nsIDOMWindow* aWindow)
|
||||
: mState(STATE_UNINITIALIZED)
|
||||
, mIsUpgrade(false)
|
||||
, mSucceeded(false)
|
||||
, mAppID(NECKO_NO_APP_ID)
|
||||
, mInBrowser(false)
|
||||
, mWindow(aWindow)
|
||||
, mByteProgress(0)
|
||||
{
|
||||
@ -178,9 +176,7 @@ OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal *aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser)
|
||||
nsIFile *aCustomProfileDir)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -222,9 +218,6 @@ OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
|
||||
if (aDocument)
|
||||
SetDocument(aDocument);
|
||||
|
||||
mAppID = aAppID;
|
||||
mInBrowser = aInBrowser;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -243,8 +236,6 @@ OfflineCacheUpdateChild::InitPartial(nsIURI *aManifestURI,
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateChild::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
{
|
||||
NS_NOTREACHED("Not expected to do only update checks"
|
||||
@ -444,7 +435,7 @@ OfflineCacheUpdateChild::Schedule()
|
||||
// the work has been done.
|
||||
ContentChild::GetSingleton()->SendPOfflineCacheUpdateConstructor(
|
||||
this, manifestURI, documentURI, loadingPrincipalInfo,
|
||||
stickDocument, child->GetTabId());
|
||||
stickDocument);
|
||||
|
||||
// ContentChild::DeallocPOfflineCacheUpdate will release this.
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -72,9 +72,6 @@ private:
|
||||
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
|
||||
uint32_t mAppID;
|
||||
bool mInBrowser;
|
||||
|
||||
/* Clients watching this update for changes */
|
||||
nsCOMArray<nsIWeakReference> mWeakObservers;
|
||||
nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers;
|
||||
|
@ -99,14 +99,18 @@ OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser)
|
||||
nsIFile *aCustomProfileDir)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoCString originSuffix;
|
||||
rv = aLoadingPrincipal->GetOriginSuffix(originSuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsOfflineCacheUpdateService* service =
|
||||
nsOfflineCacheUpdateService::EnsureService();
|
||||
if (service) {
|
||||
service->FindUpdate(aManifestURI, aAppID, aInBrowser, aCustomProfileDir,
|
||||
service->FindUpdate(aManifestURI, originSuffix, aCustomProfileDir,
|
||||
getter_AddRefs(mUpdate));
|
||||
mCoalesced = !!mUpdate;
|
||||
}
|
||||
@ -126,7 +130,7 @@ OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
|
||||
}
|
||||
|
||||
return mUpdate->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr,
|
||||
aCustomProfileDir, aAppID, aInBrowser);
|
||||
aCustomProfileDir);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -30,7 +30,7 @@ namespace docshell {
|
||||
NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \
|
||||
NS_IMETHOD GetSucceeded(bool *aSucceeded) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \
|
||||
NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI, nsIPrincipal *aLoadingPrincipal) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI, aLoadingPrincipal); } \
|
||||
NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, nsIPrincipal* aLoadingPrincipal, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aAppID, aInBrowser, aObserver); } \
|
||||
NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, nsIPrincipal* aLoadingPrincipal, nsIObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aObserver); } \
|
||||
NS_IMETHOD AddDynamicURI(nsIURI *aURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \
|
||||
NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \
|
||||
NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \
|
||||
@ -54,9 +54,7 @@ public:
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser) override;
|
||||
nsIFile *aCustomProfileDir) override;
|
||||
|
||||
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
|
||||
|
||||
|
@ -54,9 +54,9 @@ NS_IMPL_ISUPPORTS(OfflineCacheUpdateParent,
|
||||
// OfflineCacheUpdateParent <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
OfflineCacheUpdateParent::OfflineCacheUpdateParent(const DocShellOriginAttributes& aAttrs)
|
||||
|
||||
OfflineCacheUpdateParent::OfflineCacheUpdateParent()
|
||||
: mIPCClosed(false)
|
||||
, mOriginAttributes(aAttrs)
|
||||
{
|
||||
// Make sure the service has been initialized
|
||||
nsOfflineCacheUpdateService::EnsureService();
|
||||
@ -83,11 +83,16 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
{
|
||||
LOG(("OfflineCacheUpdateParent::RecvSchedule [%p]", this));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
RefPtr<nsOfflineCacheUpdate> update;
|
||||
nsCOMPtr<nsIURI> manifestURI = DeserializeURI(aManifestURI);
|
||||
if (!manifestURI)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mLoadingPrincipal = PrincipalInfoToPrincipal(aLoadingPrincipalInfo, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsOfflineCacheUpdateService* service =
|
||||
nsOfflineCacheUpdateService::EnsureService();
|
||||
if (!service)
|
||||
@ -95,13 +100,8 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
|
||||
bool offlinePermissionAllowed = false;
|
||||
|
||||
PrincipalOriginAttributes principalAttrs;
|
||||
principalAttrs.InheritFromDocShellToDoc(mOriginAttributes, manifestURI);
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
BasePrincipal::CreateCodebasePrincipal(manifestURI, principalAttrs);
|
||||
|
||||
nsresult rv = service->OfflineAppAllowed(
|
||||
principal, nullptr, &offlinePermissionAllowed);
|
||||
rv = service->OfflineAppAllowed(
|
||||
mLoadingPrincipal, nullptr, &offlinePermissionAllowed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!offlinePermissionAllowed)
|
||||
@ -114,23 +114,20 @@ OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI,
|
||||
if (!NS_SecurityCompareURIs(manifestURI, documentURI, false))
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
|
||||
// TODO: Bug 1197093 - add originAttributes to nsIOfflineCacheUpdate
|
||||
nsAutoCString originSuffix;
|
||||
rv = mLoadingPrincipal->GetOriginSuffix(originSuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
service->FindUpdate(manifestURI,
|
||||
mOriginAttributes.mAppId,
|
||||
mOriginAttributes.mInBrowser,
|
||||
originSuffix,
|
||||
nullptr,
|
||||
getter_AddRefs(update));
|
||||
if (!update) {
|
||||
update = new nsOfflineCacheUpdate();
|
||||
|
||||
nsCOMPtr<nsIPrincipal> loadingPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadingPrincipalInfo, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Leave aDocument argument null. Only glues and children keep
|
||||
// document instances.
|
||||
rv = update->Init(manifestURI, documentURI, loadingPrincipal, nullptr, nullptr,
|
||||
mOriginAttributes.mAppId, mOriginAttributes.mInBrowser);
|
||||
rv = update->Init(manifestURI, documentURI, mLoadingPrincipal, nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->Schedule();
|
||||
@ -264,25 +261,28 @@ OfflineCacheUpdateParent::SetRemoteTabs(bool aUseRemoteTabs)
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateParent::GetIsInBrowserElement(bool *aIsInBrowserElement)
|
||||
{
|
||||
*aIsInBrowserElement = mOriginAttributes.mInBrowser;
|
||||
return NS_OK;
|
||||
NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED);
|
||||
return mLoadingPrincipal->GetIsInBrowserElement(aIsInBrowserElement);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateParent::GetAppId(uint32_t *aAppId)
|
||||
{
|
||||
*aAppId = mOriginAttributes.mAppId;
|
||||
return NS_OK;
|
||||
NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED);
|
||||
return mLoadingPrincipal->GetAppId(aAppId);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateParent::GetOriginAttributes(JS::MutableHandleValue aAttrs)
|
||||
{
|
||||
NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
bool ok = ToJSValue(cx, mOriginAttributes, aAttrs);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
nsresult rv = mLoadingPrincipal->GetOriginAttributes(cx, aAttrs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,12 @@
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsIOfflineCacheUpdate.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILoadContext.h"
|
||||
|
||||
class nsIPrincipal;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace ipc {
|
||||
@ -45,7 +48,7 @@ public:
|
||||
mIPCClosed = true;
|
||||
}
|
||||
|
||||
explicit OfflineCacheUpdateParent(const mozilla::DocShellOriginAttributes& aAttrs);
|
||||
explicit OfflineCacheUpdateParent();
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
private:
|
||||
@ -53,7 +56,7 @@ private:
|
||||
|
||||
bool mIPCClosed;
|
||||
|
||||
mozilla::DocShellOriginAttributes mOriginAttributes;
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
};
|
||||
|
||||
} // namespace docshell
|
||||
|
@ -58,7 +58,7 @@ interface nsIOfflineCacheUpdateObserver : nsISupports {
|
||||
* load its items one by one, sending itemCompleted() to any registered
|
||||
* observers.
|
||||
*/
|
||||
[scriptable, uuid(e9029838-3553-4192-a00b-f0f11073a6eb)]
|
||||
[scriptable, uuid(6e3e26ea-45b2-4db7-9e4a-93b965679298)]
|
||||
interface nsIOfflineCacheUpdate : nsISupports {
|
||||
/**
|
||||
* Fetch the status of the running update. This will return a value
|
||||
@ -108,9 +108,7 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in nsIDOMDocument aDocument,
|
||||
[optional] in nsIFile aCustomProfileDir,
|
||||
[optional] in unsigned long aAppId,
|
||||
[optional] in boolean aInBrowser);
|
||||
[optional] in nsIFile aCustomProfileDir);
|
||||
|
||||
/**
|
||||
* Initialize the update for partial processing.
|
||||
@ -134,10 +132,6 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
*
|
||||
* @param aManifestURI
|
||||
* The manifest URI of the related cache.
|
||||
* @param aAppID
|
||||
* Local ID of an app (optional) to check the cache update for.
|
||||
* @param aInBrowser
|
||||
* Whether to check for a cache populated from browser element.
|
||||
* @param aObserver
|
||||
* nsIObserver implementation that receives the result.
|
||||
* When aTopic == "offline-cache-update-available" there is an update to
|
||||
@ -148,8 +142,6 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
*/
|
||||
void initForUpdateCheck(in nsIURI aManifestURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIObserver aObserver);
|
||||
|
||||
/**
|
||||
@ -199,7 +191,7 @@ interface nsIOfflineCacheUpdate : nsISupports {
|
||||
readonly attribute uint64_t byteProgress;
|
||||
};
|
||||
|
||||
[scriptable, uuid(a297a334-bcae-4779-a564-555593edc96b)]
|
||||
[scriptable, uuid(39aee0e8-9478-475d-8b62-7535293cae08)]
|
||||
interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
/**
|
||||
* Constants for the offline-app permission.
|
||||
@ -239,8 +231,6 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
nsIOfflineCacheUpdate scheduleAppUpdate(in nsIURI aManifestURI,
|
||||
in nsIURI aDocumentURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIFile aProfileDir);
|
||||
|
||||
/**
|
||||
@ -265,8 +255,6 @@ interface nsIOfflineCacheUpdateService : nsISupports {
|
||||
*/
|
||||
void checkForUpdate(in nsIURI aManifestURI,
|
||||
in nsIPrincipal aLoadingPrincipal,
|
||||
in unsigned long aAppID,
|
||||
in boolean aInBrowser,
|
||||
in nsIObserver aObserver);
|
||||
|
||||
/**
|
||||
|
@ -1163,8 +1163,6 @@ nsOfflineCacheUpdate::nsOfflineCacheUpdate()
|
||||
, mOnlyCheckUpdate(false)
|
||||
, mSucceeded(true)
|
||||
, mObsolete(false)
|
||||
, mAppID(NECKO_NO_APP_ID)
|
||||
, mInBrowser(false)
|
||||
, mItemsInProgress(0)
|
||||
, mRescheduleCount(0)
|
||||
, mPinnedEntryRetriesCount(0)
|
||||
@ -1228,9 +1226,7 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIFile *aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser)
|
||||
nsIFile *aCustomProfileDir)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -1249,12 +1245,14 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString originSuffix;
|
||||
rv = aLoadingPrincipal->GetOriginSuffix(originSuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDocumentURI = aDocumentURI;
|
||||
|
||||
if (aCustomProfileDir) {
|
||||
rv = cacheService->BuildGroupIDForApp(aManifestURI,
|
||||
aAppID, aInBrowser,
|
||||
mGroupID);
|
||||
rv = cacheService->BuildGroupIDForSuffix(aManifestURI, originSuffix, mGroupID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Create only a new offline application cache in the custom profile
|
||||
@ -1274,9 +1272,7 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
mCustomProfileDir = aCustomProfileDir;
|
||||
}
|
||||
else {
|
||||
rv = cacheService->BuildGroupIDForApp(aManifestURI,
|
||||
aAppID, aInBrowser,
|
||||
mGroupID);
|
||||
rv = cacheService->BuildGroupIDForSuffix(aManifestURI, originSuffix, mGroupID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cacheService->GetActiveCache(mGroupID,
|
||||
@ -1293,9 +1289,6 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
&mPinned);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mAppID = aAppID;
|
||||
mInBrowser = aInBrowser;
|
||||
|
||||
mState = STATE_INITIALIZED;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1303,8 +1296,6 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -1324,9 +1315,11 @@ nsOfflineCacheUpdate::InitForUpdateCheck(nsIURI *aManifestURI,
|
||||
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cacheService->BuildGroupIDForApp(aManifestURI,
|
||||
aAppID, aInBrowser,
|
||||
mGroupID);
|
||||
nsAutoCString originSuffix;
|
||||
rv = aLoadingPrincipal->GetOriginSuffix(originSuffix);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cacheService->BuildGroupIDForSuffix(aManifestURI, originSuffix, mGroupID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cacheService->GetActiveCache(mGroupID,
|
||||
@ -1710,7 +1703,7 @@ nsOfflineCacheUpdate::ManifestCheckCompleted(nsresult aStatus,
|
||||
// Leave aDocument argument null. Only glues and children keep
|
||||
// document instances.
|
||||
newUpdate->Init(mManifestURI, mDocumentURI, mLoadingPrincipal, nullptr,
|
||||
mCustomProfileDir, mAppID, mInBrowser);
|
||||
mCustomProfileDir);
|
||||
|
||||
// In a rare case the manifest will not be modified on the next refetch
|
||||
// transfer all master document URIs to the new update to ensure that
|
||||
|
@ -281,9 +281,6 @@ private:
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIFile> mCustomProfileDir;
|
||||
|
||||
uint32_t mAppID;
|
||||
bool mInBrowser;
|
||||
|
||||
nsCOMPtr<nsIObserver> mUpdateAvailableObserver;
|
||||
|
||||
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
||||
@ -335,8 +332,7 @@ public:
|
||||
|
||||
nsresult ScheduleUpdate(nsOfflineCacheUpdate *aUpdate);
|
||||
nsresult FindUpdate(nsIURI *aManifestURI,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsACString const &aOriginSuffix,
|
||||
nsIFile *aCustomProfileDir,
|
||||
nsOfflineCacheUpdate **aUpdate);
|
||||
|
||||
@ -346,8 +342,6 @@ public:
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIDOMWindow* aWindow,
|
||||
nsIFile* aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIOfflineCacheUpdate **aUpdate);
|
||||
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) override;
|
||||
|
@ -85,38 +85,6 @@ PRLogModuleInfo *gOfflineCacheUpdateLog;
|
||||
#undef LOG_ENABLED
|
||||
#define LOG_ENABLED() MOZ_LOG_TEST(gOfflineCacheUpdateLog, mozilla::LogLevel::Debug)
|
||||
|
||||
namespace {
|
||||
|
||||
nsresult
|
||||
GetAppIDAndInBrowserFromWindow(nsIDOMWindow *aWindow,
|
||||
uint32_t *aAppId,
|
||||
bool *aInBrowser)
|
||||
{
|
||||
*aAppId = NECKO_NO_APP_ID;
|
||||
*aInBrowser = false;
|
||||
|
||||
if (!aWindow) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aWindow);
|
||||
if (!loadContext) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = loadContext->GetAppId(aAppId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = loadContext->GetIsInBrowserElement(aInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsOfflineCachePendingUpdate
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -216,15 +184,9 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
|
||||
// Only schedule the update if the document loaded successfully
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
// Get extended origin attributes
|
||||
uint32_t appId;
|
||||
bool isInBrowserElement;
|
||||
nsresult rv = GetAppIDAndInBrowserFromWindow(window, &appId, &isInBrowserElement);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIOfflineCacheUpdate> update;
|
||||
mService->Schedule(mManifestURI, mDocumentURI, mLoadingPrincipal, updateDoc, window,
|
||||
nullptr, appId, isInBrowserElement, getter_AddRefs(update));
|
||||
nullptr, getter_AddRefs(update));
|
||||
if (mDidReleaseThis) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -483,8 +445,7 @@ nsOfflineCacheUpdateService::GetUpdate(uint32_t aIndex,
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdateService::FindUpdate(nsIURI *aManifestURI,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsACString const &aOriginSuffix,
|
||||
nsIFile *aCustomProfileDir,
|
||||
nsOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
@ -495,9 +456,7 @@ nsOfflineCacheUpdateService::FindUpdate(nsIURI *aManifestURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString groupID;
|
||||
rv = cacheService->BuildGroupIDForApp(aManifestURI,
|
||||
aAppID, aInBrowser,
|
||||
groupID);
|
||||
rv = cacheService->BuildGroupIDForSuffix(aManifestURI, aOriginSuffix, groupID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RefPtr<nsOfflineCacheUpdate> update;
|
||||
@ -529,8 +488,6 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIDOMWindow* aWindow,
|
||||
nsIFile* aCustomProfileDir,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
nsCOMPtr<nsIOfflineCacheUpdate> update;
|
||||
@ -552,7 +509,7 @@ nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
|
||||
}
|
||||
|
||||
rv = update->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, aDocument,
|
||||
aCustomProfileDir, aAppID, aInBrowser);
|
||||
aCustomProfileDir);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->Schedule();
|
||||
@ -570,32 +527,23 @@ nsOfflineCacheUpdateService::ScheduleUpdate(nsIURI *aManifestURI,
|
||||
nsIDOMWindow *aWindow,
|
||||
nsIOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
// Get extended origin attributes
|
||||
uint32_t appId;
|
||||
bool isInBrowser;
|
||||
nsresult rv = GetAppIDAndInBrowserFromWindow(aWindow, &appId, &isInBrowser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr, aWindow,
|
||||
nullptr, appId, isInBrowser, aUpdate);
|
||||
nullptr, aUpdate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateService::ScheduleAppUpdate(nsIURI *aManifestURI,
|
||||
nsIURI *aDocumentURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID, bool aInBrowser,
|
||||
nsIFile *aProfileDir,
|
||||
nsIOfflineCacheUpdate **aUpdate)
|
||||
{
|
||||
return Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr, nullptr,
|
||||
aProfileDir, aAppID, aInBrowser, aUpdate);
|
||||
aProfileDir, aUpdate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOfflineCacheUpdateService::CheckForUpdate(nsIURI *aManifestURI,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
uint32_t aAppID,
|
||||
bool aInBrowser,
|
||||
nsIObserver *aObserver)
|
||||
{
|
||||
if (GeckoProcessType_Default != XRE_GetProcessType()) {
|
||||
@ -607,7 +555,7 @@ NS_IMETHODIMP nsOfflineCacheUpdateService::CheckForUpdate(nsIURI *aManifestURI,
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = update->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aAppID, aInBrowser, aObserver);
|
||||
rv = update->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aObserver);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = update->Schedule();
|
||||
|
Loading…
Reference in New Issue
Block a user