1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsOfflineCacheUpdateGlue_h
7 #define nsOfflineCacheUpdateGlue_h
9 #include "nsIOfflineCacheUpdate.h"
12 #include "nsAutoPtr.h"
14 #include "nsWeakReference.h"
15 #include "mozilla/Attributes.h"
17 class nsOfflineCacheUpdate
;
22 // Like FORWARD_SAFE except methods:
25 #define NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(_to) \
26 NS_IMETHOD GetStatus(uint16_t *aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); } \
27 NS_IMETHOD GetPartial(bool *aPartial) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); } \
28 NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); } \
29 NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \
30 NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \
31 NS_IMETHOD GetSucceeded(bool *aSucceeded) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \
32 NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI); } \
33 NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aAppID, aInBrowser, aObserver); } \
34 NS_IMETHOD AddDynamicURI(nsIURI *aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \
35 NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \
36 NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \
37 NS_IMETHOD GetByteProgress(uint64_t * _result) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetByteProgress(_result); } \
38 NS_IMETHOD Cancel() { return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); }
40 class OfflineCacheUpdateGlue MOZ_FINAL
: public nsSupportsWeakReference
41 , public nsIOfflineCacheUpdate
42 , public nsIOfflineCacheUpdateObserver
48 nsIOfflineCacheUpdate
* EnsureUpdate();
51 NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
52 NS_IMETHOD
Schedule(void);
53 NS_IMETHOD
Init(nsIURI
*aManifestURI
,
55 nsIDOMDocument
*aDocument
,
56 nsIFile
*aCustomProfileDir
,
60 NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
62 OfflineCacheUpdateGlue();
64 void SetDocument(nsIDOMDocument
*aDocument
);
67 ~OfflineCacheUpdateGlue();
69 nsRefPtr
<nsOfflineCacheUpdate
> mUpdate
;
72 /* Document that requested this update */
73 nsCOMPtr
<nsIDOMDocument
> mDocument
;
74 nsCOMPtr
<nsIURI
> mDocumentURI
;