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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/ModuleUtils.h"
7 #include "nsIClassInfoImpl.h"
9 #include "nsSample.h"
11 ////////////////////////////////////////////////////////////////////////
12 // With the below sample, you can define an implementation glue
13 // that talks with xpcom for creation of component nsSampleImpl
14 // that implement the interface nsISample. This can be extended for
15 // any number of components.
16 ////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////
19 // Define the contructor function for the object nsSampleImpl
20 //
21 // What this does is defines a function nsSampleImplConstructor which we
22 // will specific in the nsModuleComponentInfo table. This function will
23 // be used by the generic factory to create an instance of nsSampleImpl.
24 //
25 // NOTE: This creates an instance of nsSampleImpl by using the default
26 // constructor nsSampleImpl::nsSampleImpl()
27 //
28 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl)
30 // The following line defines a kNS_SAMPLE_CID CID variable.
31 NS_DEFINE_NAMED_CID(NS_SAMPLE_CID);
33 // Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs
34 // should be completely unique UUIDs.
35 // each entry has the form { CID, service, factoryproc, constructorproc }
36 // where factoryproc is usually nullptr.
37 static const mozilla::Module::CIDEntry kSampleCIDs[] = {
38 { &kNS_SAMPLE_CID, false, nullptr, nsSampleImplConstructor },
39 { nullptr }
40 };
42 // Build a table which maps contract IDs to CIDs.
43 // A contract is a string which identifies a particular set of functionality. In some
44 // cases an extension component may override the contract ID of a builtin gecko component
45 // to modify or extend functionality.
46 static const mozilla::Module::ContractIDEntry kSampleContracts[] = {
47 { NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID },
48 { nullptr }
49 };
51 // Category entries are category/key/value triples which can be used
52 // to register contract ID as content handlers or to observe certain
53 // notifications. Most modules do not need to register any category
54 // entries: this is just a sample of how you'd do it.
55 // @see nsICategoryManager for information on retrieving category data.
56 static const mozilla::Module::CategoryEntry kSampleCategories[] = {
57 { "my-category", "my-key", NS_SAMPLE_CONTRACTID },
58 { nullptr }
59 };
61 static const mozilla::Module kSampleModule = {
62 mozilla::Module::kVersion,
63 kSampleCIDs,
64 kSampleContracts,
65 kSampleCategories
66 };
68 // The following line implements the one-and-only "NSModule" symbol exported from this
69 // shared library.
70 NSMODULE_DEFN(nsSampleModule) = &kSampleModule;
72 // The following line implements the one-and-only "NSGetModule" symbol
73 // for compatibility with mozilla 1.9.2. You should only use this
74 // if you need a binary which is backwards-compatible and if you use
75 // interfaces carefully across multiple versions.
76 NS_IMPL_MOZILLA192_NSGETMODULE(&kSampleModule)