Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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/. */
6 #ifndef nsOfflineCacheUpdateChild_h
7 #define nsOfflineCacheUpdateChild_h
9 #include "mozilla/docshell/POfflineCacheUpdateChild.h"
10 #include "nsIOfflineCacheUpdate.h"
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"
22 namespace mozilla {
23 namespace docshell {
25 class OfflineCacheUpdateChild : public nsIOfflineCacheUpdate
26 , public POfflineCacheUpdateChild
27 {
28 public:
29 NS_DECL_ISUPPORTS
30 NS_DECL_NSIOFFLINECACHEUPDATE
32 virtual bool
33 RecvNotifyStateEvent(const uint32_t& stateEvent,
34 const uint64_t& byteProgress) MOZ_OVERRIDE;
36 virtual bool
37 RecvAssociateDocuments(
38 const nsCString& cacheGroupId,
39 const nsCString& cacheClientId) MOZ_OVERRIDE;
41 virtual bool
42 RecvFinish(const bool& succeeded,
43 const bool& isUpgrade) MOZ_OVERRIDE;
45 OfflineCacheUpdateChild(nsIDOMWindow* aWindow);
46 ~OfflineCacheUpdateChild();
48 void SetDocument(nsIDOMDocument *aDocument);
50 private:
51 nsresult AssociateDocument(nsIDOMDocument *aDocument,
52 nsIApplicationCache *aApplicationCache);
53 void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers);
54 nsresult Finish();
56 enum {
57 STATE_UNINITIALIZED,
58 STATE_INITIALIZED,
59 STATE_CHECKING,
60 STATE_DOWNLOADING,
61 STATE_CANCELLED,
62 STATE_FINISHED
63 } mState;
65 bool mIsUpgrade;
66 bool mSucceeded;
68 nsCString mUpdateDomain;
69 nsCOMPtr<nsIURI> mManifestURI;
70 nsCOMPtr<nsIURI> mDocumentURI;
72 nsCOMPtr<nsIObserverService> mObserverService;
74 uint32_t mAppID;
75 bool mInBrowser;
77 /* Clients watching this update for changes */
78 nsCOMArray<nsIWeakReference> mWeakObservers;
79 nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers;
81 /* Document that requested this update */
82 nsCOMPtr<nsIDOMDocument> mDocument;
84 /* Keep reference to the window that owns this update to call the
85 parent offline cache update construcor */
86 nsCOMPtr<nsIDOMWindow> mWindow;
88 uint64_t mByteProgress;
89 };
91 }
92 }
94 #endif