|
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 nsOfflineCacheUpdateChild_h |
|
7 #define nsOfflineCacheUpdateChild_h |
|
8 |
|
9 #include "mozilla/docshell/POfflineCacheUpdateChild.h" |
|
10 #include "nsIOfflineCacheUpdate.h" |
|
11 |
|
12 #include "nsCOMArray.h" |
|
13 #include "nsCOMPtr.h" |
|
14 #include "nsICacheService.h" |
|
15 #include "nsIDOMDocument.h" |
|
16 #include "nsIObserver.h" |
|
17 #include "nsIObserverService.h" |
|
18 #include "nsIURI.h" |
|
19 #include "nsString.h" |
|
20 #include "nsWeakReference.h" |
|
21 |
|
22 namespace mozilla { |
|
23 namespace docshell { |
|
24 |
|
25 class OfflineCacheUpdateChild : public nsIOfflineCacheUpdate |
|
26 , public POfflineCacheUpdateChild |
|
27 { |
|
28 public: |
|
29 NS_DECL_ISUPPORTS |
|
30 NS_DECL_NSIOFFLINECACHEUPDATE |
|
31 |
|
32 virtual bool |
|
33 RecvNotifyStateEvent(const uint32_t& stateEvent, |
|
34 const uint64_t& byteProgress) MOZ_OVERRIDE; |
|
35 |
|
36 virtual bool |
|
37 RecvAssociateDocuments( |
|
38 const nsCString& cacheGroupId, |
|
39 const nsCString& cacheClientId) MOZ_OVERRIDE; |
|
40 |
|
41 virtual bool |
|
42 RecvFinish(const bool& succeeded, |
|
43 const bool& isUpgrade) MOZ_OVERRIDE; |
|
44 |
|
45 OfflineCacheUpdateChild(nsIDOMWindow* aWindow); |
|
46 ~OfflineCacheUpdateChild(); |
|
47 |
|
48 void SetDocument(nsIDOMDocument *aDocument); |
|
49 |
|
50 private: |
|
51 nsresult AssociateDocument(nsIDOMDocument *aDocument, |
|
52 nsIApplicationCache *aApplicationCache); |
|
53 void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers); |
|
54 nsresult Finish(); |
|
55 |
|
56 enum { |
|
57 STATE_UNINITIALIZED, |
|
58 STATE_INITIALIZED, |
|
59 STATE_CHECKING, |
|
60 STATE_DOWNLOADING, |
|
61 STATE_CANCELLED, |
|
62 STATE_FINISHED |
|
63 } mState; |
|
64 |
|
65 bool mIsUpgrade; |
|
66 bool mSucceeded; |
|
67 |
|
68 nsCString mUpdateDomain; |
|
69 nsCOMPtr<nsIURI> mManifestURI; |
|
70 nsCOMPtr<nsIURI> mDocumentURI; |
|
71 |
|
72 nsCOMPtr<nsIObserverService> mObserverService; |
|
73 |
|
74 uint32_t mAppID; |
|
75 bool mInBrowser; |
|
76 |
|
77 /* Clients watching this update for changes */ |
|
78 nsCOMArray<nsIWeakReference> mWeakObservers; |
|
79 nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers; |
|
80 |
|
81 /* Document that requested this update */ |
|
82 nsCOMPtr<nsIDOMDocument> mDocument; |
|
83 |
|
84 /* Keep reference to the window that owns this update to call the |
|
85 parent offline cache update construcor */ |
|
86 nsCOMPtr<nsIDOMWindow> mWindow; |
|
87 |
|
88 uint64_t mByteProgress; |
|
89 }; |
|
90 |
|
91 } |
|
92 } |
|
93 |
|
94 #endif |