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