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