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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsWeakReference_h__
8 #define nsWeakReference_h__
10 // nsWeakReference.h
12 // See mfbt/WeakPtr.h for a more typesafe C++ implementation of weak references
14 #include "nsIWeakReferenceUtils.h"
16 class nsWeakReference;
18 // Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration
19 // controls member method visibility.
20 #undef IMETHOD_VISIBILITY
21 #define IMETHOD_VISIBILITY NS_COM_GLUE
23 class NS_COM_GLUE nsSupportsWeakReference : public nsISupportsWeakReference
24 {
25 public:
26 nsSupportsWeakReference()
27 : mProxy(0)
28 {
29 // nothing else to do here
30 }
32 NS_DECL_NSISUPPORTSWEAKREFERENCE
34 protected:
35 inline ~nsSupportsWeakReference();
37 private:
38 friend class nsWeakReference;
40 void
41 NoticeProxyDestruction()
42 // ...called (only) by an |nsWeakReference| from _its_ dtor.
43 {
44 mProxy = 0;
45 }
47 nsWeakReference* mProxy;
49 protected:
51 void ClearWeakReferences();
52 bool HasWeakReferences() const {return mProxy != 0;}
53 };
55 #undef IMETHOD_VISIBILITY
56 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
58 inline
59 nsSupportsWeakReference::~nsSupportsWeakReference()
60 {
61 ClearWeakReferences();
62 }
64 #endif