2015-04-09 20:25:05 +03: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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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 22:38:25 +04:00
|
|
|
|
2014-04-29 19:51:14 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2010-04-02 22:38:25 +04:00
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "nsComponentManager.h"
|
2015-04-03 16:52:00 +03:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsObserverService.h"
|
|
|
|
#include "nsXPCOMPrivate.h"
|
2010-04-02 22:38:25 +04:00
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsIDirectoryService.h"
|
|
|
|
#include "nsIChromeRegistry.h"
|
2010-05-14 13:24:41 +04:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
#include "nsIToolkitChromeRegistry.h"
|
|
|
|
#include "nsIXULOverlayProvider.h"
|
2010-07-14 05:00:33 +04:00
|
|
|
#include "IHistory.h"
|
2011-01-28 20:15:37 +03:00
|
|
|
#include "nsIXPConnect.h"
|
2014-04-12 01:39:58 +04:00
|
|
|
#include "inIDOMUtils.h"
|
2014-04-29 21:27:02 +04:00
|
|
|
#include "nsIPermissionManager.h"
|
2014-08-19 05:13:14 +04:00
|
|
|
#include "nsIServiceWorkerManager.h"
|
2014-09-11 17:01:00 +04:00
|
|
|
#include "nsIAsyncShutdown.h"
|
2015-04-02 23:51:18 +03:00
|
|
|
#include "nsIUUIDGenerator.h"
|
2015-07-08 23:51:09 +03:00
|
|
|
#include "nsIGfxInfo.h"
|
2010-04-02 22:38:25 +04:00
|
|
|
|
2010-07-14 05:00:33 +04:00
|
|
|
using namespace mozilla;
|
2010-04-02 22:38:25 +04: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 23:00:15 +04:00
|
|
|
static TYPE* g##NAME = nullptr; \
|
2010-04-02 22:38:25 +04:00
|
|
|
\
|
2012-01-05 11:04:48 +04:00
|
|
|
already_AddRefed<TYPE> \
|
2010-04-02 22:38:25 +04:00
|
|
|
mozilla::services::Get##NAME() \
|
|
|
|
{ \
|
2014-04-29 19:51:14 +04:00
|
|
|
if (MOZ_UNLIKELY(gXPCOMShuttingDown)) { \
|
|
|
|
return nullptr; \
|
|
|
|
} \
|
2010-04-02 22:38:25 +04:00
|
|
|
if (!g##NAME) { \
|
|
|
|
nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID); \
|
2014-04-29 19:59:45 +04:00
|
|
|
os.swap(g##NAME); \
|
2010-04-02 22:38:25 +04:00
|
|
|
} \
|
2014-04-29 19:59:45 +04:00
|
|
|
nsCOMPtr<TYPE> ret = g##NAME; \
|
2013-04-22 15:15:59 +04:00
|
|
|
return ret.forget(); \
|
2010-04-02 22:38:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "ServiceList.h"
|
|
|
|
#undef MOZ_SERVICE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears service cache, sets gXPCOMShuttingDown
|
|
|
|
*/
|
2014-08-13 22:45:37 +04:00
|
|
|
void
|
2010-04-02 22:38:25 +04:00
|
|
|
mozilla::services::Shutdown()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
gXPCOMShuttingDown = true;
|
2010-04-02 22:38:25 +04:00
|
|
|
#define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) NS_IF_RELEASE(g##NAME);
|
|
|
|
#include "ServiceList.h"
|
|
|
|
#undef MOZ_SERVICE
|
|
|
|
}
|