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
|
|
|
|
2014-04-29 08:51:14 -07:00
|
|
|
#include "mozilla/Likely.h"
|
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"
|
2014-04-11 14:39:58 -07:00
|
|
|
#include "inIDOMUtils.h"
|
2014-04-29 10:27:02 -07:00
|
|
|
#include "nsIPermissionManager.h"
|
2014-08-18 18:13:14 -07:00
|
|
|
#include "nsIServiceWorkerManager.h"
|
2014-09-11 06:01:00 -07:00
|
|
|
#include "nsIAsyncShutdown.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) \
|
2014-03-15 12:00:15 -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() \
|
|
|
|
{ \
|
2014-04-29 08:51:14 -07:00
|
|
|
if (MOZ_UNLIKELY(gXPCOMShuttingDown)) { \
|
|
|
|
return nullptr; \
|
|
|
|
} \
|
2010-04-02 11:38:25 -07:00
|
|
|
if (!g##NAME) { \
|
|
|
|
nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID); \
|
2014-04-29 08:59:45 -07:00
|
|
|
os.swap(g##NAME); \
|
2010-04-02 11:38:25 -07:00
|
|
|
} \
|
2014-04-29 08:59:45 -07:00
|
|
|
nsCOMPtr<TYPE> ret = g##NAME; \
|
2013-04-22 04:15:59 -07:00
|
|
|
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
|
|
|
|
*/
|
2014-08-13 11:45:37 -07:00
|
|
|
void
|
2010-04-02 11:38:25 -07:00
|
|
|
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
|
|
|
|
}
|