xpcom/glue/nsIInterfaceRequestorUtils.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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: IDL; tab-width: 4; 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 __nsInterfaceRequestorUtils_h
     8 #define __nsInterfaceRequestorUtils_h
    10 #include "nsCOMPtr.h"
    12 // a type-safe shortcut for calling the |GetInterface()| member function
    13 // T must inherit from nsIInterfaceRequestor, but the cast may be ambiguous.
    14 template <class T, class DestinationType>
    15 inline
    16 nsresult
    17 CallGetInterface( T* aSource, DestinationType** aDestination )
    18   {
    19     NS_PRECONDITION(aSource, "null parameter");
    20     NS_PRECONDITION(aDestination, "null parameter");
    22     return aSource->GetInterface(NS_GET_TEMPLATE_IID(DestinationType),
    23                                  reinterpret_cast<void**>(aDestination));
    24   }
    26 class NS_COM_GLUE nsGetInterface : public nsCOMPtr_helper
    27   {
    28     public:
    29       nsGetInterface( nsISupports* aSource, nsresult* error )
    30           : mSource(aSource),
    31             mErrorPtr(error)
    32         {
    33           // nothing else to do here
    34         }
    36       virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
    38     private:
    39       nsISupports*          mSource;
    40       nsresult*             mErrorPtr;
    41   };
    43 inline
    44 const nsGetInterface
    45 do_GetInterface( nsISupports* aSource, nsresult* error = 0 )
    46   {
    47     return nsGetInterface(aSource, error);
    48   }
    50 #endif // __nsInterfaceRequestorUtils_h

mercurial