2010-04-02 11:38:25 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07: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/. */
|
2010-04-02 11:38:25 -07:00
|
|
|
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "nsComponentManager.h"
|
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsIDirectoryService.h"
|
2011-06-30 01:41:54 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-06-28 16:26:57 -07:00
|
|
|
#include "nsIAccessibilityService.h"
|
2011-06-30 01:41:54 -07:00
|
|
|
#endif
|
2010-04-02 11:38:25 -07:00
|
|
|
#include "nsIChromeRegistry.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsObserverService.h"
|
|
|
|
#include "nsXPCOMPrivate.h"
|
2010-05-14 02:24:41 -07:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
#include "nsIToolkitChromeRegistry.h"
|
|
|
|
#include "nsIXULOverlayProvider.h"
|
2010-07-13 18:00:33 -07:00
|
|
|
#include "IHistory.h"
|
2011-01-28 09:15:37 -08:00
|
|
|
#include "nsIXPConnect.h"
|
2010-04-02 11:38:25 -07:00
|
|
|
|
2010-07-13 18:00:33 -07:00
|
|
|
using namespace mozilla;
|
2010-04-02 11:38:25 -07:00
|
|
|
using namespace mozilla::services;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define a global variable and a getter for every service in ServiceList.
|
|
|
|
* eg. gIOService and GetIOService()
|
|
|
|
*/
|
|
|
|
#define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) \
|
2012-07-30 07:20:58 -07:00
|
|
|
static TYPE* g##NAME = nullptr; \
|
2010-04-02 11:38:25 -07:00
|
|
|
\
|
2012-01-04 23:04:48 -08:00
|
|
|
already_AddRefed<TYPE> \
|
2010-04-02 11:38:25 -07:00
|
|
|
mozilla::services::Get##NAME() \
|
|
|
|
{ \
|
|
|
|
if (!g##NAME) { \
|
|
|
|
nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID); \
|
|
|
|
g##NAME = os.forget().get(); \
|
|
|
|
} \
|
2013-04-22 04:15:59 -07:00
|
|
|
nsRefPtr<TYPE> ret = g##NAME; \
|
|
|
|
return ret.forget(); \
|
2012-01-04 23:04:48 -08:00
|
|
|
} \
|
|
|
|
NS_EXPORT_(already_AddRefed<TYPE>) \
|
|
|
|
mozilla::services::_external_Get##NAME() \
|
|
|
|
{ \
|
|
|
|
return Get##NAME(); \
|
2010-04-02 11:38:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "ServiceList.h"
|
|
|
|
#undef MOZ_SERVICE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears service cache, sets gXPCOMShuttingDown
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
mozilla::services::Shutdown()
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
gXPCOMShuttingDown = true;
|
2010-04-02 11:38:25 -07:00
|
|
|
#define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) NS_IF_RELEASE(g##NAME);
|
|
|
|
#include "ServiceList.h"
|
|
|
|
#undef MOZ_SERVICE
|
|
|
|
}
|