modules/libpref/src/nsPrefsFactory.cpp

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:aeeccca2f918
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/. */
5
6 #include "mozilla/ModuleUtils.h"
7 #include "mozilla/Preferences.h"
8 #include "nsPrefBranch.h"
9 #include "prefapi.h"
10
11 using namespace mozilla;
12
13 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences,
14 Preferences::GetInstanceForService)
15 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init)
16 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref)
17
18 static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
19 static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
20 static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID);
21
22 static mozilla::Module::CIDEntry kPrefCIDs[] = {
23 { &kPrefServiceCID, true, nullptr, PreferencesConstructor },
24 { &kPrefLocalizedStringCID, false, nullptr, nsPrefLocalizedStringConstructor },
25 { &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor },
26 { nullptr }
27 };
28
29 static mozilla::Module::ContractIDEntry kPrefContracts[] = {
30 { NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID },
31 { NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID },
32 { NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID },
33 // compatibility for extension that uses old service
34 { "@mozilla.org/preferences;1", &kPrefServiceCID },
35 { nullptr }
36 };
37
38 static void
39 UnloadPrefsModule()
40 {
41 Preferences::Shutdown();
42 }
43
44 static const mozilla::Module kPrefModule = {
45 mozilla::Module::kVersion,
46 kPrefCIDs,
47 kPrefContracts,
48 nullptr,
49 nullptr,
50 nullptr,
51 UnloadPrefsModule
52 };
53
54 NSMODULE_DEFN(nsPrefModule) = &kPrefModule;

mercurial