Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsWeakReference_h__ |
michael@0 | 8 | #define nsWeakReference_h__ |
michael@0 | 9 | |
michael@0 | 10 | // nsWeakReference.h |
michael@0 | 11 | |
michael@0 | 12 | // See mfbt/WeakPtr.h for a more typesafe C++ implementation of weak references |
michael@0 | 13 | |
michael@0 | 14 | #include "nsIWeakReferenceUtils.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsWeakReference; |
michael@0 | 17 | |
michael@0 | 18 | // Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration |
michael@0 | 19 | // controls member method visibility. |
michael@0 | 20 | #undef IMETHOD_VISIBILITY |
michael@0 | 21 | #define IMETHOD_VISIBILITY NS_COM_GLUE |
michael@0 | 22 | |
michael@0 | 23 | class NS_COM_GLUE nsSupportsWeakReference : public nsISupportsWeakReference |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | nsSupportsWeakReference() |
michael@0 | 27 | : mProxy(0) |
michael@0 | 28 | { |
michael@0 | 29 | // nothing else to do here |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | NS_DECL_NSISUPPORTSWEAKREFERENCE |
michael@0 | 33 | |
michael@0 | 34 | protected: |
michael@0 | 35 | inline ~nsSupportsWeakReference(); |
michael@0 | 36 | |
michael@0 | 37 | private: |
michael@0 | 38 | friend class nsWeakReference; |
michael@0 | 39 | |
michael@0 | 40 | void |
michael@0 | 41 | NoticeProxyDestruction() |
michael@0 | 42 | // ...called (only) by an |nsWeakReference| from _its_ dtor. |
michael@0 | 43 | { |
michael@0 | 44 | mProxy = 0; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | nsWeakReference* mProxy; |
michael@0 | 48 | |
michael@0 | 49 | protected: |
michael@0 | 50 | |
michael@0 | 51 | void ClearWeakReferences(); |
michael@0 | 52 | bool HasWeakReferences() const {return mProxy != 0;} |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | #undef IMETHOD_VISIBILITY |
michael@0 | 56 | #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN |
michael@0 | 57 | |
michael@0 | 58 | inline |
michael@0 | 59 | nsSupportsWeakReference::~nsSupportsWeakReference() |
michael@0 | 60 | { |
michael@0 | 61 | ClearWeakReferences(); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | #endif |