/src/mozilla-central/uriloader/prefetch/OfflineCacheUpdateGlue.h
Line | Count | Source (jump to first uncovered line) |
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 | 0 | NS_IMETHOD GetStatus(uint16_t *aStatus) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); } \ |
27 | 0 | NS_IMETHOD GetPartial(bool *aPartial) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); } \ |
28 | 0 | NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); } \ |
29 | 0 | NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \ |
30 | 0 | NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \ |
31 | 0 | NS_IMETHOD GetSucceeded(bool *aSucceeded) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \ |
32 | 0 | 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); } \ |
33 | 0 | NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, nsIPrincipal* aLoadingPrincipal, nsIObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aLoadingPrincipal, aObserver); } \ |
34 | 0 | NS_IMETHOD AddDynamicURI(nsIURI *aURI) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \ |
35 | 0 | NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \ |
36 | 0 | NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) override { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \ |
37 | 0 | NS_IMETHOD GetByteProgress(uint64_t * _result) override { return !_to ? NS_ERROR_NULL_POINTER : _to->GetByteProgress(_result); } \ |
38 | 0 | NS_IMETHOD Cancel() override { return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); } |
39 | | |
40 | | class OfflineCacheUpdateGlue 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) override; |
53 | | NS_IMETHOD Init(nsIURI *aManifestURI, |
54 | | nsIURI *aDocumentURI, |
55 | | nsIPrincipal* aLoadingPrincipal, |
56 | | nsIDocument *aDocument, |
57 | | nsIFile *aCustomProfileDir) override; |
58 | | |
59 | | NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER |
60 | | |
61 | | OfflineCacheUpdateGlue(); |
62 | | |
63 | | void SetDocument(nsIDocument *aDocument); |
64 | | |
65 | | private: |
66 | | ~OfflineCacheUpdateGlue(); |
67 | | |
68 | | RefPtr<nsOfflineCacheUpdate> mUpdate; |
69 | | bool mCoalesced; |
70 | | |
71 | | /* Document that requested this update */ |
72 | | nsCOMPtr<nsIDocument> mDocument; |
73 | | nsCOMPtr<nsIURI> mDocumentURI; |
74 | | nsCOMPtr<nsIPrincipal> mLoadingPrincipal; |
75 | | }; |
76 | | |
77 | | } // namespace docshell |
78 | | } // namespace mozilla |
79 | | |
80 | | #endif |