LCOV - code coverage report
Current view: top level - xpcom/components - nsServiceManagerUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 21 21 100.0 %
Date: 2017-07-14 16:53:18 Functions: 24 33 72.7 %
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 nsServiceManagerUtils_h__
       8             : #define nsServiceManagerUtils_h__
       9             : 
      10             : #include "nsIServiceManager.h"
      11             : #include "nsCOMPtr.h"
      12             : 
      13             : inline const nsGetServiceByCID
      14          15 : do_GetService(const nsCID& aCID)
      15             : {
      16          15 :   return nsGetServiceByCID(aCID);
      17             : }
      18             : 
      19             : inline const nsGetServiceByCIDWithError
      20          77 : do_GetService(const nsCID& aCID, nsresult* aError)
      21             : {
      22          77 :   return nsGetServiceByCIDWithError(aCID, aError);
      23             : }
      24             : 
      25             : inline const nsGetServiceByContractID
      26        3701 : do_GetService(const char* aContractID)
      27             : {
      28        3701 :   return nsGetServiceByContractID(aContractID);
      29             : }
      30             : 
      31             : inline const nsGetServiceByContractIDWithError
      32         555 : do_GetService(const char* aContractID, nsresult* aError)
      33             : {
      34         555 :   return nsGetServiceByContractIDWithError(aContractID, aError);
      35             : }
      36             : 
      37             : class MOZ_STACK_CLASS nsGetServiceFromCategory final : public nsCOMPtr_helper
      38             : {
      39             : public:
      40           3 :   nsGetServiceFromCategory(const char* aCategory, const char* aEntry,
      41             :                            nsresult* aErrorPtr)
      42           3 :     : mCategory(aCategory)
      43             :     , mEntry(aEntry)
      44           3 :     , mErrorPtr(aErrorPtr)
      45             :   {
      46           3 :   }
      47             : 
      48             :   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const
      49             :     override;
      50             : protected:
      51             :   const char*                 mCategory;
      52             :   const char*                 mEntry;
      53             :   nsresult*                   mErrorPtr;
      54             : };
      55             : 
      56             : inline const nsGetServiceFromCategory
      57           3 : do_GetServiceFromCategory(const char* aCategory, const char* aEntry,
      58             :                           nsresult* aError = 0)
      59             : {
      60           3 :   return nsGetServiceFromCategory(aCategory, aEntry, aError);
      61             : }
      62             : 
      63             : nsresult CallGetService(const nsCID& aClass, const nsIID& aIID, void** aResult);
      64             : 
      65             : nsresult CallGetService(const char* aContractID, const nsIID& aIID,
      66             :                         void** aResult);
      67             : 
      68             : // type-safe shortcuts for calling |GetService|
      69             : template<class DestinationType>
      70             : inline nsresult
      71          21 : CallGetService(const nsCID& aClass,
      72             :                DestinationType** aDestination)
      73             : {
      74          21 :   NS_PRECONDITION(aDestination, "null parameter");
      75             : 
      76             :   return CallGetService(aClass,
      77             :                         NS_GET_TEMPLATE_IID(DestinationType),
      78          21 :                         reinterpret_cast<void**>(aDestination));
      79             : }
      80             : 
      81             : template<class DestinationType>
      82             : inline nsresult
      83         148 : CallGetService(const char* aContractID,
      84             :                DestinationType** aDestination)
      85             : {
      86         148 :   NS_PRECONDITION(aContractID, "null parameter");
      87         148 :   NS_PRECONDITION(aDestination, "null parameter");
      88             : 
      89             :   return CallGetService(aContractID,
      90             :                         NS_GET_TEMPLATE_IID(DestinationType),
      91         148 :                         reinterpret_cast<void**>(aDestination));
      92             : }
      93             : 
      94             : #endif

Generated by: LCOV version 1.13