1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Mozilla Corporation
19 : * Portions created by the Initial Developer are Copyright (C) 2010
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Honza Bambas <honzab@firemni.cz>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef nsOfflineCacheUpdateGlue_h
40 : #define nsOfflineCacheUpdateGlue_h
41 :
42 : #include "nsIOfflineCacheUpdate.h"
43 :
44 : #include "nsCOMPtr.h"
45 : #include "nsAutoPtr.h"
46 : #include "nsString.h"
47 : #include "nsWeakReference.h"
48 :
49 : class nsOfflineCacheUpdate;
50 :
51 : namespace mozilla {
52 : namespace docshell {
53 :
54 : // Like FORWARD_SAFE except methods:
55 : // Schedule
56 : // Init
57 : #define NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(_to) \
58 : NS_SCRIPTABLE NS_IMETHOD GetStatus(PRUint16 *aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); } \
59 : NS_SCRIPTABLE NS_IMETHOD GetPartial(bool *aPartial) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); } \
60 : NS_SCRIPTABLE NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); } \
61 : NS_SCRIPTABLE NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \
62 : NS_SCRIPTABLE NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \
63 : NS_SCRIPTABLE NS_IMETHOD GetSucceeded(bool *aSucceeded) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \
64 : NS_SCRIPTABLE NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI); } \
65 : NS_SCRIPTABLE NS_IMETHOD AddDynamicURI(nsIURI *aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \
66 : NS_SCRIPTABLE NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \
67 : NS_SCRIPTABLE NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); }
68 :
69 : class OfflineCacheUpdateGlue : public nsSupportsWeakReference
70 : , public nsIOfflineCacheUpdate
71 : , public nsIOfflineCacheUpdateObserver
72 : {
73 : public:
74 : NS_DECL_ISUPPORTS
75 :
76 : private:
77 : nsIOfflineCacheUpdate* EnsureUpdate();
78 :
79 : public:
80 0 : NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
81 : NS_SCRIPTABLE NS_IMETHOD Schedule(void);
82 : NS_SCRIPTABLE NS_IMETHOD Init(nsIURI *aManifestURI,
83 : nsIURI *aDocumentURI,
84 : nsIDOMDocument *aDocument);
85 :
86 : NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
87 :
88 : OfflineCacheUpdateGlue();
89 : ~OfflineCacheUpdateGlue();
90 :
91 : void SetDocument(nsIDOMDocument *aDocument);
92 :
93 : private:
94 : nsRefPtr<nsOfflineCacheUpdate> mUpdate;
95 :
96 : /* Document that requested this update */
97 : nsCOMPtr<nsIDOMDocument> mDocument;
98 : nsCOMPtr<nsIURI> mDocumentURI;
99 : };
100 :
101 : }
102 : }
103 :
104 : #endif
|