|
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/. */ |
|
5 |
|
6 #ifndef nsOfflineCacheUpdateGlue_h |
|
7 #define nsOfflineCacheUpdateGlue_h |
|
8 |
|
9 #include "nsIOfflineCacheUpdate.h" |
|
10 |
|
11 #include "nsCOMPtr.h" |
|
12 #include "nsAutoPtr.h" |
|
13 #include "nsString.h" |
|
14 #include "nsWeakReference.h" |
|
15 #include "mozilla/Attributes.h" |
|
16 |
|
17 class nsOfflineCacheUpdate; |
|
18 |
|
19 namespace mozilla { |
|
20 namespace docshell { |
|
21 |
|
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(); } |
|
39 |
|
40 class OfflineCacheUpdateGlue MOZ_FINAL : public nsSupportsWeakReference |
|
41 , public nsIOfflineCacheUpdate |
|
42 , public nsIOfflineCacheUpdateObserver |
|
43 { |
|
44 public: |
|
45 NS_DECL_ISUPPORTS |
|
46 |
|
47 private: |
|
48 nsIOfflineCacheUpdate* EnsureUpdate(); |
|
49 |
|
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); |
|
59 |
|
60 NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER |
|
61 |
|
62 OfflineCacheUpdateGlue(); |
|
63 ~OfflineCacheUpdateGlue(); |
|
64 |
|
65 void SetDocument(nsIDOMDocument *aDocument); |
|
66 |
|
67 private: |
|
68 nsRefPtr<nsOfflineCacheUpdate> mUpdate; |
|
69 |
|
70 /* Document that requested this update */ |
|
71 nsCOMPtr<nsIDOMDocument> mDocument; |
|
72 nsCOMPtr<nsIURI> mDocumentURI; |
|
73 }; |
|
74 |
|
75 } |
|
76 } |
|
77 |
|
78 #endif |