LCOV - code coverage report
Current view: directory - xpcom/glue - nsComponentManagerUtils.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 97 70 72.2 %
Date: 2012-06-02 Functions: 15 12 80.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsXPCOM_h__
      39                 : #include "nsXPCOM.h"
      40                 : #endif
      41                 : 
      42                 : #ifndef nsCOMPtr_h__
      43                 : #include "nsCOMPtr.h"
      44                 : #endif
      45                 : 
      46                 : #include "nsComponentManagerUtils.h"
      47                 : #include "nsServiceManagerUtils.h"
      48                 : 
      49                 : #include "nsIComponentManager.h"
      50                 : 
      51                 : #ifndef MOZILLA_INTERNAL_API
      52                 : 
      53                 : nsresult
      54            1815 : CallGetService(const nsCID &aCID, const nsIID &aIID, void **aResult)
      55                 : {
      56            3630 :     nsCOMPtr<nsIServiceManager> servMgr;
      57            1815 :     nsresult status = NS_GetServiceManager(getter_AddRefs(servMgr));
      58            1815 :     if (servMgr)
      59            1815 :         status = servMgr->GetService(aCID, aIID, aResult);
      60            1815 :     return status;
      61                 : }
      62                 : 
      63                 : nsresult
      64          176040 : CallGetService(const char *aContractID, const nsIID &aIID, void **aResult)
      65                 : {
      66          352080 :     nsCOMPtr<nsIServiceManager> servMgr;
      67          176040 :     nsresult status = NS_GetServiceManager(getter_AddRefs(servMgr));
      68          176040 :     if (servMgr)
      69          176040 :         status = servMgr->GetServiceByContractID(aContractID, aIID, aResult);
      70          176040 :     return status;
      71                 : }
      72                 : 
      73                 : #else
      74                 : 
      75                 : #include "nsComponentManager.h"
      76                 : 
      77                 : nsresult
      78                 : CallGetService(const nsCID &aCID, const nsIID &aIID, void **aResult)
      79                 : {
      80                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
      81                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
      82                 : 
      83                 :     return compMgr->nsComponentManagerImpl::GetService(aCID, aIID, aResult);
      84                 : }
      85                 : 
      86                 : nsresult
      87                 : CallGetService(const char *aContractID, const nsIID &aIID, void **aResult)
      88                 : {
      89                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
      90                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
      91                 : 
      92                 :     return compMgr->
      93                 :         nsComponentManagerImpl::GetServiceByContractID(aContractID,
      94                 :                                                        aIID, aResult);
      95                 : }
      96                 : 
      97                 : #endif
      98                 : 
      99                 : #ifndef MOZILLA_INTERNAL_API
     100                 : 
     101                 : nsresult
     102               4 : CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
     103                 :                    const nsIID &aIID, void **aResult)
     104                 : {
     105               8 :     nsCOMPtr<nsIComponentManager> compMgr;
     106               4 :     nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
     107               4 :     if (compMgr)
     108               4 :         status = compMgr->CreateInstance(aCID, aDelegate, aIID, aResult);
     109               4 :     return status;
     110                 : }
     111                 : 
     112                 : nsresult
     113              44 : CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
     114                 :                    const nsIID &aIID, void **aResult)
     115                 : {
     116              88 :     nsCOMPtr<nsIComponentManager> compMgr;
     117              44 :     nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
     118              44 :     if (compMgr)
     119              43 :         status = compMgr->CreateInstanceByContractID(aContractID, aDelegate,
     120              43 :                                                      aIID, aResult);
     121              44 :     return status;
     122                 : }
     123                 : 
     124                 : nsresult
     125               1 : CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
     126                 : {
     127               2 :     nsCOMPtr<nsIComponentManager> compMgr;
     128               1 :     nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
     129               1 :     if (compMgr)
     130               1 :         status = compMgr->GetClassObject(aCID, aIID, aResult);
     131               1 :     return status;
     132                 : }
     133                 : 
     134                 : nsresult
     135               0 : CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
     136                 : {
     137               0 :     nsCOMPtr<nsIComponentManager> compMgr;
     138               0 :     nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
     139               0 :     if (compMgr)
     140               0 :         status = compMgr->GetClassObjectByContractID(aContractID, aIID,
     141               0 :                                                      aResult);
     142               0 :     return status;
     143                 : }
     144                 : 
     145                 : #else
     146                 : 
     147                 : #include "nsComponentManager.h"
     148                 : 
     149                 : nsresult
     150                 : CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
     151                 :                    const nsIID &aIID, void **aResult)
     152                 : {
     153                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
     154                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
     155                 : 
     156                 :     return compMgr->
     157                 :         nsComponentManagerImpl::CreateInstance(aCID, aDelegate, aIID, aResult);
     158                 : }
     159                 : 
     160                 : nsresult
     161                 : CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
     162                 :                    const nsIID &aIID, void **aResult)
     163                 : {
     164                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
     165                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
     166                 : 
     167                 :     return compMgr->
     168                 :         nsComponentManagerImpl::CreateInstanceByContractID(aContractID,
     169                 :                                                            aDelegate, aIID,
     170                 :                                                            aResult);
     171                 : }
     172                 : 
     173                 : nsresult
     174                 : CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
     175                 : {
     176                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
     177                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
     178                 : 
     179                 :     return compMgr->
     180                 :         nsComponentManagerImpl::GetClassObject(aCID, aIID, aResult);
     181                 : }
     182                 : 
     183                 : nsresult
     184                 : CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
     185                 : {
     186                 :     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
     187                 :     NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
     188                 : 
     189                 :     return compMgr->
     190                 :         nsComponentManagerImpl::GetClassObjectByContractID(aContractID, aIID,
     191                 :                                                            aResult);
     192                 : }
     193                 : 
     194                 : #endif
     195                 : 
     196                 : nsresult
     197               4 : nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     198                 : {
     199               4 :     nsresult status = CallCreateInstance(mCID, mOuter, aIID, aInstancePtr);
     200               4 :     if ( NS_FAILED(status) )
     201               0 :         *aInstancePtr = 0;
     202               4 :     if ( mErrorPtr )
     203               4 :         *mErrorPtr = status;
     204               4 :     return status;
     205                 : }
     206                 : 
     207                 : nsresult
     208              43 : nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     209                 : {
     210              43 :     nsresult status = CallCreateInstance(mContractID, mOuter, aIID, aInstancePtr);
     211              43 :     if (NS_FAILED(status))
     212               0 :         *aInstancePtr = 0;
     213              43 :     if ( mErrorPtr )
     214              39 :         *mErrorPtr = status;
     215              43 :     return status;
     216                 : }
     217                 : 
     218                 : nsresult
     219               0 : nsCreateInstanceFromFactory::operator()( const nsIID& aIID, void** aInstancePtr ) const
     220                 : {
     221               0 :     nsresult status = mFactory->CreateInstance(mOuter, aIID, aInstancePtr);
     222               0 :     if ( NS_FAILED(status) )
     223               0 :         *aInstancePtr = 0;
     224               0 :     if ( mErrorPtr )
     225               0 :         *mErrorPtr = status;
     226               0 :     return status;
     227                 : }
     228                 : 
     229                 : 
     230                 : nsresult
     231               1 : nsGetClassObjectByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     232                 : {
     233               1 :     nsresult status = CallGetClassObject(mCID, aIID, aInstancePtr);
     234               1 :     if ( NS_FAILED(status) )
     235               0 :         *aInstancePtr = 0;
     236               1 :     if ( mErrorPtr )
     237               1 :         *mErrorPtr = status;
     238               1 :     return status;
     239                 : }
     240                 : 
     241                 : nsresult
     242               0 : nsGetClassObjectByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     243                 : {
     244               0 :     nsresult status = CallGetClassObject(mContractID, aIID, aInstancePtr);
     245               0 :     if ( NS_FAILED(status) )
     246               0 :         *aInstancePtr = 0;
     247               0 :     if ( mErrorPtr )
     248               0 :         *mErrorPtr = status;
     249               0 :     return status;
     250                 : }
     251                 : 
     252                 : 
     253                 : nsresult
     254            1813 : nsGetServiceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     255                 : {
     256            1813 :     nsresult status = CallGetService(mCID, aIID, aInstancePtr);
     257            1813 :     if ( NS_FAILED(status) )
     258               0 :         *aInstancePtr = 0;
     259                 : 
     260            1813 :     return status;
     261                 : }
     262                 : 
     263                 : nsresult
     264               2 : nsGetServiceByCIDWithError::operator()( const nsIID& aIID, void** aInstancePtr ) const
     265                 : {
     266               2 :     nsresult status = CallGetService(mCID, aIID, aInstancePtr);
     267               2 :     if ( NS_FAILED(status) )
     268               0 :         *aInstancePtr = 0;
     269                 : 
     270               2 :     if ( mErrorPtr )
     271               2 :         *mErrorPtr = status;
     272               2 :     return status;
     273                 : }
     274                 : 
     275                 : nsresult
     276          170857 : nsGetServiceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
     277                 : {
     278          170857 :     nsresult status = CallGetService(mContractID, aIID, aInstancePtr);
     279          170857 :     if ( NS_FAILED(status) )
     280            8073 :         *aInstancePtr = 0;
     281                 :     
     282          170857 :     return status;
     283                 : }
     284                 : 
     285                 : nsresult
     286            5183 : nsGetServiceByContractIDWithError::operator()( const nsIID& aIID, void** aInstancePtr ) const
     287                 : {
     288            5183 :     nsresult status = CallGetService(mContractID, aIID, aInstancePtr);
     289            5183 :     if ( NS_FAILED(status) )
     290               0 :         *aInstancePtr = 0;
     291                 :     
     292            5183 :     if ( mErrorPtr )
     293            5183 :         *mErrorPtr = status;
     294            5183 :     return status;
     295                 : }

Generated by: LCOV version 1.7