Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsServiceManagerUtils_h__ |
michael@0 | 7 | #define nsServiceManagerUtils_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIServiceManager.h" |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | |
michael@0 | 12 | inline |
michael@0 | 13 | const nsGetServiceByCID |
michael@0 | 14 | do_GetService(const nsCID& aCID) |
michael@0 | 15 | { |
michael@0 | 16 | return nsGetServiceByCID(aCID); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | inline |
michael@0 | 20 | const nsGetServiceByCIDWithError |
michael@0 | 21 | do_GetService(const nsCID& aCID, nsresult* error) |
michael@0 | 22 | { |
michael@0 | 23 | return nsGetServiceByCIDWithError(aCID, error); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | inline |
michael@0 | 27 | const nsGetServiceByContractID |
michael@0 | 28 | do_GetService(const char* aContractID) |
michael@0 | 29 | { |
michael@0 | 30 | return nsGetServiceByContractID(aContractID); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | inline |
michael@0 | 34 | const nsGetServiceByContractIDWithError |
michael@0 | 35 | do_GetService( const char* aContractID, nsresult* error) |
michael@0 | 36 | { |
michael@0 | 37 | return nsGetServiceByContractIDWithError(aContractID, error); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | class nsGetServiceFromCategory : public nsCOMPtr_helper |
michael@0 | 41 | { |
michael@0 | 42 | public: |
michael@0 | 43 | nsGetServiceFromCategory(const char* aCategory, const char* aEntry, |
michael@0 | 44 | nsresult* aErrorPtr) |
michael@0 | 45 | : mCategory(aCategory), |
michael@0 | 46 | mEntry(aEntry), |
michael@0 | 47 | mErrorPtr(aErrorPtr) |
michael@0 | 48 | { |
michael@0 | 49 | // nothing else to do |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const; |
michael@0 | 53 | protected: |
michael@0 | 54 | const char* mCategory; |
michael@0 | 55 | const char* mEntry; |
michael@0 | 56 | nsresult* mErrorPtr; |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | inline |
michael@0 | 60 | const nsGetServiceFromCategory |
michael@0 | 61 | do_GetServiceFromCategory( const char* category, const char* entry, |
michael@0 | 62 | nsresult* error = 0) |
michael@0 | 63 | { |
michael@0 | 64 | return nsGetServiceFromCategory(category, entry, error); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | NS_COM_GLUE nsresult |
michael@0 | 68 | CallGetService(const nsCID &aClass, const nsIID &aIID, void **aResult); |
michael@0 | 69 | |
michael@0 | 70 | NS_COM_GLUE nsresult |
michael@0 | 71 | CallGetService(const char *aContractID, const nsIID &aIID, void **aResult); |
michael@0 | 72 | |
michael@0 | 73 | // type-safe shortcuts for calling |GetService| |
michael@0 | 74 | template <class DestinationType> |
michael@0 | 75 | inline |
michael@0 | 76 | nsresult |
michael@0 | 77 | CallGetService( const nsCID &aClass, |
michael@0 | 78 | DestinationType** aDestination) |
michael@0 | 79 | { |
michael@0 | 80 | NS_PRECONDITION(aDestination, "null parameter"); |
michael@0 | 81 | |
michael@0 | 82 | return CallGetService(aClass, |
michael@0 | 83 | NS_GET_TEMPLATE_IID(DestinationType), |
michael@0 | 84 | reinterpret_cast<void**>(aDestination)); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | template <class DestinationType> |
michael@0 | 88 | inline |
michael@0 | 89 | nsresult |
michael@0 | 90 | CallGetService( const char *aContractID, |
michael@0 | 91 | DestinationType** aDestination) |
michael@0 | 92 | { |
michael@0 | 93 | NS_PRECONDITION(aContractID, "null parameter"); |
michael@0 | 94 | NS_PRECONDITION(aDestination, "null parameter"); |
michael@0 | 95 | |
michael@0 | 96 | return CallGetService(aContractID, |
michael@0 | 97 | NS_GET_TEMPLATE_IID(DestinationType), |
michael@0 | 98 | reinterpret_cast<void**>(aDestination)); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | #endif |