Bug 1475065 part 10. Remove nsIDOMOfflineResourceList::SwapCache. r=mystor
--- a/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
+++ b/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
@@ -7,15 +7,9 @@
[uuid(6044702d-e4a9-420c-b711-558b7d6a3b9f)]
interface nsIDOMOfflineResourceList : nsISupports
{
/**
* Get the list of dynamically-managed entries.
*/
readonly attribute nsISupports mozItems;
-
- /**
- * Swap in the newest version of the application cache, or disassociate
- * from the cache if the cache group is obsolete.
- */
- void swapCache();
};
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -553,62 +553,72 @@ nsDOMOfflineResourceList::Update(ErrorRe
rv = updateService->ScheduleUpdate(mManifestURI, mDocumentURI, mLoadingPrincipal,
window, getter_AddRefs(update));
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;
}
}
-NS_IMETHODIMP
-nsDOMOfflineResourceList::SwapCache()
+void
+nsDOMOfflineResourceList::SwapCache(ErrorResult& aRv)
{
nsresult rv = Init();
- NS_ENSURE_SUCCESS(rv, rv);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ aRv.Throw(rv);
+ return;
+ }
if (!nsContentUtils::OfflineAppAllowed(mDocumentURI)) {
- return NS_ERROR_DOM_SECURITY_ERR;
+ aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
+ return;
}
nsCOMPtr<nsIApplicationCache> currentAppCache = GetDocumentAppCache();
if (!currentAppCache) {
- return NS_ERROR_DOM_INVALID_STATE_ERR;
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return;
}
// Check the current and potentially newly available cache are not identical.
if (mAvailableApplicationCache == currentAppCache) {
- return NS_ERROR_DOM_INVALID_STATE_ERR;
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return;
}
if (mAvailableApplicationCache) {
nsCString currClientId, availClientId;
currentAppCache->GetClientID(currClientId);
mAvailableApplicationCache->GetClientID(availClientId);
- if (availClientId == currClientId)
- return NS_ERROR_DOM_INVALID_STATE_ERR;
+ if (availClientId == currClientId) {
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return;
+ }
} else if (mStatus != OfflineResourceList_Binding::OBSOLETE) {
- return NS_ERROR_DOM_INVALID_STATE_ERR;
+ aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return;
}
ClearCachedKeys();
nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer =
GetDocumentAppCacheContainer();
// In the case of an obsolete cache group, newAppCache might be null.
// We will disassociate from the cache in that case.
if (appCacheContainer) {
rv = appCacheContainer->SetApplicationCache(mAvailableApplicationCache);
- NS_ENSURE_SUCCESS(rv, rv);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ aRv.Throw(rv);
+ return;
+ }
}
mAvailableApplicationCache = nullptr;
mStatus = OfflineResourceList_Binding::IDLE;
-
- return NS_OK;
}
void
nsDOMOfflineResourceList::FirePendingEvents()
{
for (int32_t i = 0; i < mPendingEvents.Count(); ++i) {
RefPtr<Event> event = mPendingEvents[i];
DispatchEvent(*event);
--- a/dom/offline/nsDOMOfflineResourceList.h
+++ b/dom/offline/nsDOMOfflineResourceList.h
@@ -67,20 +67,17 @@ public:
}
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
uint16_t GetStatus(ErrorResult& aRv);
void Update(ErrorResult& aRv);
- void SwapCache(ErrorResult& aRv)
- {
- aRv = SwapCache();
- }
+ void SwapCache(ErrorResult& aRv);
IMPL_EVENT_HANDLER(checking)
IMPL_EVENT_HANDLER(error)
IMPL_EVENT_HANDLER(noupdate)
IMPL_EVENT_HANDLER(downloading)
IMPL_EVENT_HANDLER(progress)
IMPL_EVENT_HANDLER(cached)
IMPL_EVENT_HANDLER(updateready)