xpcom/glue/nsWeakReference.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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

mercurial