xpcom/build/Services.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "mozilla/Services.h"
michael@0 7 #include "nsComponentManager.h"
michael@0 8 #include "nsIIOService.h"
michael@0 9 #include "nsIDirectoryService.h"
michael@0 10 #ifdef ACCESSIBILITY
michael@0 11 #include "nsIAccessibilityService.h"
michael@0 12 #endif
michael@0 13 #include "nsIChromeRegistry.h"
michael@0 14 #include "nsIObserverService.h"
michael@0 15 #include "nsNetCID.h"
michael@0 16 #include "nsObserverService.h"
michael@0 17 #include "nsXPCOMPrivate.h"
michael@0 18 #include "nsIStringBundle.h"
michael@0 19 #include "nsIToolkitChromeRegistry.h"
michael@0 20 #include "nsIXULOverlayProvider.h"
michael@0 21 #include "IHistory.h"
michael@0 22 #include "nsIXPConnect.h"
michael@0 23 #include "inIDOMUtils.h"
michael@0 24
michael@0 25 using namespace mozilla;
michael@0 26 using namespace mozilla::services;
michael@0 27
michael@0 28 /*
michael@0 29 * Define a global variable and a getter for every service in ServiceList.
michael@0 30 * eg. gIOService and GetIOService()
michael@0 31 */
michael@0 32 #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) \
michael@0 33 static TYPE* g##NAME = nullptr; \
michael@0 34 \
michael@0 35 already_AddRefed<TYPE> \
michael@0 36 mozilla::services::Get##NAME() \
michael@0 37 { \
michael@0 38 if (!g##NAME) { \
michael@0 39 nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID); \
michael@0 40 g##NAME = os.forget().take(); \
michael@0 41 } \
michael@0 42 nsRefPtr<TYPE> ret = g##NAME; \
michael@0 43 return ret.forget(); \
michael@0 44 } \
michael@0 45 NS_EXPORT_(already_AddRefed<TYPE>) \
michael@0 46 mozilla::services::_external_Get##NAME() \
michael@0 47 { \
michael@0 48 return Get##NAME(); \
michael@0 49 }
michael@0 50
michael@0 51 #include "ServiceList.h"
michael@0 52 #undef MOZ_SERVICE
michael@0 53
michael@0 54 /**
michael@0 55 * Clears service cache, sets gXPCOMShuttingDown
michael@0 56 */
michael@0 57 void
michael@0 58 mozilla::services::Shutdown()
michael@0 59 {
michael@0 60 gXPCOMShuttingDown = true;
michael@0 61 #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID) NS_IF_RELEASE(g##NAME);
michael@0 62 #include "ServiceList.h"
michael@0 63 #undef MOZ_SERVICE
michael@0 64 }

mercurial