michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsOfflineCacheUpdateGlue_h michael@0: #define nsOfflineCacheUpdateGlue_h michael@0: michael@0: #include "nsIOfflineCacheUpdate.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: #include "nsWeakReference.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsOfflineCacheUpdate; michael@0: michael@0: namespace mozilla { michael@0: namespace docshell { michael@0: michael@0: // Like FORWARD_SAFE except methods: michael@0: // Schedule michael@0: // Init michael@0: #define NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(_to) \ michael@0: NS_IMETHOD GetStatus(uint16_t *aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); } \ michael@0: NS_IMETHOD GetPartial(bool *aPartial) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); } \ michael@0: NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); } \ michael@0: NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \ michael@0: NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \ michael@0: NS_IMETHOD GetSucceeded(bool *aSucceeded) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \ michael@0: NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI); } \ michael@0: NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aAppID, aInBrowser, aObserver); } \ michael@0: NS_IMETHOD AddDynamicURI(nsIURI *aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \ michael@0: NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \ michael@0: NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \ michael@0: NS_IMETHOD GetByteProgress(uint64_t * _result) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetByteProgress(_result); } \ michael@0: NS_IMETHOD Cancel() { return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); } michael@0: michael@0: class OfflineCacheUpdateGlue MOZ_FINAL : public nsSupportsWeakReference michael@0: , public nsIOfflineCacheUpdate michael@0: , public nsIOfflineCacheUpdateObserver michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: private: michael@0: nsIOfflineCacheUpdate* EnsureUpdate(); michael@0: michael@0: public: michael@0: NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate()) michael@0: NS_IMETHOD Schedule(void); michael@0: NS_IMETHOD Init(nsIURI *aManifestURI, michael@0: nsIURI *aDocumentURI, michael@0: nsIDOMDocument *aDocument, michael@0: nsIFile *aCustomProfileDir, michael@0: uint32_t aAppID, michael@0: bool aInBrowser); michael@0: michael@0: NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER michael@0: michael@0: OfflineCacheUpdateGlue(); michael@0: ~OfflineCacheUpdateGlue(); michael@0: michael@0: void SetDocument(nsIDOMDocument *aDocument); michael@0: michael@0: private: michael@0: nsRefPtr mUpdate; michael@0: michael@0: /* Document that requested this update */ michael@0: nsCOMPtr mDocument; michael@0: nsCOMPtr mDocumentURI; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif