2014-06-30 19:39:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-10-16 07:35:52 +04:00
|
|
|
|
2004-11-25 01:48:45 +03:00
|
|
|
#ifndef nsServiceManagerUtils_h__
|
|
|
|
#define nsServiceManagerUtils_h__
|
2001-10-16 07:35:52 +04:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByCID
|
2004-11-25 01:48:45 +03:00
|
|
|
do_GetService(const nsCID& aCID)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByCID(aCID);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByCIDWithError
|
|
|
|
do_GetService(const nsCID& aCID, nsresult* aError)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByCIDWithError(aCID, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByContractID
|
2004-11-25 01:48:45 +03:00
|
|
|
do_GetService(const char* aContractID)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByContractID(aContractID);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceByContractIDWithError
|
|
|
|
do_GetService(const char* aContractID, nsresult* aError)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceByContractIDWithError(aContractID, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2015-04-20 23:58:15 +03:00
|
|
|
class MOZ_STACK_CLASS nsGetServiceFromCategory final : public nsCOMPtr_helper
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
public:
|
|
|
|
nsGetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aErrorPtr)
|
|
|
|
: mCategory(aCategory)
|
|
|
|
, mEntry(aEntry)
|
|
|
|
, mErrorPtr(aErrorPtr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-15 19:36:10 +03:00
|
|
|
virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2014-06-27 05:35:39 +04:00
|
|
|
protected:
|
|
|
|
const char* mCategory;
|
|
|
|
const char* mEntry;
|
|
|
|
nsresult* mErrorPtr;
|
2001-10-16 07:35:52 +04:00
|
|
|
};
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
inline const nsGetServiceFromCategory
|
|
|
|
do_GetServiceFromCategory(const char* aCategory, const char* aEntry,
|
|
|
|
nsresult* aError = 0)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
return nsGetServiceFromCategory(aCategory, aEntry, aError);
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-08-28 02:47:27 +04:00
|
|
|
nsresult CallGetService(const nsCID& aClass, const nsIID& aIID, void** aResult);
|
2004-11-25 01:48:45 +03:00
|
|
|
|
2014-08-28 02:47:27 +04:00
|
|
|
nsresult CallGetService(const char* aContractID, const nsIID& aIID,
|
|
|
|
void** aResult);
|
2004-11-25 01:48:45 +03:00
|
|
|
|
2001-10-16 07:35:52 +04:00
|
|
|
// type-safe shortcuts for calling |GetService|
|
2014-06-27 05:35:39 +04:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const nsCID& aClass,
|
|
|
|
DestinationType** aDestination)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aClass,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
template<class DestinationType>
|
|
|
|
inline nsresult
|
|
|
|
CallGetService(const char* aContractID,
|
|
|
|
DestinationType** aDestination)
|
2001-10-16 07:35:52 +04:00
|
|
|
{
|
2014-06-27 05:35:39 +04:00
|
|
|
NS_PRECONDITION(aContractID, "null parameter");
|
|
|
|
NS_PRECONDITION(aDestination, "null parameter");
|
|
|
|
|
|
|
|
return CallGetService(aContractID,
|
|
|
|
NS_GET_TEMPLATE_IID(DestinationType),
|
|
|
|
reinterpret_cast<void**>(aDestination));
|
2001-10-16 07:35:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|