Bumping manifests a=b2g-bump
[gecko.git] / uriloader / prefetch / OfflineCacheUpdateGlue.h
blobc275a647d64744648bb592d4d2b186541b13b606
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"
11 #include "nsCOMPtr.h"
12 #include "nsAutoPtr.h"
13 #include "nsString.h"
14 #include "nsWeakReference.h"
15 #include "mozilla/Attributes.h"
17 class nsOfflineCacheUpdate;
19 namespace mozilla {
20 namespace docshell {
22 // Like FORWARD_SAFE except methods:
23 // Schedule
24 // Init
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
44 public:
45 NS_DECL_ISUPPORTS
47 private:
48 nsIOfflineCacheUpdate* EnsureUpdate();
50 public:
51 NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
52 NS_IMETHOD Schedule(void);
53 NS_IMETHOD Init(nsIURI *aManifestURI,
54 nsIURI *aDocumentURI,
55 nsIDOMDocument *aDocument,
56 nsIFile *aCustomProfileDir,
57 uint32_t aAppID,
58 bool aInBrowser);
60 NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
62 OfflineCacheUpdateGlue();
64 void SetDocument(nsIDOMDocument *aDocument);
66 private:
67 ~OfflineCacheUpdateGlue();
69 nsRefPtr<nsOfflineCacheUpdate> mUpdate;
70 bool mCoalesced;
72 /* Document that requested this update */
73 nsCOMPtr<nsIDOMDocument> mDocument;
74 nsCOMPtr<nsIURI> mDocumentURI;
80 #endif