1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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) 2007
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Dave Camp <dcamp@mozilla.com>
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 nsDOMOfflineResourceList_h___
40 : #define nsDOMOfflineResourceList_h___
41 :
42 : #include "nscore.h"
43 : #include "nsIDOMOfflineResourceList.h"
44 : #include "nsIApplicationCache.h"
45 : #include "nsIApplicationCacheContainer.h"
46 : #include "nsIApplicationCacheService.h"
47 : #include "nsIOfflineCacheUpdate.h"
48 : #include "nsTArray.h"
49 : #include "nsString.h"
50 : #include "nsIURI.h"
51 : #include "nsCOMPtr.h"
52 : #include "nsWeakReference.h"
53 : #include "nsCOMArray.h"
54 : #include "nsIDOMEventListener.h"
55 : #include "nsDOMEvent.h"
56 : #include "nsIObserver.h"
57 : #include "nsIScriptContext.h"
58 : #include "nsCycleCollectionParticipant.h"
59 : #include "nsPIDOMWindow.h"
60 : #include "nsDOMEventTargetHelper.h"
61 :
62 : class nsIDOMWindow;
63 :
64 : class nsDOMOfflineResourceList : public nsDOMEventTargetHelper,
65 : public nsIDOMOfflineResourceList,
66 : public nsIObserver,
67 : public nsIOfflineCacheUpdateObserver,
68 : public nsSupportsWeakReference
69 : {
70 : public:
71 : NS_DECL_ISUPPORTS_INHERITED
72 : NS_DECL_NSIDOMOFFLINERESOURCELIST
73 : NS_DECL_NSIOBSERVER
74 : NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
75 :
76 1464 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
77 : nsDOMEventTargetHelper)
78 :
79 : nsDOMOfflineResourceList(nsIURI* aManifestURI,
80 : nsIURI* aDocumentURI,
81 : nsPIDOMWindow* aWindow);
82 : virtual ~nsDOMOfflineResourceList();
83 :
84 : void FirePendingEvents();
85 : void Disconnect();
86 :
87 : nsresult Init();
88 :
89 : private:
90 : nsresult SendEvent(const nsAString &aEventName);
91 :
92 : nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
93 : nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
94 :
95 : already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
96 : already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
97 :
98 : nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
99 : nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
100 :
101 : nsresult CacheKeys();
102 : void ClearCachedKeys();
103 :
104 : bool mInitialized;
105 :
106 : nsCOMPtr<nsIURI> mManifestURI;
107 : // AsciiSpec of mManifestURI
108 : nsCString mManifestSpec;
109 :
110 : nsCOMPtr<nsIURI> mDocumentURI;
111 : nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
112 : nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
113 : nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
114 : bool mExposeCacheUpdateStatus;
115 : PRUint16 mStatus;
116 :
117 : // The set of dynamic keys for this application cache object.
118 : char **mCachedKeys;
119 : PRUint32 mCachedKeysCount;
120 :
121 : nsRefPtr<nsDOMEventListenerWrapper> mOnCheckingListener;
122 : nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
123 : nsRefPtr<nsDOMEventListenerWrapper> mOnNoUpdateListener;
124 : nsRefPtr<nsDOMEventListenerWrapper> mOnDownloadingListener;
125 : nsRefPtr<nsDOMEventListenerWrapper> mOnProgressListener;
126 : nsRefPtr<nsDOMEventListenerWrapper> mOnCachedListener;
127 : nsRefPtr<nsDOMEventListenerWrapper> mOnUpdateReadyListener;
128 : nsRefPtr<nsDOMEventListenerWrapper> mOnObsoleteListener;
129 :
130 : nsCOMArray<nsIDOMEvent> mPendingEvents;
131 : };
132 :
133 : #endif
|