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