2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-20 17:12:32 +00:00
|
|
|
|
|
|
|
#ifndef nsOfflineCacheUpdateGlue_h
|
|
|
|
#define nsOfflineCacheUpdateGlue_h
|
|
|
|
|
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsWeakReference.h"
|
2012-06-13 03:53:09 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-10-20 17:12:32 +00:00
|
|
|
|
|
|
|
class nsOfflineCacheUpdate;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2019-01-02 13:05:23 +00:00
|
|
|
namespace dom {
|
|
|
|
class Document;
|
|
|
|
}
|
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
namespace docshell {
|
|
|
|
|
|
|
|
// Like FORWARD_SAFE except methods:
|
|
|
|
// Schedule
|
|
|
|
// Init
|
|
|
|
#define NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(_to) \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetStatus(uint16_t *aStatus) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); \
|
|
|
|
} \
|
|
|
|
NS_IMETHOD GetPartial(bool *aPartial) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); \
|
|
|
|
} \
|
|
|
|
NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); \
|
|
|
|
} \
|
|
|
|
NS_IMETHOD GetUpdateDomain(nsACString &aUpdateDomain) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); \
|
|
|
|
} \
|
|
|
|
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); \
|
2015-10-02 16:13:52 +00:00
|
|
|
} \
|
|
|
|
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); \
|
2016-01-18 19:20:08 +00:00
|
|
|
} \
|
|
|
|
NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, \
|
|
|
|
nsIPrincipal *aLoadingPrincipal, \
|
|
|
|
nsIObserver *aObserver) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER \
|
|
|
|
: _to->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, \
|
|
|
|
aObserver); \
|
2015-03-21 16:28:04 +00:00
|
|
|
} \
|
|
|
|
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); \
|
2018-11-30 10:46:48 +00:00
|
|
|
} \
|
2015-03-27 18:52:19 +00:00
|
|
|
NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) \
|
2010-10-20 17:12:32 +00:00
|
|
|
override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); \
|
2018-11-30 10:46:48 +00:00
|
|
|
} \
|
2010-10-20 17:12:32 +00:00
|
|
|
NS_IMETHOD GetByteProgress(uint64_t *_result) override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->GetByteProgress(_result); \
|
2018-11-30 10:46:48 +00:00
|
|
|
} \
|
2010-10-20 17:12:32 +00:00
|
|
|
NS_IMETHOD Cancel() override { \
|
|
|
|
return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); \
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
class OfflineCacheUpdateGlue final : public nsSupportsWeakReference,
|
|
|
|
public nsIOfflineCacheUpdate,
|
2015-03-21 16:28:04 +00:00
|
|
|
public nsIOfflineCacheUpdateObserver {
|
2010-10-20 17:12:32 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
private:
|
|
|
|
nsIOfflineCacheUpdate *EnsureUpdate();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
|
|
|
|
NS_IMETHOD Schedule(void) override;
|
2015-10-02 16:13:52 +00:00
|
|
|
NS_IMETHOD Init(nsIURI *aManifestURI, nsIURI *aDocumentURI,
|
2019-01-02 13:05:23 +00:00
|
|
|
nsIPrincipal *aLoadingPrincipal,
|
|
|
|
mozilla::dom::Document *aDocument,
|
2016-01-18 19:20:08 +00:00
|
|
|
nsIFile *aCustomProfileDir) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
OfflineCacheUpdateGlue();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
void SetDocument(mozilla::dom::Document *aDocument);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
private:
|
2014-06-23 18:49:09 +00:00
|
|
|
~OfflineCacheUpdateGlue();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsOfflineCacheUpdate> mUpdate;
|
2014-07-16 14:16:30 +00:00
|
|
|
bool mCoalesced;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2010-10-20 17:12:32 +00:00
|
|
|
/* Document that requested this update */
|
2019-01-02 13:05:23 +00:00
|
|
|
RefPtr<mozilla::dom::Document> mDocument;
|
2010-10-20 17:12:32 +00:00
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2015-10-02 16:13:52 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
2010-10-20 17:12:32 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace docshell
|
|
|
|
} // namespace mozilla
|
2010-10-20 17:12:32 +00:00
|
|
|
|
|
|
|
#endif
|