LCOV - code coverage report
Current view: top level - xpcom/base - nsIInterfaceRequestorUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 10 10 100.0 %
Date: 2017-07-14 16:53:18 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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/. */
       6             : 
       7             : #ifndef __nsInterfaceRequestorUtils_h
       8             : #define __nsInterfaceRequestorUtils_h
       9             : 
      10             : #include "nsCOMPtr.h"
      11             : 
      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 nsresult
      16          97 : CallGetInterface(T* aSource, DestinationType** aDestination)
      17             : {
      18          97 :   NS_PRECONDITION(aSource, "null parameter");
      19          97 :   NS_PRECONDITION(aDestination, "null parameter");
      20             : 
      21             :   return aSource->GetInterface(NS_GET_TEMPLATE_IID(DestinationType),
      22          97 :                                reinterpret_cast<void**>(aDestination));
      23             : }
      24             : 
      25             : class MOZ_STACK_CLASS nsGetInterface final : public nsCOMPtr_helper
      26             : {
      27             : public:
      28         676 :   nsGetInterface(nsISupports* aSource, nsresult* aError)
      29         676 :     : mSource(aSource)
      30         676 :     , mErrorPtr(aError)
      31             :   {
      32         676 :   }
      33             : 
      34             :   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const
      35             :     override;
      36             : 
      37             : private:
      38             :   nsISupports* MOZ_NON_OWNING_REF mSource;
      39             :   nsresult* mErrorPtr;
      40             : };
      41             : 
      42             : inline const nsGetInterface
      43         676 : do_GetInterface(nsISupports* aSource, nsresult* aError = 0)
      44             : {
      45         676 :   return nsGetInterface(aSource, aError);
      46             : }
      47             : 
      48             : #endif // __nsInterfaceRequestorUtils_h
      49             : 

Generated by: LCOV version 1.13