diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index e038d116d53c..4f56d9df5711 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -20,10 +20,10 @@ # include "Logging.h" #endif +#include "mozilla/Components.h" #include "mozilla/EventListenerManager.h" #include "mozilla/dom/Event.h" // for Event #include "nsContentUtils.h" -#include "nsCURILoader.h" #include "nsDocShellLoadTypes.h" #include "nsIChannel.h" #include "nsIInterfaceRequestorUtils.h" @@ -171,8 +171,7 @@ bool DocManager::IsProcessingRefreshDriverNotification() const { // DocManager protected bool DocManager::Init() { - nsCOMPtr progress = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID); + nsCOMPtr progress = components::DocLoader::Service(); if (!progress) return false; @@ -183,8 +182,7 @@ bool DocManager::Init() { } void DocManager::Shutdown() { - nsCOMPtr progress = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID); + nsCOMPtr progress = components::DocLoader::Service(); if (progress) progress->RemoveProgressListener( diff --git a/browser/base/content/test/general/browser_zbug569342.js b/browser/base/content/test/general/browser_zbug569342.js index 018ffc1ebd72..64c5ddf73806 100644 --- a/browser/base/content/test/general/browser_zbug569342.js +++ b/browser/base/content/test/general/browser_zbug569342.js @@ -13,7 +13,7 @@ add_task(async function findBarDisabledOnSomePages() { ok(!gFindBar.hidden, "Find bar should be visible"); let urls = [ - "about:config", + "about:preferences", "about:addons", ]; diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js index 13707671b7cf..c08b8c407e24 100644 --- a/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -42,8 +42,10 @@ var gExceptionPaths = [ // Exclude all search-plugins because they aren't referenced by filename "resource://search-plugins/", - // This is only in Nightly, and accessed using a direct chrome URL - "chrome://browser/content/aboutconfig/", + // Previous version of "about:config" kept for risk mitigation as a hidden + // page accessed using a direct chrome URL, will be removed in the future. + "chrome://global/content/config.js", + "chrome://global/content/config.xul", ]; // These are not part of the omni.ja file, so we find them only when running diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp index 867f7b9154b3..5f9f15a314eb 100644 --- a/browser/components/about/AboutRedirector.cpp +++ b/browser/components/about/AboutRedirector.cpp @@ -53,6 +53,7 @@ static const RedirEntry kRedirMap[] = { nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT}, + {"config", "chrome://browser/content/aboutconfig/aboutconfig.html", 0}, {"tabcrashed", "chrome://browser/content/aboutTabCrashed.xhtml", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::HIDE_FROM_ABOUTABOUT}, diff --git a/browser/components/aboutconfig/jar.mn b/browser/components/aboutconfig/jar.mn index 06e96991014a..d63beae99009 100644 --- a/browser/components/aboutconfig/jar.mn +++ b/browser/components/aboutconfig/jar.mn @@ -8,6 +8,3 @@ browser.jar: content/browser/aboutconfig/aboutconfig.html (content/aboutconfig.html) content/browser/aboutconfig/aboutconfig.js (content/aboutconfig.js) content/browser/aboutconfig/background.svg (content/background.svg) - -[localization] @AB_CD@.jar: - browser/aboutConfig.ftl (content/aboutconfig.notftl) diff --git a/browser/components/build/nsModule.cpp b/browser/components/build/nsModule.cpp index 9aa06b7b9518..c3720ed818ae 100644 --- a/browser/components/build/nsModule.cpp +++ b/browser/components/build/nsModule.cpp @@ -93,6 +93,7 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = { #endif { NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, + { NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "tabcrashed", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "privatebrowsing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "rights", &kNS_BROWSER_ABOUT_REDIRECTOR_CID }, diff --git a/browser/components/sessionstore/test/browser.ini b/browser/components/sessionstore/test/browser.ini index c890f6e4bec9..3b47a31528c0 100644 --- a/browser/components/sessionstore/test/browser.ini +++ b/browser/components/sessionstore/test/browser.ini @@ -143,6 +143,7 @@ skip-if = true [browser_354894_perwindowpb.js] [browser_367052.js] [browser_393716.js] +skip-if = debug # Bug 1507747 [browser_394759_basic.js] # Disabled for intermittent failures, bug 944372. skip-if = true diff --git a/browser/components/sessionstore/test/browser_393716.js b/browser/components/sessionstore/test/browser_393716.js index fae075aa0605..7119564d2beb 100644 --- a/browser/components/sessionstore/test/browser_393716.js +++ b/browser/components/sessionstore/test/browser_393716.js @@ -5,6 +5,15 @@ const URL = "about:config"; +add_task(async function setup() { + // Make sure that the field of which we restore the state is visible on load. + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.aboutConfig.showWarning", false], + ], + }); +}); + /** * Bug 393716 - Basic tests for getTabState(), setTabState(), and duplicateTab(). */ @@ -52,7 +61,7 @@ add_task(async function test_set_tabstate_and_duplicate() { "the tab's state was correctly restored"); // add text data - await setInputValue(tab.linkedBrowser, {id: "textbox", value: value3}); + await setInputValue(tab.linkedBrowser, {id: "search", value: value3}); // duplicate the tab let tab2 = ss.duplicateTab(window, tab); @@ -62,7 +71,7 @@ add_task(async function test_set_tabstate_and_duplicate() { ok(ss.getCustomTabValue(tab2, key2) == value2 && tab2.linkedBrowser.currentURI.spec == URL, "correctly duplicated the tab's state"); - let textbox = await getInputValue(tab2.linkedBrowser, {id: "textbox"}); + let textbox = await getInputValue(tab2.linkedBrowser, {id: "search"}); is(textbox, value3, "also duplicated text data"); // clean up diff --git a/browser/components/aboutconfig/content/aboutconfig.notftl b/browser/locales/en-US/browser/aboutConfig.ftl similarity index 100% rename from browser/components/aboutconfig/content/aboutconfig.notftl rename to browser/locales/en-US/browser/aboutConfig.ftl diff --git a/build/docs/defining-xpcom-components.rst b/build/docs/defining-xpcom-components.rst new file mode 100644 index 000000000000..790007febb76 --- /dev/null +++ b/build/docs/defining-xpcom-components.rst @@ -0,0 +1,266 @@ +.. _defining_xpcom_components: + +========================================= +Defining XPCOM C++-implemented Components +========================================= + +Native XPCOM components are registered at build time, and compiled into static +data structures which allow them to be accessed with little runtime overhead. +Each module which wishes to register components must provide a manifest +describing each component it implements, its type, and how it should be +constructed. + +Manifest files are Python data files registered in ``moz.build`` files in a +``XPCOM_MANIFESTS`` file list: + +.. code-block:: python + + XPCOM_MANIFESTS += [ + 'components.conf', + ] + +The files may define any of the following special variables: + +.. code-block:: python + + # Optional: A function to be called once, the first time any component + # listed in this manifest is instantiated. + InitFunc = 'nsInitFooModule' + # Optional: A function to be called at shutdown if any component listed in + # this manifest has been instantiated. + UnloadFunc = 'nsUnloadFooModule' + + # Optional: A processing priority, to determine how early or late the + # manifest is processed. Defaults to 50. In practice, this mainly affects + # the order in which unload functions are called at shutdown, with higher + # priority numbers being called later. + Priority = 10 + + # Optional: A list of header files to include before calling init or + # unload functions, or any legacy constructor functions. + # + # Any header path beginning with a `/` is loaded relative to the root of + # the source tree, and must not rely on any local includes. + # + # Any relative header path must be exported. + Headers = [ + '/foo/nsFooModule.h', + 'nsFoo.h', + ] + + # A list of component classes provided by this module. + Classes = [ + { + # ... + }, + # ... + ] + +Class definitions may have the following properties: + +``name`` (optional) + If present, this component will generate an entry with the given name in the + ``mozilla::components`` namespace in ``mozilla/Components.h``, which gives + easy access to its CID, service, and instance constructors as (e.g.,) + ``components::Foo::CID()``, ``components::Foo::Service()``, and + ``components::Foo::Create()``, respectively. + +``cid`` + A UUID string containing this component's CID, in the form + ``'{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}'``. + +``contract_ids`` (optional) + A list of contract IDs to register for this class. + +``categories`` (optional) + A dict of category entries to register for this component's contract ID. + Each key in the dict is the name of the category. Each value is either a + string containing a single entry name, or a list of entry name strings. + +``type`` (optional, default=``nsISupports``) + The fully-qualified type of the class implementing this component. Defaults + to ``nsISupports``, but **must** be provided if the ``init_method`` property + is specified, or if neither the ``constructor`` nor ``legacy_constructor`` + properties are provided. + +``headers`` (optional) + A list of headers to include in order to call this component's constructor, + in the same format as the global ``Headers`` property. + +``init_method`` (optional) + The name of a method to call on newly-created instances of this class before + returning them. The method must take no arguments, and must return a + ``nsresult``. If it returns failure, that failure is propagated to the + ``getService`` or ``createInstance`` caller. + +``constructor`` (optional) + The fully-qualified name of a constructor function to call in order to + create instances of this class. This function must be declared in one of the + headers listed in the ``headers`` property, must take no arguments, and must + return ``already_AddRefed`` where ``iface`` is the interface provided + in the ``type`` property. + + This property is incompatible with ``legacy_constructor``. + +``legacy_constructor`` (optional) + This property is deprecated, and should not be used in new code. + + The fully-qualified name of a constructor function to call in order to + create instances of this class. This function must be declared in one of the + headers listed in the ``headers`` property, and must have the signature + ``nsresult(nsISupports* aOuter, const nsID& aIID, void** aResult)``, and + behave equivalently to ``nsIFactory::CreateInstance``. + + This property is incompatible with ``constructor``. + +``singleton`` (optional, default=``False``) + If true, this component's constructor is expected to return the same + singleton for every call, and no ``mozilla::components::::Create()`` + method will be generated for it. + +``overridable`` (optional, default=``False``) + If true, this component's contract ID is expected to be overridden by some + tests, and its ``mozilla::components::::Service()`` getter will + therefore look it up by contract ID for every call. This component must, + therefore, provide at least one contract ID in its ``contract_ids`` array. + + If false, the ``Service()`` getter will always retrieve the service based on + its static data, and it cannot be overridden. + + Note: Enabling this option is expensive, and should not be done when it can + be avoided, or when the getter is used by any hot code. + +``external`` (optional, default=``False`` if any ``headers`` are provided, ``True`` otherwise) + If true, a constructor for this component's ``type`` must be defined in + another translation unit, using ``NS_IMPL_COMPONENT_FACTORY(type)``. The + constructor must return an ``already_AddRefed``, and will be + used to construct instances of this type. + + This option should only be used in cases where the headers which define the + component's concrete type cannot be easily included without local includes. + + Note: External constructors may not specify an ``init_method``, since the + generated code will not have the necessary type information required to call + it. This option is also incompatible with ``constructor`` and + ``legacy_constructor``. + +``processes`` (optional, default=``ProcessSelector.ANY_PROCESS``) + An optional specifier restricting which types of process this component may + be loaded in. This must be a property of ``ProcessSelector`` with the same + name as one of the values in the ``Module::ProcessSelector`` enum. + + +Conditional Compilation +======================= + +This manifest may run any appropriate Python code to customize the values of +the ``Classes`` array based on build configuration. To simplify this process, +the following globals are available: + +``defined`` + A function which returns true if the given build config setting is defined + and true. + +``buildconfig`` + The ``buildconfig`` python module, with a ``substs`` property containing a + dict of all available build substitutions. + + +Component Constructors +====================== + +There are several ways to define component constructors, which vary mostly +depending on how old the code that uses them is: + +Class Constructors +------------------ + +This simplest way to define a component is to include a header defining a +concrete type, and let the component manager call that class's constructor: + +.. code-block:: python + + 'type': 'mozilla::foo::Foo', + 'headers': ['mozilla/Foo.h'], + +This is generally the preferred method of defining non-singleton constructors, +but may not be practicable for classes which rely on local includes for their +definitions. + +Singleton Constructors +---------------------- + +Singleton classes are generally expected to provide their own constructor +function which caches a singleton instance the first time it is called, and +returns the same instance on subsequent calls. This requires declaring the +constructor in an included header, and implementing it in a separate source +file: + +.. code-block:: python + + 'type': 'mozilla::foo::Foo', + 'headers': ['mozilla/Foo.h'], + 'constructor': 'mozilla::Foo::GetSingleton', + +``Foo.h`` + +.. code-block:: c++ + + class Foo final : public nsISupports { + public: + static already_AddRefed GetSingleton(); + }; + +``Foo.cpp`` + +.. code-block:: c++ + + already_AddRefed Foo::GetSingleton() { + // ... + } + +External Constructors +--------------------- + +For types whose headers can't easily be included, constructors can be defined +using a template specialization on an incomplete type: + +.. code-block:: python + + 'type': 'mozilla::foo::Foo', + 'external: True,' + +``Foo.cpp`` + +.. code-block:: c++ + + NS_IMPL_COMPONENT_FACTORY(Foo) { + return do_AddRef(new Foo()).downcast(); + } + +Legacy Constructors +------------------- + +These should not be used in new code, and are left as an exercise for the +reader. + + +Registering Categories +====================== + +Classes which need define category entries with the same value as their +contract ID may do so using the following: + +.. code-block:: python + + 'contract_ids': ['@mozilla.org/foo;1'], + 'categories': { + 'content-policy': 'm-foo', + 'Gecko-Content-Viewers': ['image/jpeg', 'image/png'], + }, + +This will define each of the following category entries: + +* ``"content-policy"`` ``"m-foo",`` ``"@mozilla.org/foo;1"`` +* ``"Gecko-Content-Viewers"`` ``"image/jpeg"`` ``"@mozilla.org/foo;1"`` +* ``"Gecko-Content-Viewers"`` ``"image/png"`` ``"@mozilla.org/foo;1"`` diff --git a/build/docs/index.rst b/build/docs/index.rst index 88b6def06414..da8d210f2e28 100644 --- a/build/docs/index.rst +++ b/build/docs/index.rst @@ -25,6 +25,7 @@ Important Concepts preprocessor jar-manifests defining-binaries + defining-xpcom-components toolchains locales rust diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 4eb993821a7e..2b91c73cccfd 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -53,11 +53,11 @@ #include "nsAboutProtocolUtils.h" #include "nsIClassInfo.h" #include "nsIURIFixup.h" -#include "nsCDefaultURIFixup.h" #include "nsIChromeRegistry.h" #include "nsIResProtocolHandler.h" #include "nsIContentSecurityPolicy.h" #include "nsIAsyncVerifyRedirectCallback.h" +#include "mozilla/Components.h" #include "mozilla/Preferences.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/NullPrincipal.h" @@ -1150,7 +1150,7 @@ nsScriptSecurityManager::CheckLoadURIStrWithPrincipal( // Now start testing fixup -- since aTargetURIStr is a string, not // an nsIURI, we may well end up fixing it up before loading. // Note: This needs to stay in sync with the nsIURIFixup api. - nsCOMPtr fixup = do_GetService(NS_URIFIXUP_CONTRACTID); + nsCOMPtr fixup = components::URIFixup::Service(); if (!fixup) { return rv; } diff --git a/devtools/client/inspector/rules/components/Selector.js b/devtools/client/inspector/rules/components/Selector.js index ded110da8197..37b677610459 100644 --- a/devtools/client/inspector/rules/components/Selector.js +++ b/devtools/client/inspector/rules/components/Selector.js @@ -66,33 +66,44 @@ class Selector extends PureComponent { // matches. for (let i = 0; i < selectors.length; i++) { const selector = selectors[i]; - // Parse the selector for pseudo classes and attributes, and apply different // CSS classes for the parsed values. // NOTE: parsePseudoClassesAndAttributes is a good candidate for memoization. - const parsedSelector = parsePseudoClassesAndAttributes(selector); - for (const parsedText of parsedSelector) { - let selectorSpanClass = matchedSelectors.indexOf(selector) > -1 ? - "ruleview-selector-matched" : "ruleview-selector-unmatched"; + output.push( + dom.span( + { + className: matchedSelectors.indexOf(selector) > -1 ? + "ruleview-selector-matched" : "ruleview-selector-unmatched", + }, + parsePseudoClassesAndAttributes(selector).map(({ type, value }) => { + let selectorSpanClass = ""; - switch (parsedText.type) { - case SELECTOR_ATTRIBUTE: - selectorSpanClass += " ruleview-selector-attribute"; - break; - case SELECTOR_ELEMENT: - selectorSpanClass += " ruleview-selector"; - break; - case SELECTOR_PSEUDO_CLASS: - selectorSpanClass += PSEUDO_CLASSES.some(p => parsedText.value === p) ? - " ruleview-selector-pseudo-class-lock" : - " ruleview-selector-pseudo-class"; - break; - } + switch (type) { + case SELECTOR_ATTRIBUTE: + selectorSpanClass += " ruleview-selector-attribute"; + break; + case SELECTOR_ELEMENT: + selectorSpanClass += " ruleview-selector"; + break; + case SELECTOR_PSEUDO_CLASS: + selectorSpanClass += PSEUDO_CLASSES.some(p => value === p) ? + " ruleview-selector-pseudo-class-lock" : + " ruleview-selector-pseudo-class"; + break; + } - output.push( - dom.span({ className: selectorSpanClass }, parsedText.value) - ); - } + return ( + dom.span( + { + key: value, + className: selectorSpanClass, + }, + value + ) + ); + }) + ) + ); // Append a comma separator unless this is the last selector. if (i < selectors.length - 1) { diff --git a/devtools/client/webreplay/mochitest/browser.ini b/devtools/client/webreplay/mochitest/browser.ini index 833f815460e4..6f2f840a3b9f 100644 --- a/devtools/client/webreplay/mochitest/browser.ini +++ b/devtools/client/webreplay/mochitest/browser.ini @@ -1,6 +1,6 @@ [DEFAULT] -tags = devtools -subsuite = devtools +tags = devtools-webreplay +subsuite = devtools-webreplay # Feel free to set this to true if an impending change breaks Web Replay and # fixing it would be annoying or difficult. This will avoid running all tests @@ -9,8 +9,7 @@ subsuite = devtools # # Please file a bug against the 'Core > Web Replay' component if you do so, # so that the problem can be fixed and tests reenabled. -skip-if = true # See bug 1523364 -# skip-if = os != "mac" || debug || !nightly_build +skip-if = os != "mac" || debug || !nightly_build support-files = head.js diff --git a/docshell/base/ChildProcessChannelListener.h b/docshell/base/ChildProcessChannelListener.h index 72d025e9cfa2..b87db1f862ee 100644 --- a/docshell/base/ChildProcessChannelListener.h +++ b/docshell/base/ChildProcessChannelListener.h @@ -38,15 +38,6 @@ class ChildProcessChannelListener final nsDataHashtable> mChannels; }; -#define NS_CHILDPROCESSCHANNELLISTENER_CID \ - { \ - 0x397b43f3, 0x1470, 0x4542, { \ - 0x8a, 0x40, 0xc7, 0x18, 0xf7, 0x75, 0x35, 0x63 \ - } \ - } -#define NS_CHILDPROCESSCHANNELLISTENER_CONTRACTID \ - "@mozilla.org/network/childProcessChannelListener;1" - } // namespace dom } // namespace mozilla diff --git a/docshell/base/moz.build b/docshell/base/moz.build index e01a665c29b6..78da07dd12c4 100644 --- a/docshell/base/moz.build +++ b/docshell/base/moz.build @@ -36,7 +36,6 @@ DIRS += [ ] XPIDL_SOURCES += [ - 'nsCDefaultURIFixup.idl', 'nsIContentViewer.idl', 'nsIContentViewerEdit.idl', 'nsIDocShell.idl', diff --git a/docshell/base/nsAboutRedirector.cpp b/docshell/base/nsAboutRedirector.cpp index 6893484d5ff4..e57e491f08f5 100644 --- a/docshell/base/nsAboutRedirector.cpp +++ b/docshell/base/nsAboutRedirector.cpp @@ -72,7 +72,9 @@ static const RedirEntry kRedirMap[] = { {"checkerboard", "chrome://global/content/aboutCheckerboard.xhtml", nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | nsIAboutModule::ALLOW_SCRIPT}, +#if !defined(NIGHTLY_BUILD) || !defined(MOZ_BUILD_APP_IS_BROWSER) {"config", "chrome://global/content/config.xul", 0}, +#endif #ifdef MOZ_CRASHREPORTER {"crashes", "chrome://global/content/crashes.xhtml", 0}, #endif diff --git a/docshell/base/nsAboutRedirector.h b/docshell/base/nsAboutRedirector.h index c84c4f84fd77..08448787e97a 100644 --- a/docshell/base/nsAboutRedirector.h +++ b/docshell/base/nsAboutRedirector.h @@ -23,12 +23,4 @@ class nsAboutRedirector : public nsIAboutModule { virtual ~nsAboutRedirector() {} }; -/* 56ebedd4-6ccf-48e8-bdae-adc77f044567 */ -#define NS_ABOUT_REDIRECTOR_MODULE_CID \ - { \ - 0x56ebedd4, 0x6ccf, 0x48e8, { \ - 0xbd, 0xae, 0xad, 0xc7, 0x7f, 0x04, 0x45, 0x67 \ - } \ - } - #endif // nsAboutRedirector_h__ diff --git a/docshell/base/nsCDefaultURIFixup.idl b/docshell/base/nsCDefaultURIFixup.idl deleted file mode 100644 index 60fffdf21931..000000000000 --- a/docshell/base/nsCDefaultURIFixup.idl +++ /dev/null @@ -1,13 +0,0 @@ -/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -%{ C++ -// {214C48A0-B57F-11d4-959C-0020183BF181} -#define NS_DEFAULTURIFIXUP_CID \ -{ 0x214c48a0, 0xb57f, 0x11d4, { 0x95, 0x9c, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } } -#define NS_URIFIXUP_CONTRACTID \ -"@mozilla.org/docshell/urifixup;1" -%} diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index eaae3b0d0424..251fc18998c0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -20,6 +20,7 @@ #include "mozilla/AutoRestore.h" #include "mozilla/BasePrincipal.h" #include "mozilla/Casting.h" +#include "mozilla/Components.h" #include "mozilla/Encoding.h" #include "mozilla/EventStateManager.h" #include "mozilla/HTMLEditor.h" @@ -160,7 +161,6 @@ #include "nsArray.h" #include "nsArrayUtils.h" #include "nsAutoPtr.h" -#include "nsCDefaultURIFixup.h" #include "nsCExternalHandlerService.h" #include "nsContentDLF.h" #include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...) @@ -399,7 +399,8 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext) NS_ASSERTION(sURIFixup == nullptr, "Huh, sURIFixup not null in first nsDocShell ctor!"); - CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup); + nsCOMPtr uriFixup = components::URIFixup::Service(); + uriFixup.forget(&sURIFixup); } MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this)); @@ -9628,13 +9629,12 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, return NS_OK; } - nsresult rv; - nsCOMPtr uriLoader = - do_GetService(NS_URI_LOADER_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - return rv; + nsCOMPtr uriLoader = components::URILoader::Service(); + if (NS_WARN_IF(!uriLoader)) { + return NS_ERROR_UNEXPECTED; } + nsresult rv; if (IsFrame()) { MOZ_ASSERT(aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME || aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME, @@ -11267,7 +11267,7 @@ nsresult nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel, // Create a new entry if necessary. if (!entry) { - entry = do_CreateInstance(NS_SHENTRY_CONTRACTID); + entry = components::SHEntry::Create(); if (!entry) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/docshell/base/nsWebNavigationInfo.h b/docshell/base/nsWebNavigationInfo.h index b952d238a13f..1dfa902889f9 100644 --- a/docshell/base/nsWebNavigationInfo.h +++ b/docshell/base/nsWebNavigationInfo.h @@ -13,13 +13,6 @@ #include "nsStringFwd.h" #include "mozilla/Attributes.h" -#define NS_WEBNAVIGATION_INFO_CID \ - { \ - 0xf30bc0a2, 0x958b, 0x4287, { \ - 0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e \ - } \ - } - class nsWebNavigationInfo final : public nsIWebNavigationInfo { public: nsWebNavigationInfo() {} diff --git a/docshell/build/components.conf b/docshell/build/components.conf new file mode 100644 index 000000000000..f8c3e248f2ca --- /dev/null +++ b/docshell/build/components.conf @@ -0,0 +1,177 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +about_pages = [ + 'about', + 'addons', + 'buildconfig', + 'checkerboard', + 'crashcontent', + 'crashparent', + 'credits', + 'license', + 'logo', + 'memory', + 'mozilla', + 'neterror', + 'networking', + 'performance', + 'plugins', + 'printpreview', + 'serviceworkers', + 'srcdoc', + 'support', + 'telemetry', + 'url-classifier', + 'webrtc', +] + +if not defined('NIGHTLY_BUILD') or buildconfig.substs['MOZ_BUILD_APP'] != 'browser': + about_pages.append('config') +if defined('MOZ_CRASHREPORTER'): + about_pages.append('crashes') +if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android': + about_pages.append('profiles') + +Headers = ['/docshell/build/nsDocShellModule.h'] + +InitFunc = 'mozilla::InitDocShellModule' +UnloadFunc = 'mozilla::UnloadDocShellModule' + +Classes = [ + { + 'name': 'SHEntry', + 'cid': '{bfd1a791-ad9f-11d3-bdc7-0050040a9b44}', + 'contract_ids': ['@mozilla.org/browser/session-history-entry;1'], + 'type': 'nsSHEntry', + 'headers': ['/docshell/shistory/nsSHEntry.h'], + }, + { + 'name': 'DocLoader', + 'cid': '{057b04d0-0ccf-11d2-beba-00805f8a66dc}', + 'contract_ids': ['@mozilla.org/docloaderservice;1'], + 'type': 'nsDocLoader', + 'headers': ['nsDocLoader.h'], + 'init_method': 'Init', + }, + { + 'name': 'URIFixup', + 'cid': '{214c48a0-b57f-11d4-959c-0020183bf181}', + 'contract_ids': ['@mozilla.org/docshell/urifixup;1'], + 'type': 'nsDefaultURIFixup', + 'headers': ['/docshell/base/nsDefaultURIFixup.h'], + }, + { + 'cid': '{a7f800e0-4306-11d4-98d0-001083010e9b}', + 'contract_ids': [ + '@mozilla.org/mime;1', + '@mozilla.org/uriloader/external-helper-app-service;1', + '@mozilla.org/uriloader/external-protocol-service;1', + ], + 'type': 'nsOSHelperAppService', + 'headers': ['nsOSHelperAppService.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{397b43f3-1470-4542-8a40-c718f7753563}', + 'contract_ids': ['@mozilla.org/network/childProcessChannelListener;1'], + 'singleton': True, + 'type': 'mozilla::dom::ChildProcessChannelListener', + 'constructor': 'mozilla::dom::ChildProcessChannelListener::GetSingleton', + 'headers': ['mozilla/dom/ChildProcessChannelListener.h'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + { + 'cid': '{56ebedd4-6ccf-48e8-bdae-adc77f044567}', + 'contract_ids': [ + '@mozilla.org/network/protocol/about;1?what=%s' % path + for path in about_pages + ], + 'legacy_constructor': 'nsAboutRedirector::Create', + 'headers': ['/docshell/base/nsAboutRedirector.h'], + }, + { + 'cid': '{bd6390c8-fbea-11d4-98f6-001083010e9b}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=default'], + 'type': 'nsExternalProtocolHandler', + 'headers': ['/uriloader/exthandler/nsExternalProtocolHandler.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'name': 'OfflineCacheUpdate', + 'cid': '{ec06f3fc-70db-4ecd-94e0-a6e91ca44d8a}', + 'contract_ids': ['@mozilla.org/offlinecacheupdate-service;1'], + 'singleton': True, + 'type': 'nsOfflineCacheUpdateService', + 'headers': ['/uriloader/prefetch/nsOfflineCacheUpdate.h'], + 'constructor': 'nsOfflineCacheUpdateService::GetInstance', + }, + { + 'cid': '{95790842-75a0-430d-98bf-f5ce3788ea6d}', + 'contract_ids': ['@mozilla.org/ospermissionrequest;1'], + 'type': 'nsOSPermissionRequest', + 'headers': ['nsOSPermissionRequest.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'name': 'Prefetch', + 'cid': '{6b8bdffc-3394-417d-be83-a81b7c0f63bf}', + 'contract_ids': ['@mozilla.org/prefetch-service;1'], + 'type': 'nsPrefetchService', + 'headers': ['/uriloader/prefetch/nsPrefetchService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{c4b6fb7c-bfb1-49dc-a65f-035796524b53}', + 'contract_ids': ['@mozilla.org/uriloader/handler-service;1'], + 'type': 'mozilla::dom::ContentHandlerService', + 'headers': ['ContentHandlerService.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + { + 'cid': '{bc0017e3-2438-47be-a567-41db58f17627}', + 'contract_ids': ['@mozilla.org/uriloader/local-handler-app;1'], + 'type': 'PlatformLocalHandlerApp_t', + 'headers': ['/uriloader/exthandler/nsLocalHandlerApp.h'], + }, + { + 'name': 'URILoader', + 'cid': '{9f6d5d40-90e7-11d3-af80-00a024ffc08c}', + 'contract_ids': ['@mozilla.org/uriloader;1'], + 'type': 'nsURILoader', + 'headers': ['nsURILoader.h'], + }, + { + 'cid': '{f30bc0a2-958b-4287-bf62-ce38ba0c811e}', + 'contract_ids': ['@mozilla.org/webnavigation-info;1'], + 'type': 'nsWebNavigationInfo', + 'headers': ['/docshell/base/nsWebNavigationInfo.h'], + 'init_method': 'Init', + }, +] + +if defined('MOZ_ENABLE_DBUS'): + Classes += [ + { + 'name': 'DBusHandlerApp', + 'cid': '{6c3c274b-4cbf-4bb5-a635-05ad2cbb6535}', + 'contract_ids': ['@mozilla.org/uriloader/dbus-handler-app;1'], + 'type': 'nsDBusHandlerApp', + 'headers': ['/uriloader/exthandler/nsDBusHandlerApp.h'], + }, + ] + +if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'android': + Classes += [ + { + 'cid': '{4bf1f8ef-d947-4ba3-9cd3-8c9a54a63a1c}', + 'contract_ids': ['@mozilla.org/uriloader/external-url-handler-service;1'], + 'type': 'nsExternalURLHandlerService', + 'headers': ['nsExternalURLHandlerService.h'], + }, + ] diff --git a/docshell/build/moz.build b/docshell/build/moz.build index e47bd89eda01..b48cb24fabe4 100644 --- a/docshell/build/moz.build +++ b/docshell/build/moz.build @@ -13,11 +13,11 @@ SOURCES += [ ] LOCAL_INCLUDES += [ - '/docshell/base', '/docshell/shistory', - '/uriloader/base', - '/uriloader/exthandler', - '/uriloader/prefetch', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] include('/ipc/chromium/chromium-config.mozbuild') diff --git a/docshell/build/nsDocShellModule.cpp b/docshell/build/nsDocShellModule.cpp index a84fca81ce16..ed5c2a4b34e5 100644 --- a/docshell/build/nsDocShellModule.cpp +++ b/docshell/build/nsDocShellModule.cpp @@ -4,53 +4,16 @@ * 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/. */ -#include "mozilla/ModuleUtils.h" -#include "nsDocShellCID.h" - #include "mozilla/dom/BrowsingContext.h" -#include "mozilla/dom/ChildProcessChannelListener.h" - -#include "nsDocShell.h" -#include "nsDefaultURIFixup.h" -#include "nsWebNavigationInfo.h" -#include "nsAboutRedirector.h" -#include "nsCDefaultURIFixup.h" - -// uriloader -#include "nsURILoader.h" -#include "nsDocLoader.h" -#include "nsOSHelperAppService.h" -#include "nsOSPermissionRequest.h" -#include "nsExternalProtocolHandler.h" -#include "nsPrefetchService.h" -#include "nsOfflineCacheUpdate.h" -#include "nsLocalHandlerApp.h" -#include "ContentHandlerService.h" -#ifdef MOZ_ENABLE_DBUS -# include "nsDBusHandlerApp.h" -#endif -#if defined(MOZ_WIDGET_ANDROID) -# include "nsExternalURLHandlerService.h" -#endif // session history -#include "nsSHEntry.h" #include "nsSHEntryShared.h" #include "nsSHistory.h" -using mozilla::dom::ChildProcessChannelListener; -using mozilla::dom::ContentHandlerService; - -static bool gInitialized = false; +namespace mozilla { // The one time initialization for this module -static nsresult Initialize() { - MOZ_ASSERT(!gInitialized, "docshell module already initialized"); - if (gInitialized) { - return NS_OK; - } - gInitialized = true; - +nsresult InitDocShellModule() { mozilla::dom::BrowsingContext::Init(); nsresult rv = nsSHistory::Startup(); NS_ENSURE_SUCCESS(rv, rv); @@ -58,152 +21,9 @@ static nsresult Initialize() { return NS_OK; } -static void Shutdown() { +void UnloadDocShellModule() { nsSHistory::Shutdown(); nsSHEntryShared::Shutdown(); - gInitialized = false; } -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init) - -// uriloader -NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - nsOfflineCacheUpdateService, nsOfflineCacheUpdateService::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t) -#ifdef MOZ_ENABLE_DBUS -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp) -#endif -#if defined(MOZ_WIDGET_ANDROID) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService) -#endif -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ContentHandlerService, Init) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - ChildProcessChannelListener, ChildProcessChannelListener::GetSingleton) - -// OS access permissions -NS_GENERIC_FACTORY_CONSTRUCTOR(nsOSPermissionRequest) - -// session history -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry) - -NS_DEFINE_NAMED_CID(NS_DEFAULTURIFIXUP_CID); -NS_DEFINE_NAMED_CID(NS_WEBNAVIGATION_INFO_CID); -NS_DEFINE_NAMED_CID(NS_ABOUT_REDIRECTOR_MODULE_CID); -NS_DEFINE_NAMED_CID(NS_URI_LOADER_CID); -NS_DEFINE_NAMED_CID(NS_DOCUMENTLOADER_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_EXTERNALHELPERAPPSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_EXTERNALPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_PREFETCHSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_OFFLINECACHEUPDATESERVICE_CID); -NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_CID); -NS_DEFINE_NAMED_CID(NS_OSPERMISSIONREQUEST_CID); -#ifdef MOZ_ENABLE_DBUS -NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID); -#endif -#if defined(MOZ_WIDGET_ANDROID) -NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID); -#endif -NS_DEFINE_NAMED_CID(NS_SHENTRY_CID); -NS_DEFINE_NAMED_CID(NS_CONTENTHANDLERSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_CHILDPROCESSCHANNELLISTENER_CID); - -const mozilla::Module::CIDEntry kDocShellCIDs[] = { - // clang-format off - { &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor }, - { &kNS_WEBNAVIGATION_INFO_CID, false, nullptr, nsWebNavigationInfoConstructor }, - { &kNS_ABOUT_REDIRECTOR_MODULE_CID, false, nullptr, nsAboutRedirector::Create }, - { &kNS_URI_LOADER_CID, false, nullptr, nsURILoaderConstructor }, - { &kNS_DOCUMENTLOADER_SERVICE_CID, false, nullptr, nsDocLoaderConstructor }, - { &kNS_EXTERNALHELPERAPPSERVICE_CID, false, nullptr, nsOSHelperAppServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_OSPERMISSIONREQUEST_CID, false, nullptr, nsOSPermissionRequestConstructor }, - { &kNS_CONTENTHANDLERSERVICE_CID, false, nullptr, ContentHandlerServiceConstructor, - mozilla::Module::CONTENT_PROCESS_ONLY }, - { &kNS_EXTERNALPROTOCOLHANDLER_CID, false, nullptr, nsExternalProtocolHandlerConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_PREFETCHSERVICE_CID, false, nullptr, nsPrefetchServiceConstructor }, - { &kNS_OFFLINECACHEUPDATESERVICE_CID, false, nullptr, nsOfflineCacheUpdateServiceConstructor }, - { &kNS_LOCALHANDLERAPP_CID, false, nullptr, PlatformLocalHandlerApp_tConstructor }, -#ifdef MOZ_ENABLE_DBUS - { &kNS_DBUSHANDLERAPP_CID, false, nullptr, nsDBusHandlerAppConstructor }, -#endif -#if defined(MOZ_WIDGET_ANDROID) - { &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor }, -#endif - { &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor }, - { &kNS_CHILDPROCESSCHANNELLISTENER_CID, false, nullptr, ChildProcessChannelListenerConstructor }, - { nullptr } - // clang-format on -}; - -const mozilla::Module::ContractIDEntry kDocShellContracts[] = { - // clang-format off - { NS_URIFIXUP_CONTRACTID, &kNS_DEFAULTURIFIXUP_CID }, - { NS_WEBNAVIGATION_INFO_CONTRACTID, &kNS_WEBNAVIGATION_INFO_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "about", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "checkerboard", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, -#ifdef MOZ_CRASHREPORTER - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, -#endif - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashparent", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashcontent", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "networking", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "performance", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "serviceworkers", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, -#ifndef ANDROID - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "profiles", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, -#endif - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "srcdoc", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "support", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "telemetry", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "webrtc", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "printpreview", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "url-classifier", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, - { NS_URI_LOADER_CONTRACTID, &kNS_URI_LOADER_CID }, - { NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &kNS_DOCUMENTLOADER_SERVICE_CID }, - { NS_HANDLERSERVICE_CONTRACTID, &kNS_CONTENTHANDLERSERVICE_CID, mozilla::Module::CONTENT_PROCESS_ONLY }, - { NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID }, - { NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_MIMESERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", &kNS_EXTERNALPROTOCOLHANDLER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_PREFETCHSERVICE_CONTRACTID, &kNS_PREFETCHSERVICE_CID }, - { NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &kNS_OFFLINECACHEUPDATESERVICE_CID }, - { NS_LOCALHANDLERAPP_CONTRACTID, &kNS_LOCALHANDLERAPP_CID }, -#ifdef MOZ_ENABLE_DBUS - { NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID }, -#endif -#if defined(MOZ_WIDGET_ANDROID) - { NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID }, -#endif - { NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID }, - { NS_OSPERMISSIONREQUEST_CONTRACTID, &kNS_OSPERMISSIONREQUEST_CID, mozilla::Module::MAIN_PROCESS_ONLY }, - { NS_CHILDPROCESSCHANNELLISTENER_CONTRACTID, &kNS_CHILDPROCESSCHANNELLISTENER_CID, mozilla::Module::CONTENT_PROCESS_ONLY }, - { nullptr } - // clang-format on -}; - -static const mozilla::Module kDocShellModule = { - mozilla::Module::kVersion, - kDocShellCIDs, - kDocShellContracts, - nullptr, - nullptr, - Initialize, - Shutdown, - mozilla::Module::ALLOW_IN_SOCKET_PROCESS}; - -NSMODULE_DEFN(docshell_provider) = &kDocShellModule; +} // namespace mozilla diff --git a/docshell/build/nsDocShellModule.h b/docshell/build/nsDocShellModule.h new file mode 100644 index 000000000000..c64f3ad8a95b --- /dev/null +++ b/docshell/build/nsDocShellModule.h @@ -0,0 +1,20 @@ +/* -*- 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 + * 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/. */ + +#ifndef nsDocShellModule_h +#define nsDocShellModule_h + +#include "nscore.h" + +namespace mozilla { + +nsresult InitDocShellModule(); + +void UnloadDocShellModule(); + +} // namespace mozilla + +#endif diff --git a/docshell/shistory/nsISHEntry.idl b/docshell/shistory/nsISHEntry.idl index 648fec03814a..5e69e2f93419 100644 --- a/docshell/shistory/nsISHEntry.idl +++ b/docshell/shistory/nsISHEntry.idl @@ -397,12 +397,3 @@ interface nsISHEntry : nsISupports [noscript] void ReplaceChild(in nsISHEntry aNewChild); }; -%{ C++ -// {BFD1A791-AD9F-11d3-BDC7-0050040A9B44} -#define NS_SHENTRY_CID \ -{0xbfd1a791, 0xad9f, 0x11d3, {0xbd, 0xc7, 0x0, 0x50, 0x4, 0xa, 0x9b, 0x44}} - -#define NS_SHENTRY_CONTRACTID \ - "@mozilla.org/browser/session-history-entry;1" -%} - diff --git a/dom/base/Link.cpp b/dom/base/Link.cpp index 0c76bf9589cf..97b3df0d20c3 100644 --- a/dom/base/Link.cpp +++ b/dom/base/Link.cpp @@ -6,6 +6,7 @@ #include "Link.h" +#include "mozilla/Components.h" #include "mozilla/EventStates.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" @@ -19,7 +20,6 @@ #include "nsISizeOf.h" #include "nsIDocShell.h" #include "nsIPrefetchService.h" -#include "nsCPrefetchService.h" #include "nsStyleLinkElement.h" #include "nsEscape.h" @@ -134,7 +134,7 @@ void Link::TryDNSPrefetchOrPreconnectOrPrefetchOrPreloadOrPrerender() { (linkTypes & nsStyleLinkElement::eNEXT) || (linkTypes & nsStyleLinkElement::ePRELOAD)) { nsCOMPtr prefetchService( - do_GetService(NS_PREFETCHSERVICE_CONTRACTID)); + components::Prefetch::Service()); if (prefetchService) { nsCOMPtr uri(GetURI()); if (uri) { @@ -209,8 +209,7 @@ void Link::UpdatePreload(nsAtom *aName, const nsAttrValue *aValue, return; } - nsCOMPtr prefetchService( - do_GetService(NS_PREFETCHSERVICE_CONTRACTID)); + nsCOMPtr prefetchService(components::Prefetch::Service()); if (!prefetchService) { return; } @@ -310,8 +309,7 @@ void Link::UpdatePreload(nsAtom *aName, const nsAttrValue *aValue, } void Link::CancelPrefetchOrPreload() { - nsCOMPtr prefetchService( - do_GetService(NS_PREFETCHSERVICE_CONTRACTID)); + nsCOMPtr prefetchService(components::Prefetch::Service()); if (prefetchService) { nsCOMPtr uri(GetURI()); if (uri) { diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index 9b6afa564da1..f159d86171bb 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -11,7 +11,6 @@ #include "nsIDocShell.h" #include "nsDocShellLoadState.h" #include "nsIWebNavigation.h" -#include "nsCDefaultURIFixup.h" #include "nsIURIFixup.h" #include "nsIURL.h" #include "nsIURIMutator.h" @@ -31,6 +30,7 @@ #include "nsGlobalWindow.h" #include "mozilla/Likely.h" #include "nsCycleCollectionParticipant.h" +#include "mozilla/Components.h" #include "mozilla/NullPrincipal.h" #include "mozilla/Unused.h" #include "mozilla/dom/LocationBinding.h" @@ -192,8 +192,7 @@ nsresult Location::GetURI(nsIURI** aURI, bool aGetInnermostURI) { NS_ASSERTION(uri, "nsJARURI screwed up?"); - nsCOMPtr urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr urifixup(components::URIFixup::Service()); return urifixup->CreateExposableURI(uri, aURI); } diff --git a/dom/base/WindowDestroyedEvent.cpp b/dom/base/WindowDestroyedEvent.cpp index 4bd52a82a063..1550ebeb218c 100644 --- a/dom/base/WindowDestroyedEvent.cpp +++ b/dom/base/WindowDestroyedEvent.cpp @@ -12,10 +12,10 @@ #include "nsIPrincipal.h" #include "nsISupportsPrimitives.h" #include "nsIAppStartup.h" -#include "nsToolkitCompsCID.h" #include "nsCOMPtr.h" #include "nsContentUtils.h" #include "xpcpublic.h" +#include "mozilla/Components.h" namespace mozilla { @@ -65,8 +65,7 @@ WindowDestroyedEvent::Run() { case Phase::Destroying: { bool skipNukeCrossCompartment = false; #ifndef DEBUG - nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); + nsCOMPtr appStartup = components::AppStartup::Service(); if (appStartup) { appStartup->GetShuttingDown(&skipNukeCrossCompartment); diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index efcfdfe6d7d5..03070cd038cc 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -10,13 +10,14 @@ */ #include "nsContentSink.h" +#include "mozilla/Components.h" #include "mozilla/dom/Document.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/SRILogHelper.h" #include "nsStyleLinkElement.h" #include "nsIDocShell.h" #include "nsILoadContext.h" -#include "nsCPrefetchService.h" +#include "nsIPrefetchService.h" #include "nsIURI.h" #include "nsNetUtil.h" #include "nsIMIMEHeaderParam.h" @@ -825,8 +826,7 @@ void nsContentSink::PrefetchPreloadHref(const nsAString& aHref, const nsAString& aAs, const nsAString& aType, const nsAString& aMedia) { - nsCOMPtr prefetchService( - do_GetService(NS_PREFETCHSERVICE_CONTRACTID)); + nsCOMPtr prefetchService(components::Prefetch::Service()); if (prefetchService) { // construct URI using document charset auto encoding = mDocument->GetDocumentCharacterSet(); @@ -1126,7 +1126,7 @@ void nsContentSink::ProcessOfflineManifest(const nsAString& aManifestSpec) { break; case CACHE_SELECTION_UPDATE: { nsCOMPtr updateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID); + components::OfflineCacheUpdate::Service(); if (updateService) { updateService->ScheduleOnDocumentStop( diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 5b1428de6898..3891e42ab84d 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -40,6 +40,7 @@ #include "mozilla/Base64.h" #include "mozilla/BasePrincipal.h" #include "mozilla/CheckedInt.h" +#include "mozilla/Components.h" #include "mozilla/DebugOnly.h" #include "mozilla/LoadInfo.h" #include "mozilla/dom/BlobURLProtocolHandler.h" @@ -107,7 +108,6 @@ #include "nsContentList.h" #include "nsContentPolicyUtils.h" #include "nsContentSecurityManager.h" -#include "nsCPrefetchService.h" #include "nsCRT.h" #include "nsCycleCollectionParticipant.h" #include "nsCycleCollector.h" @@ -1784,7 +1784,7 @@ void nsContentUtils::GetOfflineAppManifest(Document* aDocument, nsIURI** aURI) { /* static */ bool nsContentUtils::OfflineAppAllowed(nsIURI* aURI) { nsCOMPtr updateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID); + components::OfflineCacheUpdate::Service(); if (!updateService) { return false; } @@ -1798,7 +1798,7 @@ bool nsContentUtils::OfflineAppAllowed(nsIURI* aURI) { /* static */ bool nsContentUtils::OfflineAppAllowed(nsIPrincipal* aPrincipal) { nsCOMPtr updateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID); + components::OfflineCacheUpdate::Service(); if (!updateService) { return false; } @@ -1822,7 +1822,7 @@ bool nsContentUtils::MaybeAllowOfflineAppByDefault(nsIPrincipal* aPrincipal) { if (!allowedByDefault) return false; nsCOMPtr updateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID); + components::OfflineCacheUpdate::Service(); if (!updateService) { return false; } diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index a2b906ad884c..7d8888e4b157 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -149,11 +149,6 @@ #include "nsContentUtils.h" #include "nsCSSProps.h" #include "nsIURIFixup.h" -#ifndef DEBUG -# include "nsIAppStartup.h" -# include "nsToolkitCompsCID.h" -#endif -#include "nsCDefaultURIFixup.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStateManager.h" #include "nsIObserverService.h" diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index b60dcc7955d1..c2f5c7804815 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -95,6 +95,7 @@ #include "mozilla/dom/ToJSValue.h" #include "nsJSPrincipals.h" #include "mozilla/Attributes.h" +#include "mozilla/Components.h" #include "mozilla/Debug.h" #include "mozilla/EventListenerManager.h" #include "mozilla/EventStates.h" @@ -153,11 +154,6 @@ #include "nsCSSProps.h" #include "nsIURIFixup.h" #include "nsIURIMutator.h" -#ifndef DEBUG -# include "nsIAppStartup.h" -# include "nsToolkitCompsCID.h" -#endif -#include "nsCDefaultURIFixup.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStateManager.h" #include "nsIObserverService.h" @@ -4561,7 +4557,7 @@ void nsGlobalWindowOuter::MakeScriptDialogTitle( if (NS_SUCCEEDED(rv) && uri) { // remove user:pass for privacy and spoof prevention - nsCOMPtr fixup(do_GetService(NS_URIFIXUP_CONTRACTID)); + nsCOMPtr fixup(components::URIFixup::Service()); if (fixup) { nsCOMPtr fixedURI; rv = fixup->CreateExposableURI(uri, getter_AddRefs(fixedURI)); diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 377fa5839ead..fb93433e551e 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -74,6 +74,7 @@ #include "nsWidgetsCID.h" #include "nsContentCID.h" #include "mozilla/BasicEvents.h" +#include "mozilla/Components.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" @@ -2240,9 +2241,8 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad, nsCOMPtr req(do_QueryInterface(docShell)); NS_ASSERTION(req, "Docshell must be an ifreq"); - nsCOMPtr uriLoader( - do_GetService(NS_URI_LOADER_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { + nsCOMPtr uriLoader(components::URILoader::Service()); + if (NS_WARN_IF(!uriLoader)) { MOZ_ASSERT_UNREACHABLE("Failed to get uriLoader service"); mFrameLoader->Destroy(); mFrameLoader = nullptr; diff --git a/dom/events/test/test_bug574663.html b/dom/events/test/test_bug574663.html index b90698affbc1..bbf6c0a692ab 100644 --- a/dom/events/test/test_bug574663.html +++ b/dom/events/test/test_bug574663.html @@ -25,7 +25,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=574663 function waitForPaint(win, utils, callback) { win.document.documentElement.getBoundingClientRect(); if (!utils.isMozAfterPaintPending) { - callback(); + win.requestAnimationFrame(function() { + setTimeout(callback); + }); return; } diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index 0bc59cafb106..903fa2653511 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -20,7 +20,6 @@ #include "nsIDNSListener.h" #include "nsIWebProgressListener.h" #include "nsIWebProgress.h" -#include "nsCURILoader.h" #include "nsIDNSRecord.h" #include "nsIDNSService.h" #include "nsICancelable.h" @@ -31,6 +30,7 @@ #include "nsIObserverService.h" #include "mozilla/dom/Link.h" +#include "mozilla/Components.h" #include "mozilla/Preferences.h" using namespace mozilla; @@ -410,8 +410,7 @@ void nsHTMLDNSPrefetch::nsDeferrals::SubmitQueue() { void nsHTMLDNSPrefetch::nsDeferrals::Activate() { // Register as an observer for the document loader - nsCOMPtr progress = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID); + nsCOMPtr progress = components::DocLoader::Service(); if (progress) progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 053f105997e5..413f33475b5b 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -33,6 +33,7 @@ #include "mozilla/AntiTrackingCommon.h" #include "mozilla/BasePrincipal.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/Components.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/DataStorage.h" #include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h" @@ -113,7 +114,6 @@ #include "mozilla/HangDetails.h" #include "nsAnonymousTemporaryFile.h" #include "nsAppRunner.h" -#include "nsCDefaultURIFixup.h" #include "nsCExternalHandlerService.h" #include "nsCOMPtr.h" #include "nsChromeRegistryChrome.h" @@ -180,7 +180,6 @@ #include "nsServiceManagerUtils.h" #include "nsStyleSheetService.h" #include "nsThreadUtils.h" -#include "nsToolkitCompsCID.h" #include "nsWidgetsCID.h" #include "PreallocatedProcessManager.h" #include "ProcessPriorityManager.h" @@ -3803,8 +3802,7 @@ mozilla::ipc::IPCResult ContentParent::RecvShowAlert( return IPC_OK(); } - nsCOMPtr sysAlerts( - do_GetService(NS_ALERTSERVICE_CONTRACTID)); + nsCOMPtr sysAlerts(components::Alerts::Service()); if (sysAlerts) { sysAlerts->ShowAlert(aAlert, this); } @@ -3817,8 +3815,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCloseAlert( return IPC_OK(); } - nsCOMPtr sysAlerts( - do_GetService(NS_ALERTSERVICE_CONTRACTID)); + nsCOMPtr sysAlerts(components::Alerts::Service()); if (sysAlerts) { sysAlerts->CloseAlert(aName, aPrincipal); } @@ -4120,7 +4117,7 @@ mozilla::ipc::IPCResult ContentParent::RecvKeywordToURI( *aPostData = nullptr; *aURI = void_t(); - nsCOMPtr fixup = do_GetService(NS_URIFIXUP_CONTRACTID); + nsCOMPtr fixup = components::URIFixup::Service(); if (!fixup) { return IPC_OK(); } diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 4fc3a35c5aaf..3c3c6a87e612 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -82,7 +82,6 @@ #include "nsIFrame.h" #include "nsIURI.h" #include "nsIURIFixup.h" -#include "nsCDefaultURIFixup.h" #include "nsIWebBrowser.h" #include "nsIWebProgress.h" #include "nsIXULRuntime.h" diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 7f492bc4fbcb..feb05b1d50aa 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/Notification.h" +#include "mozilla/Components.h" #include "mozilla/Encoding.h" #include "mozilla/EventStateManager.h" #include "mozilla/JSONWriter.h" @@ -55,7 +56,6 @@ #include "nsServiceManagerUtils.h" #include "nsStructuredCloneContainer.h" #include "nsThreadUtils.h" -#include "nsToolkitCompsCID.h" #include "nsXULAppAPI.h" namespace mozilla { @@ -653,8 +653,7 @@ void NotificationTelemetryService::RecordDNDSupported() { return; } - nsCOMPtr alertService = - do_GetService(NS_ALERTSERVICE_CONTRACTID); + nsCOMPtr alertService = components::Alerts::Service(); if (!alertService) { return; } @@ -1411,8 +1410,7 @@ void Notification::ShowInternal() { NS_WARNING("Could not persist Notification"); } - nsCOMPtr alertService = - do_GetService(NS_ALERTSERVICE_CONTRACTID); + nsCOMPtr alertService = components::Alerts::Service(); ErrorResult result; NotificationPermission permission = NotificationPermission::Denied; @@ -1952,8 +1950,7 @@ void Notification::CloseInternal() { SetAlertName(); UnpersistNotification(); if (!mIsClosed) { - nsCOMPtr alertService = - do_GetService(NS_ALERTSERVICE_CONTRACTID); + nsCOMPtr alertService = components::Alerts::Service(); if (alertService) { nsAutoString alertName; GetAlertName(alertName); diff --git a/dom/offline/nsDOMOfflineResourceList.cpp b/dom/offline/nsDOMOfflineResourceList.cpp index 4d1ea9e02273..3a44da3c92f7 100644 --- a/dom/offline/nsDOMOfflineResourceList.cpp +++ b/dom/offline/nsDOMOfflineResourceList.cpp @@ -7,9 +7,9 @@ #include "nsDOMOfflineResourceList.h" #include "nsIScriptSecurityManager.h" #include "nsError.h" +#include "mozilla/Components.h" #include "mozilla/dom/DOMStringList.h" #include "nsIPrefetchService.h" -#include "nsCPrefetchService.h" #include "nsMemory.h" #include "nsNetUtil.h" #include "nsNetCID.h" @@ -120,8 +120,8 @@ nsresult nsDOMOfflineResourceList::Init() { // Check for in-progress cache updates nsCOMPtr cacheUpdateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + components::OfflineCacheUpdate::Service(); + NS_ENSURE_TRUE(cacheUpdateService, NS_ERROR_UNEXPECTED); uint32_t numUpdates; rv = cacheUpdateService->GetNumUpdates(&numUpdates); @@ -497,9 +497,9 @@ void nsDOMOfflineResourceList::Update(ErrorResult& aRv) { } nsCOMPtr updateService = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.Throw(rv); + components::OfflineCacheUpdate::Service(); + if (NS_WARN_IF(!updateService)) { + aRv.Throw(NS_ERROR_UNEXPECTED); return; } diff --git a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp index 8a3dd16e65a2..dda1d13dea23 100644 --- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp @@ -109,6 +109,7 @@ NS_IMPL_ISUPPORTS(MulticastDNSDeviceProvider, nsIPresentationDeviceProvider, nsIDNSServiceResolveListener, nsIPresentationControlServerListener, nsIObserver) +MulticastDNSDeviceProvider::MulticastDNSDeviceProvider() {} MulticastDNSDeviceProvider::~MulticastDNSDeviceProvider() { Uninit(); } nsresult MulticastDNSDeviceProvider::Init() { diff --git a/dom/presentation/provider/MulticastDNSDeviceProvider.h b/dom/presentation/provider/MulticastDNSDeviceProvider.h index 11d50b555f1b..0707916148fb 100644 --- a/dom/presentation/provider/MulticastDNSDeviceProvider.h +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.h @@ -45,7 +45,7 @@ class MulticastDNSDeviceProvider final NS_DECL_NSIPRESENTATIONCONTROLSERVERLISTENER NS_DECL_NSIOBSERVER - explicit MulticastDNSDeviceProvider() = default; + explicit MulticastDNSDeviceProvider(); nsresult Init(); nsresult Uninit(); diff --git a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js index 874aad145578..3d1573247833 100644 --- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js +++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js @@ -25,9 +25,6 @@ function registerMockedFactory(contractId, mockedClassId, mockedFactory) { originalClassId = ""; originalFactory = null; } - if (originalFactory) { - registrar.unregisterFactory(originalClassId, originalFactory); - } registrar.registerFactory(mockedClassId, "", contractId, mockedFactory); } @@ -42,7 +39,9 @@ function registerOriginalFactory(contractId, mockedClassId, mockedFactory, origi if (originalFactory) { var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); registrar.unregisterFactory(mockedClassId, mockedFactory); - registrar.registerFactory(originalClassId, "", contractId, originalFactory); + // Passing null for the factory remaps the original CID to the + // contract ID. + registrar.registerFactory(originalClassId, "", contractId, null); } } diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index 47fdc7f47643..c66701d9f262 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -16,7 +16,6 @@ #include "nsContentUtils.h" #include "nsCORSListenerProxy.h" #include "nsIStreamListener.h" -#include "nsCDefaultURIFixup.h" #include "nsIURIFixup.h" #include "nsIImageLoadingContent.h" #include "nsIRedirectHistoryEntry.h" @@ -25,6 +24,7 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/nsMixedContentBlocker.h" #include "mozilla/dom/TabChild.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" NS_IMPL_ISUPPORTS(nsContentSecurityManager, nsIContentSecurityManager, @@ -380,8 +380,8 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel, // TYPE_DOCUMENT and TYPE_SUBDOCUMENT loads might potentially // be wyciwyg:// channels. Let's fix up the URI so we can // perform proper security checks. - nsCOMPtr urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv) && urifixup) { + nsCOMPtr urifixup(components::URIFixup::Service()); + if (urifixup) { nsCOMPtr fixedURI; rv = urifixup->CreateExposableURI(uri, getter_AddRefs(fixedURI)); if (NS_SUCCEEDED(rv)) { @@ -922,8 +922,8 @@ nsresult nsContentSecurityManager::CheckChannel(nsIChannel* aChannel) { // TYPE_DOCUMENT and TYPE_SUBDOCUMENT loads might potentially // be wyciwyg:// channels. Let's fix up the URI so we can // perform proper security checks. - nsCOMPtr urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv) && urifixup) { + nsCOMPtr urifixup(components::URIFixup::Service()); + if (urifixup) { nsCOMPtr fixedURI; rv = urifixup->CreateExposableURI(uri, getter_AddRefs(fixedURI)); if (NS_SUCCEEDED(rv)) { diff --git a/dom/system/nsOSPermissionRequestBase.h b/dom/system/nsOSPermissionRequestBase.h index 05eeee59a086..1707b089aaa1 100644 --- a/dom/system/nsOSPermissionRequestBase.h +++ b/dom/system/nsOSPermissionRequestBase.h @@ -10,14 +10,6 @@ #include "nsIOSPermissionRequest.h" #include "nsWeakReference.h" -#define NS_OSPERMISSIONREQUEST_CID \ - { \ - 0x95790842, 0x75a0, 0x430d, { \ - 0x98, 0xbf, 0xf5, 0xce, 0x37, 0x88, 0xea, 0x6d \ - } \ - } -#define NS_OSPERMISSIONREQUEST_CONTRACTID "@mozilla.org/ospermissionrequest;1" - namespace mozilla { namespace dom { class Promise; diff --git a/extensions/pref/autoconfig/src/nsReadConfig.cpp b/extensions/pref/autoconfig/src/nsReadConfig.cpp index 90c3f56714f0..c9b2144a81c7 100644 --- a/extensions/pref/autoconfig/src/nsReadConfig.cpp +++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp @@ -6,6 +6,7 @@ #include "nsReadConfig.h" #include "nsJSConfigTriggers.h" +#include "mozilla/Components.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIAppStartup.h" #include "nsContentUtils.h" @@ -18,13 +19,14 @@ #include "nsIPromptService.h" #include "nsIServiceManager.h" #include "nsIStringBundle.h" -#include "nsToolkitCompsCID.h" #include "nsNetUtil.h" #include "nsString.h" #include "nsCRT.h" #include "nspr.h" #include "nsXULAppAPI.h" +using namespace mozilla; + extern bool sandboxEnabled; extern mozilla::LazyLogModule MCD; @@ -101,7 +103,7 @@ NS_IMETHODIMP nsReadConfig::Observe(nsISupports *aSubject, const char *aTopic, rv = DisplayError(); if (NS_FAILED(rv)) { nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); + components::AppStartup::Service(); if (appStartup) appStartup->Quit(nsIAppStartup::eAttemptQuit); } } diff --git a/gfx/wr/wrench/reftests/text/raster-space-snap-ref.yaml b/gfx/wr/wrench/reftests/text/raster-space-snap-ref.yaml new file mode 100644 index 000000000000..43e4ccdf4697 --- /dev/null +++ b/gfx/wr/wrench/reftests/text/raster-space-snap-ref.yaml @@ -0,0 +1,10 @@ +root: + items: + - type: stacking-context + bounds: [0, 0, 480, 80] + raster-space: screen + items: + - text: "a Bcd Efgh Ijklm Nopqrs Tuvwxyz" + origin: 20.5 50 + size: 20 + font: "FreeSans.ttf" diff --git a/gfx/wr/wrench/reftests/text/raster-space-snap.yaml b/gfx/wr/wrench/reftests/text/raster-space-snap.yaml new file mode 100644 index 000000000000..4ae3f8c99f43 --- /dev/null +++ b/gfx/wr/wrench/reftests/text/raster-space-snap.yaml @@ -0,0 +1,10 @@ +root: + items: + - type: stacking-context + bounds: [0, 0, 480, 80] + raster-space: local(1.0) + items: + - text: "a Bcd Efgh Ijklm Nopqrs Tuvwxyz" + origin: 20.5 50 + size: 20 + font: "FreeSans.ttf" diff --git a/gfx/wr/wrench/reftests/text/reftest.list b/gfx/wr/wrench/reftests/text/reftest.list index dfd788616f1e..53b0cb7387fe 100644 --- a/gfx/wr/wrench/reftests/text/reftest.list +++ b/gfx/wr/wrench/reftests/text/reftest.list @@ -68,3 +68,4 @@ fuzzy(1,113) platform(linux) == raster-space.yaml raster-space.png == shadow-image.yaml shadow-solid-ref.yaml options(disable-aa) == snap-clip.yaml snap-clip-ref.yaml platform(linux) == perspective-clip.yaml perspective-clip.png +options(disable-subpixel) == raster-space-snap.yaml raster-space-snap-ref.yaml diff --git a/js/xpconnect/src/XPCModule.h b/js/xpconnect/src/XPCModule.h index a2b218eb9367..d53975075315 100644 --- a/js/xpconnect/src/XPCModule.h +++ b/js/xpconnect/src/XPCModule.h @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "xpcprivate.h" -#include "mozilla/ModuleUtils.h" #include "mozJSSubScriptLoader.h" /* Module implementation for the xpconnect library. */ @@ -22,16 +21,5 @@ #define MOZJSSUBSCRIPTLOADER_CONTRACTID "@mozilla.org/moz/jssubscript-loader;1" -NS_GENERIC_FACTORY_CONSTRUCTOR(mozJSSubScriptLoader) - -NS_DEFINE_NAMED_CID(MOZ_JSSUBSCRIPTLOADER_CID); - -#define XPCONNECT_CIDENTRIES \ - {&kMOZ_JSSUBSCRIPTLOADER_CID, false, nullptr, \ - mozJSSubScriptLoaderConstructor}, - -#define XPCONNECT_CONTRACTS \ - {MOZJSSUBSCRIPTLOADER_CONTRACTID, &kMOZ_JSSUBSCRIPTLOADER_CID}, - nsresult xpcModuleCtor(); void xpcModuleDtor(); diff --git a/js/xpconnect/src/components.conf b/js/xpconnect/src/components.conf new file mode 100644 index 000000000000..584d107781aa --- /dev/null +++ b/js/xpconnect/src/components.conf @@ -0,0 +1,14 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{929814d6-1dd2-11b2-8e08-82fa0a339b00}', + 'contract_ids': ['@mozilla.org/moz/jssubscript-loader;1'], + 'type': 'mozJSSubScriptLoader', + 'headers': ['/js/xpconnect/loader/mozJSSubScriptLoader.h'], + }, +] diff --git a/js/xpconnect/src/moz.build b/js/xpconnect/src/moz.build index c128fb33d566..edf569255cb7 100644 --- a/js/xpconnect/src/moz.build +++ b/js/xpconnect/src/moz.build @@ -44,6 +44,10 @@ UNIFIED_SOURCES += [ 'XPCWrapper.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index b8580ac627ba..6e66b735924a 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -45,6 +45,7 @@ #include "mozilla/PendingAnimationTracker.h" #include "mozilla/PendingFullscreenEvent.h" #include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" #include "nsViewManager.h" #include "GeckoProfiler.h" #include "nsNPAPIPluginInstance.h" @@ -256,6 +257,19 @@ class RefreshDriverTimer { return nextTick < TimeStamp::Now() ? Nothing() : Some(nextTick); } + // Returns null if the RefreshDriverTimer is attached to several + // RefreshDrivers. That may happen for example when there are + // several windows open. + nsPresContext* GetPresContextForOnlyRefreshDriver() { + if (mRootRefreshDrivers.Length() == 1 && mContentRefreshDrivers.IsEmpty()) { + return mRootRefreshDrivers[0]->GetPresContext(); + } + if (mContentRefreshDrivers.Length() == 1 && mRootRefreshDrivers.IsEmpty()) { + return mContentRefreshDrivers[0]->GetPresContext(); + } + return nullptr; + } + protected: virtual ~RefreshDriverTimer() { MOZ_ASSERT( @@ -543,6 +557,37 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer { return true; } + if (StaticPrefs::layout_lower_priority_refresh_driver_during_load()) { + nsPresContext* pctx = + mVsyncRefreshDriverTimer->GetPresContextForOnlyRefreshDriver(); + if (pctx && pctx->HadContentfulPaint() && pctx->Document() && + pctx->Document()->GetReadyStateEnum() < + Document::READYSTATE_COMPLETE) { + nsPIDOMWindowInner* win = pctx->Document()->GetInnerWindow(); + if (win) { + dom::Performance* perf = win->GetPerformance(); + // Limit slower refresh rate to 5 seconds between the + // first contentful paint and page load. + if (perf && perf->Now() < 5000) { + if (mProcessedVsync) { + mProcessedVsync = false; + // Handle this case similarly to the code above, but just + // use idle queue. + TimeDuration rate = mVsyncRefreshDriverTimer->GetTimerRate(); + uint32_t slowRate = + static_cast(rate.ToMilliseconds() * 4); + nsCOMPtr vsyncEvent = NewRunnableMethod<>( + "RefreshDriverVsyncObserver::NormalPriorityNotify[IDLE]", + this, &RefreshDriverVsyncObserver::NormalPriorityNotify); + NS_DispatchToCurrentThreadQueue(vsyncEvent.forget(), slowRate, + EventQueuePriority::Idle); + } + return true; + } + } + } + } + RefPtr kungFuDeathGrip(this); TickRefreshDriver(aVsync.mId, aVsync.mTime); } @@ -1728,7 +1773,23 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) { // situation we don't want to thrash our timer. So instead we // wait until we get a Notify() call when we have no observers // before stopping the timer. - StopTimer(); + // On top level content pages keep the timer running initially so that we + // paint the page soon enough. + if (!XRE_IsContentProcess() || !presShell || mTestControllingRefreshes || + !mPresContext->Document()->IsTopLevelContentDocument() || mThrottled || + gfxPlatform::IsInLayoutAsapMode()) { + StopTimer(); + } else if (mPresContext->Document()->GetReadyStateEnum() < + Document::READYSTATE_COMPLETE && + !mPresContext->HadContentfulPaint()) { + if (mInitialTimerRunningLimit.IsNull()) { + mInitialTimerRunningLimit = + TimeStamp::Now() + TimeDuration::FromSeconds(4.0f); + // Don't let the timer to run forever, so limit to 4s for now. + } else if (mInitialTimerRunningLimit < TimeStamp::Now()) { + StopTimer(); + } + } return; } diff --git a/layout/base/nsRefreshDriver.h b/layout/base/nsRefreshDriver.h index 5e5802944167..7966ed05b986 100644 --- a/layout/base/nsRefreshDriver.h +++ b/layout/base/nsRefreshDriver.h @@ -539,6 +539,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator, mozilla::TimeStamp mTickVsyncTime; mozilla::TimeStamp mNextThrottledFrameRequestTick; mozilla::TimeStamp mNextRecomputeVisibilityTick; + mozilla::TimeStamp mInitialTimerRunningLimit; // separate arrays for each flush type we support ObserverArray mObservers[4]; diff --git a/layout/build/components.conf b/layout/build/components.conf new file mode 100644 index 000000000000..eafd849dcdc0 --- /dev/null +++ b/layout/build/components.conf @@ -0,0 +1,458 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Headers = [ + '/layout/build/nsLayoutModule.h', +] + +UnloadFunc = 'nsLayoutModuleDtor' + +# This module's unload function needs to be called as late as possible. +Priority = 100 + +content_types = [ + 'application/ecmascript', + 'application/javascript', + 'application/json', + 'application/mathml+xml', + 'application/rdf+xml', + 'application/vnd.mozilla.xul+xml', + 'application/vnd.wap.xhtml+xml', + 'application/x-javascript', + 'application/x-view-source', + 'application/xhtml+xml', + 'application/xml', + 'image/svg+xml', + 'mozilla.application/cached-xul', + 'text/cache-manifest', + 'text/css', + 'text/ecmascript', + 'text/html', + 'text/javascript', + 'text/json', + 'text/plain', + 'text/rdf', + 'text/vtt', + 'text/xml', +] + +if defined('MOZ_WEBM'): + content_types += [ + "audio/webm", + "video/webm", + ] + +Classes = [ + { + 'cid': '{1691e1f4-ee41-11d4-9885-00c04fa0cf4b}', + 'type': 'nsIFrameTraversal', + }, + { + 'cid': '{574ce83e-fe9f-4095-b85c-7909abbf7c37}', + 'type': 'nsJSURI::Mutator', + 'headers': ['nsJSProtocolHandler.h'], + }, + { + 'cid': '{58f089ee-512a-42d2-a935-d0c874128930}', + 'type': 'nsJSURI::Mutator', + 'headers': ['nsJSProtocolHandler.h'], + }, + { + 'cid': '{972d8d8f-f0da-11d4-9885-00c04fa0cf4b}', + 'type': 'nsIContentViewer', + }, + { + 'cid': '{bbe50ef2-80eb-469d-b70d-02858275389f}', + 'type': 'mozilla::dom::BlobURL::Mutator', + 'headers': ['mozilla/dom/BlobURL.h'], + }, + { + 'cid': '{f5475c51-59a7-4757-b3d9-e211a9410872}', + 'type': 'mozilla::dom::BlobURL::Mutator', + 'headers': ['mozilla/dom/BlobURL.h'], + }, + { + 'cid': '{fe0ff7c3-8e97-448b-9a8a-86afdb9fbbb6}', + 'contract_ids': ['@mozilla.org/childprocessmessagemanager;1'], + 'legacy_constructor': 'CreateChildMessageManager', + }, + { + 'cid': '{fc886801-e768-11d4-9885-00c04fa0cf4b}', + 'contract_ids': ['@mozilla.org/content/document-loader-factory;1'], + 'type': 'nsIDocumentLoaderFactory', + 'categories': {'Gecko-Content-Viewers': content_types}, + }, + { + 'cid': '{0ddf4df8-4dbb-4133-8b79-9afb966514f5}', + 'contract_ids': ['@mozilla.org/content/plugin/document-loader-factory;1'], + 'type': 'nsIDocumentLoaderFactory', + }, + { + 'cid': '{3b55e72e-ab7e-431b-89c0-3b06a8b14016}', + 'contract_ids': ['@mozilla.org/content/style-sheet-service;1'], + 'type': 'nsStyleSheetService', + 'headers': ['nsStyleSheetService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{cdcc1ab8-3cea-4e6c-a294-a651fa35227f}', + 'contract_ids': ['@mozilla.org/contentsecuritymanager;1'], + 'type': 'nsContentSecurityManager', + 'headers': ['mozilla/dom/nsContentSecurityManager.h'], + }, + { + 'cid': '{09d9ed1a-e5d4-4004-bfe0-27ceb923d9ac}', + 'contract_ids': ['@mozilla.org/cspcontext;1'], + 'type': 'nsCSPContext', + 'headers': ['mozilla/dom/nsCSPContext.h'], + }, + { + 'cid': '{8d2f40b2-4875-4c95-97d9-3f7dca2cb460}', + 'contract_ids': ['@mozilla.org/cspservice;1'], + 'type': 'CSPService', + 'headers': ['mozilla/dom/nsCSPService.h'], + 'categories': {'content-policy': 'CSPService', 'net-channel-event-sinks': 'CSPService'}, + }, + { + 'cid': '{1147d32c-215b-4014-b180-07fe7aedf915}', + 'contract_ids': ['@mozilla.org/data-document-content-policy;1'], + 'type': 'nsDataDocumentContentPolicy', + 'headers': ['/dom/base/nsDataDocumentContentPolicy.h'], + 'categories': {'content-policy': '@mozilla.org/data-document-content-policy;1'}, + }, + { + 'cid': '{ecba5203-77da-465a-865e-78b7af10d8f7}', + 'contract_ids': ['@mozilla.org/devicesensors;1'], + 'type': 'nsDeviceSensors', + 'headers': ['nsDeviceSensors.h'], + }, + { + 'cid': '{38bd0634-0fd4-46f0-b85f-13ced889eeec}', + 'contract_ids': ['@mozilla.org/docshell/structured-clone-container;1'], + 'type': 'nsStructuredCloneContainer', + 'headers': ['nsStructuredCloneContainer.h'], + }, + { + 'cid': '{3160e271-138d-4cc7-9d63-6429f16957c7}', + 'contract_ids': ['@mozilla.org/dom/dom-request-service;1'], + 'singleton': True, + 'type': 'mozilla::dom::DOMRequestService', + 'headers': ['mozilla/dom/DOMRequest.h'], + 'constructor': 'mozilla::dom::DOMRequestService::FactoryCreate', + }, + { + 'cid': '{656db07c-aa80-49e4-bce8-e431baae697d}', + 'contract_ids': ['@mozilla.org/dom/localStorage-manager;1'], + 'legacy_constructor': 'LocalStorageManagerConstructor', + }, + { + 'cid': '{5a75c25a-5e7e-4d90-8f7c-07eb15cc0aa8}', + 'contract_ids': ['@mozilla.org/dom/quota-manager-service;1'], + 'singleton': True, + 'type': 'mozilla::dom::quota::QuotaManagerService', + 'headers': ['mozilla/dom/quota/QuotaManagerService.h'], + 'constructor': 'mozilla::dom::quota::QuotaManagerService::FactoryCreate', + 'categories': {'idle-daily': 'QuotaManagerService'}, + }, + { + 'cid': '{ae2793c0-2ba3-4adb-9c5e-c23525812c64}', + 'contract_ids': ['@mozilla.org/dom/sdb-connection;1'], + 'legacy_constructor': 'mozilla::dom::SDBConnection::Create', + 'headers': ['mozilla/dom/SDBConnection.h'], + }, + { + 'cid': '{62ec8731-55ad-4246-b2ea-f26c1fe19d2d}', + 'contract_ids': ['@mozilla.org/dom/workers/workerdebuggermanager;1'], + 'singleton': True, + 'type': 'mozilla::dom::WorkerDebuggerManager', + 'headers': ['mozilla/dom/WorkerDebuggerManager.h'], + 'constructor': 'mozilla::dom::WorkerDebuggerManager::GetInstance', + }, + { + 'cid': '{baa34652-f1f1-4185-b224-244ee82a413a}', + 'contract_ids': ['@mozilla.org/eventlistenerservice;1'], + 'type': 'nsIEventListenerService', + }, + { + 'cid': '{e8ee88b0-5571-4086-a45b-39a716906bdb}', + 'contract_ids': ['@mozilla.org/expandedprincipal;1'], + 'type': 'ExpandedPrincipal', + 'headers': ['/caps/ExpandedPrincipal.h'], + }, + { + 'cid': '{cf7fd51f-aba2-44c1-9ff0-11f7508efcd4}', + 'contract_ids': ['@mozilla.org/focus-manager;1'], + 'type': 'nsIFocusManager', + }, + { + 'cid': '{7b121f7e-ebe4-43ab-9410-dc9087a1dba6}', + 'contract_ids': ['@mozilla.org/gecko-media-plugin-service;1'], + 'singleton': True, + 'type': 'mozilla::gmp::GeckoMediaPluginService', + 'headers': ['GMPService.h'], + 'constructor': 'mozilla::gmp::GeckoMediaPluginService::GetGeckoMediaPluginService', + }, + { + 'cid': '{01e1c3ff-094a-d048-44b4-62d29c7b4f39}', + 'contract_ids': ['@mozilla.org/geolocation;1'], + 'singleton': True, + 'type': 'mozilla::dom::Geolocation', + 'headers': ['/dom/geolocation/nsGeolocation.h'], + 'constructor': 'mozilla::dom::Geolocation::NonWindowSingleton', + }, + { + 'cid': '{130b016f-fad7-4526-bc7f-827dabf79265}', + 'contract_ids': ['@mozilla.org/globalmessagemanager;1'], + 'legacy_constructor': 'CreateGlobalMessageManager', + }, + { + 'cid': '{bfcb82c2-5611-4318-90d6-baf4a7864252}', + 'contract_ids': ['@mozilla.org/inspector/deep-tree-walker;1'], + 'type': 'inDeepTreeWalker', + 'headers': ['/layout/inspector/inDeepTreeWalker.h'], + }, + { + 'cid': '{0e3afd3d-eb60-4c2b-963b-56d7c439f124}', + 'contract_ids': ['@mozilla.org/layout/content-policy;1'], + 'legacy_constructor': 'CreateContentPolicy', + }, + { + 'cid': '{4aef38b7-6364-4e23-a5e7-12f837fbbd9c}', + 'contract_ids': [ + '@mozilla.org/layout/contentserializer;1?mimetype=application/vnd.mozilla.xul+xml', + '@mozilla.org/layout/contentserializer;1?mimetype=application/xml', + '@mozilla.org/layout/contentserializer;1?mimetype=image/svg+xml', + '@mozilla.org/layout/contentserializer;1?mimetype=text/xml', + ], + 'type': 'nsIContentSerializer', + 'legacy_constructor': 'CreateXMLContentSerializer', + }, + { + 'cid': '{e7c2aaf5-c11a-4954-9dbf-e28edec1fd91}', + 'contract_ids': ['@mozilla.org/layout/contentserializer;1?mimetype=application/xhtml+xml'], + 'legacy_constructor': 'CreateXHTMLContentSerializer', + }, + { + 'cid': '{9d3f70da-86e9-11d4-95ec-00b0d03e37b7}', + 'contract_ids': ['@mozilla.org/layout/contentserializer;1?mimetype=text/html'], + 'type': 'nsIContentSerializer', + 'legacy_constructor': 'CreateHTMLContentSerializer', + }, + { + 'cid': '{6030f7ef-32ed-46a7-9a63-6a5d3f90445f}', + 'contract_ids': ['@mozilla.org/layout/contentserializer;1?mimetype=text/plain'], + 'legacy_constructor': 'CreatePlainTextSerializer', + }, + { + 'cid': '{abc622ea-9655-4123-80d9-22621bdd5465}', + 'contract_ids': ['@mozilla.org/mediaManagerService;1'], + 'singleton': True, + 'type': 'nsIMediaManagerService', + 'headers': ['mozilla/MediaManager.h'], + 'constructor': 'mozilla::MediaManager::GetInstance', + }, + { + 'cid': '{daf1461b-bf29-4f88-8d0e-4bcdf332c862}', + 'contract_ids': ['@mozilla.org/mixedcontentblocker;1'], + 'type': 'nsMixedContentBlocker', + 'headers': ['mozilla/dom/nsMixedContentBlocker.h'], + 'categories': { + 'content-policy': '@mozilla.org/mixedcontentblocker;1', + 'net-channel-event-sinks': '@mozilla.org/mixedcontentblocker;1', + }, + }, + { + 'cid': '{4bbe1b96-8956-457f-a03f-9c27435f2afa}', + 'contract_ids': ['@mozilla.org/net/osfileconstantsservice;1'], + 'singleton': True, + 'type': 'mozilla::OSFileConstantsService', + 'headers': ['mozilla/OSFileConstants.h'], + 'constructor': 'mozilla::OSFileConstantsService::GetOrCreate', + }, + { + 'cid': '{bfc310d2-38a0-11d3-8cd3-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=javascript'], + 'legacy_constructor': 'nsJSProtocolHandler::Create', + 'headers': ['nsJSProtocolHandler.h'], + }, + { + 'cid': '{ac9e3e82-bfbd-4f26-941e-f58c8ee178c1}', + 'contract_ids': ['@mozilla.org/no-data-protocol-content-policy;1'], + 'type': 'nsNoDataProtocolContentPolicy', + 'headers': ['/dom/base/nsNoDataProtocolContentPolicy.h'], + 'categories': {'content-policy': '@mozilla.org/no-data-protocol-content-policy;1'}, + }, + { + 'cid': '{5995b782-6a0e-4066-aac5-276f0a9ad8cf}', + 'contract_ids': ['@mozilla.org/notificationTelemetryService;1'], + 'type': 'mozilla::dom::NotificationTelemetryService', + 'headers': ['mozilla/dom/Notification.h'], + 'init_method': 'Init', + }, + { + 'cid': '{bd066e5f-146f-4472-8331-7bfd05b1ed90}', + 'contract_ids': ['@mozilla.org/nullprincipal;1'], + 'type': 'mozilla::NullPrincipal', + 'headers': ['/caps/NullPrincipal.h'], + 'init_method': 'Init', + }, + { + 'cid': '{2a058404-fb85-44ec-8cfd-e8cbdc988dc1}', + 'contract_ids': ['@mozilla.org/parentprocessmessagemanager;1'], + 'legacy_constructor': 'CreateParentMessageManager', + }, + { + 'cid': '{af7b24cb-893f-41bb-961f-5a69388e27c3}', + 'contract_ids': ['@mozilla.org/parserutils;1'], + 'type': 'nsParserUtils', + 'headers': ['nsParserUtils.h'], + }, + { + 'cid': '{e1e79dec-4085-4994-ac5b-744b016697e6}', + 'contract_ids': ['@mozilla.org/presentation-device/manager;1'], + 'type': 'mozilla::dom::PresentationDeviceManager', + 'headers': ['mozilla/dom/PresentationDeviceManager.h'], + 'categories': {'profile-after-change': 'PresentationDeviceManager'}, + }, + { + 'cid': '{1d9bb10c-c0ab-4fe8-9e4f-4058b8519832}', + 'contract_ids': ['@mozilla.org/presentation/presentationservice;1'], + 'singleton': True, + 'type': 'nsIPresentationService', + 'constructor': 'NS_CreatePresentationService', + 'headers': ['nsIPresentationService.h', '/layout/build/nsLayoutModule.h'], + 'categories': {'profile-after-change': 'PresentationService'}, + }, + { + 'cid': '{c9d023f4-6228-4c07-8b1d-9c19573faa27}', + 'contract_ids': ['@mozilla.org/presentation/presentationtcpsessiontransport;1'], + 'type': 'mozilla::dom::PresentationTCPSessionTransport', + 'headers': ['mozilla/dom/PresentationTCPSessionTransport.h'], + }, + { + 'cid': '{653e0e4d-3ee4-45fa-b272-97c20bc01eb8}', + 'contract_ids': ['@mozilla.org/principal;1'], + 'type': 'mozilla::ContentPrincipal', + 'headers': ['/caps/ContentPrincipal.h'], + }, + { + 'cid': '{2fc2d3e3-020f-404e-b06a-6ecf3ea2334a}', + 'contract_ids': ['@mozilla.org/push/Notifier;1'], + 'type': 'mozilla::dom::PushNotifier', + 'headers': ['mozilla/dom/PushNotifier.h'], + }, + { + 'cid': '{f68037ec-2790-44c5-8e5f-df5da58b93a7}', + 'contract_ids': ['@mozilla.org/scriptable-content-iterator;1'], + 'type': 'ScriptableContentIterator', + 'headers': ['mozilla/ScriptableContentIterator.h'], + }, + { + 'cid': '{1950539a-90f0-4d22-b5af-71329c68fa35}', + 'contract_ids': ['@mozilla.org/scripterror;1'], + 'type': 'nsScriptError', + 'headers': ['/dom/bindings/nsScriptError.h'], + }, + { + 'cid': '{7ee2a4c0-4b93-17d3-ba18-0060b0f199a2}', + 'contract_ids': ['@mozilla.org/scriptsecuritymanager;1'], + 'legacy_constructor': 'Construct_nsIScriptSecurityManager', + }, + { + 'cid': '{c74bde32-bcc7-4840-8430-c733351b212a}', + 'contract_ids': ['@mozilla.org/serviceworkers/manager;1'], + 'singleton': True, + 'type': 'mozilla::dom::ServiceWorkerManager', + 'headers': ['mozilla/dom/ServiceWorkerManager.h'], + 'constructor': 'mozilla::dom::ServiceWorkerManager::GetInstance', + }, + { + 'cid': '{69da374a-fda3-4a93-9fbc-d9304f66a7fe}', + 'contract_ids': ['@mozilla.org/storage/activity-service;1'], + 'singleton': True, + 'type': 'mozilla::dom::StorageActivityService', + 'headers': ['mozilla/StaticPtr.h', 'mozilla/dom/StorageActivityService.h'], + 'constructor': 'mozilla::dom::StorageActivityService::GetOrCreate', + }, + { + 'cid': '{4a6212db-accb-11d3-b765-0060b0b6cecb}', + 'contract_ids': ['@mozilla.org/systemprincipal;1'], + 'singleton': True, + 'type': 'nsIPrincipal', + 'headers': ['nsScriptSecurityManager.h', '/caps/SystemPrincipal.h'], + 'constructor': 'nsScriptSecurityManager::SystemPrincipalSingletonConstructor', + }, + { + 'cid': '{caaab47f-1e31-478e-8919-970904e9cb72}', + 'contract_ids': ['@mozilla.org/text-input-processor;1'], + 'type': 'mozilla::TextInputProcessor', + 'headers': ['mozilla/TextInputProcessor.h'], + }, + { + 'cid': '{08c6cc8b-cfb0-421d-b1f7-683ff2989681}', + 'contract_ids': ['@mozilla.org/thirdpartyutil;1'], + 'type': 'ThirdPartyUtil', + 'headers': ['/dom/base/ThirdPartyUtil.h'], + 'init_method': 'Init', + }, + { + 'cid': '{31689828-da66-49a6-870c-df62b83fe789}', + 'contract_ids': ['@mozilla.org/websocketevent/service;1'], + 'singleton': True, + 'type': 'mozilla::net::WebSocketEventService', + 'headers': ['mozilla/net/WebSocketEventService.h'], + 'constructor': 'mozilla::net::WebSocketEventService::GetOrCreate', + }, +] + +if defined('DEBUG'): + Classes += [ + { + 'cid': '{NS_LAYOUT_DEBUGGER_CID}', + 'type': 'nsILayoutDebugger', + }, + ] + +if defined('MOZ_WEBSPEECH'): + Classes += [ + { + 'cid': '{7090524d-5574-4492-a77f-d8d558ced59d}', + 'contract_ids': ['@mozilla.org/synth-voice-registry;1'], + 'singleton': True, + 'type': 'mozilla::dom::nsSynthVoiceRegistry', + 'headers': ['mozilla/dom/nsSynthVoiceRegistry.h'], + 'constructor': 'mozilla::dom::nsSynthVoiceRegistry::GetInstanceForService', + }, + ] + +if defined('MOZ_WEBSPEECH_TEST_BACKEND'): + Classes += [ + { + 'cid': '{48c345e7-9929-4f9a-a563-f478222dabcd}', + 'contract_ids': ['@mozilla.org/webspeech/service;1?name=fake'], + 'type': 'mozilla::FakeSpeechRecognitionService', + 'headers': ['mozilla/dom/FakeSpeechRecognitionService.h'], + }, + ] + +if defined('ACCESSIBILITY'): + Classes += [ + { + 'cid': '{3b265b69-f813-48ff-880d-d88d101af404}', + 'contract_ids': ['@mozilla.org/accessibilityService;1'], + 'type': 'nsIAccessibilityService', + }, + ] + +if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'android': + Classes += [ + { + 'cid': '{1f15dbc8-bfaa-45de-8a46-08e2e26326b0}', + 'contract_ids': ['@mozilla.org/widget/hapticfeedback;1'], + 'type': 'nsHapticFeedback', + 'headers': ['/dom/system/android/nsHapticFeedback.h'], + }, + ] diff --git a/layout/build/moz.build b/layout/build/moz.build index 7ec0c755f072..d8750a792a89 100644 --- a/layout/build/moz.build +++ b/layout/build/moz.build @@ -71,11 +71,9 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': '/dom/system/android', ] -if CONFIG['MOZ_WEBSPEECH']: - LOCAL_INCLUDES += [ - '/dom/media/webspeech/recognition', - '/dom/media/webspeech/synth', - ] +XPCOM_MANIFESTS += [ + 'components.conf', +] FINAL_LIBRARY = 'xul' diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index c0563dadc618..d009a8e2d67c 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "XPCModule.h" +#include "mozilla/Components.h" #include "mozilla/ModuleUtils.h" #include "nsImageModule.h" #include "nsLayoutStatics.h" @@ -19,63 +20,30 @@ #include "nsFrameMessageManager.h" #include "nsHTMLContentSerializer.h" #include "nsHTMLParts.h" -#include "nsIComponentManager.h" #include "nsIContentSerializer.h" #include "nsIContentViewer.h" -#include "nsIController.h" -#include "nsIControllers.h" -#include "nsIFactory.h" -#include "nsIIdleService.h" -#include "nsHTMLStyleSheet.h" #include "nsILayoutDebugger.h" -#include "nsNameSpaceManager.h" -#include "nsIObserver.h" -#include "nsIObserverService.h" -#include "nsIScriptError.h" -#include "nsCaret.h" #include "nsPlainTextSerializer.h" #include "nsXMLContentSerializer.h" #include "nsXHTMLContentSerializer.h" -#include "nsContentAreaDragDrop.h" #include "nsIFrameTraversal.h" #include "nsLayoutCID.h" -#include "nsStyleSheetService.h" #include "nsFocusManager.h" #include "ThirdPartyUtil.h" -#include "nsStructuredCloneContainer.h" #include "gfxPlatform.h" #include "mozilla/gfx/gfxVars.h" +#include "mozilla/dom/quota/QuotaManagerService.h" #include "nsIEventListenerService.h" #include "nsIMessageManager.h" -// Transformiix stuff -#include "mozilla/dom/XPathEvaluator.h" - // view stuff #include "nsContentCreatorFunctions.h" -#include "nsGlobalWindowCommands.h" -#include "nsJSProtocolHandler.h" -#include "nsIControllerContext.h" -#include "nsZipArchive.h" -#include "mozilla/Attributes.h" -#include "mozilla/dom/BlobURL.h" -#include "mozilla/dom/DOMRequest.h" -#include "mozilla/dom/SDBConnection.h" #include "mozilla/dom/LocalStorageCommon.h" #include "mozilla/dom/LocalStorageManager.h" #include "mozilla/dom/LocalStorageManager2.h" -#include "mozilla/dom/quota/QuotaManagerService.h" -#include "mozilla/dom/ServiceWorkerManager.h" -#include "mozilla/dom/StorageActivityService.h" -#include "mozilla/dom/WorkerDebuggerManager.h" -#include "mozilla/dom/Notification.h" -#include "mozilla/OSFileConstants.h" -#ifdef MOZ_WEBSPEECH_TEST_BACKEND -# include "mozilla/dom/FakeSpeechRecognitionService.h" -#endif #ifdef MOZ_WEBSPEECH # include "mozilla/dom/nsSynthVoiceRegistry.h" #endif @@ -89,22 +57,13 @@ using mozilla::dom::PushNotifier; } \ } -// Editor stuff -#include "mozilla/EditorController.h" //CID - #include "nsScriptSecurityManager.h" -#include "ExpandedPrincipal.h" -#include "mozilla/ContentPrincipal.h" -#include "mozilla/NullPrincipal.h" -#include "mozilla/SystemPrincipal.h" #include "nsNetCID.h" #if defined(MOZ_WIDGET_ANDROID) # include "nsHapticFeedback.h" #endif #include "nsParserUtils.h" -#include "nsHTMLCanvasFrame.h" - class nsIDocumentLoaderFactory; #define PRODUCT_NAME "Gecko" @@ -121,101 +80,11 @@ class nsIDocumentLoaderFactory; static void Shutdown(); -#include "nsGeolocation.h" -#include "nsDeviceSensors.h" #include "mozilla/dom/nsContentSecurityManager.h" -#include "mozilla/dom/nsCSPService.h" -#include "mozilla/dom/nsCSPContext.h" -#include "nsIMediaManager.h" -#include "mozilla/dom/nsMixedContentBlocker.h" - -#include "mozilla/net/WebSocketEventService.h" - -#include "nsIPresentationService.h" - -#include "MediaManager.h" - -#include "GMPService.h" - -#include "mozilla/dom/PresentationDeviceManager.h" -#include "mozilla/dom/PresentationTCPSessionTransport.h" - -#include "nsScriptError.h" -#include "nsBaseCommandController.h" -#include "nsControllerCommandTable.h" - -#include "mozilla/TextInputProcessor.h" -#include "mozilla/ScriptableContentIterator.h" using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::net; -using mozilla::dom::quota::QuotaManagerService; -using mozilla::gmp::GeckoMediaPluginService; - -#define NS_HAPTICFEEDBACK_CID \ - { \ - 0x1f15dbc8, 0xbfaa, 0x45de, { \ - 0x8a, 0x46, 0x08, 0xe2, 0xe2, 0x63, 0x26, 0xb0 \ - } \ - } - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils) - -// PresentationDeviceManager -/* e1e79dec-4085-4994-ac5b-744b016697e6 */ -#define PRESENTATION_DEVICE_MANAGER_CID \ - { \ - 0xe1e79dec, 0x4085, 0x4994, { \ - 0xac, 0x5b, 0x74, 0x4b, 0x01, 0x66, 0x97, 0xe6 \ - } \ - } - -#define PRESENTATION_TCP_SESSION_TRANSPORT_CID \ - { \ - 0xc9d023f4, 0x6228, 0x4c07, { \ - 0x8b, 0x1d, 0x9c, 0x19, 0x57, 0x3f, 0xaa, 0x27 \ - } \ - } - -already_AddRefed NS_CreatePresentationService(); - -// Factory Constructor -typedef mozilla::dom::BlobURL::Mutator BlobURLMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(BlobURLMutator) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService, - DOMRequestService::FactoryCreate) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManagerService, - QuotaManagerService::FactoryCreate) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager, - ServiceWorkerManager::GetInstance) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WorkerDebuggerManager, - WorkerDebuggerManager::GetInstance) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(StorageActivityService, - StorageActivityService::GetOrCreate) - -#ifdef MOZ_WEBSPEECH -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - nsSynthVoiceRegistry, nsSynthVoiceRegistry::GetInstanceForService) -#endif - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceSensors) - -#if defined(ANDROID) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback) -#endif -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init) - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMediaManagerService, - MediaManager::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationDeviceManager) -NS_GENERIC_FACTORY_CONSTRUCTOR(TextInputProcessor) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPresentationService, - NS_CreatePresentationService) -NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationTCPSessionTransport) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NotificationTelemetryService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(PushNotifier) -NS_GENERIC_FACTORY_CONSTRUCTOR(ScriptableContentIterator) //----------------------------------------------------------------------------- @@ -271,43 +140,39 @@ nsresult NS_NewGlobalMessageManager(nsISupports** aResult); nsresult NS_NewParentProcessMessageManager(nsISupports** aResult); nsresult NS_NewChildProcessMessageManager(nsISupports** aResult); -#define MAKE_CTOR(ctor_, iface_, func_) \ - static nsresult ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) { \ - *aResult = nullptr; \ - if (aOuter) return NS_ERROR_NO_AGGREGATION; \ - iface_* inst; \ - nsresult rv = func_(&inst); \ - if (NS_SUCCEEDED(rv)) { \ - rv = inst->QueryInterface(aIID, aResult); \ - NS_RELEASE(inst); \ - } \ - return rv; \ +#define MAKE_CTOR(ctor_, iface_, func_) \ + nsresult ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) { \ + *aResult = nullptr; \ + if (aOuter) return NS_ERROR_NO_AGGREGATION; \ + iface_* inst; \ + nsresult rv = func_(&inst); \ + if (NS_SUCCEEDED(rv)) { \ + rv = inst->QueryInterface(aIID, aResult); \ + NS_RELEASE(inst); \ + } \ + return rv; \ } -// As above, but expects -// already_AddRefed NS_NewFoo(); -// instead of -// nsresult NS_NewFoo(nsIFoo**); -#define MAKE_CTOR2(ctor_, iface_, func_) \ - static nsresult ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) { \ - *aResult = nullptr; \ - if (aOuter) { \ - return NS_ERROR_NO_AGGREGATION; \ - } \ - nsCOMPtr inst = func_(); \ - inst.forget(aResult); \ - return NS_OK; \ +#define MAKE_GENERIC_CTOR(iface_, func_) \ + NS_IMPL_COMPONENT_FACTORY(iface_) { \ + nsCOMPtr inst; \ + if (NS_SUCCEEDED(func_(getter_AddRefs(inst)))) { \ + return inst.forget(); \ + } \ + return nullptr; \ } +#define MAKE_GENERIC_CTOR2(iface_, func_) \ + NS_IMPL_COMPONENT_FACTORY(iface_) { return func_(); } + #ifdef DEBUG -MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLayoutDebugger) +MAKE_GENERIC_CTOR(nsILayoutDebugger, NS_NewLayoutDebugger) #endif -MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTraversal) +MAKE_GENERIC_CTOR(nsIFrameTraversal, NS_CreateFrameTraversal) -NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker) +MAKE_GENERIC_CTOR2(nsIContentViewer, NS_NewContentViewer) -MAKE_CTOR2(CreateContentViewer, nsIContentViewer, NS_NewContentViewer) MAKE_CTOR(CreateXMLContentSerializer, nsIContentSerializer, NS_NewXMLContentSerializer) MAKE_CTOR(CreateHTMLContentSerializer, nsIContentSerializer, @@ -317,23 +182,16 @@ MAKE_CTOR(CreateXHTMLContentSerializer, nsIContentSerializer, MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer, NS_NewPlainTextSerializer) MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy) -MAKE_CTOR(CreateContentDLF, nsIDocumentLoaderFactory, - NS_NewContentDocumentLoaderFactory) -MAKE_CTOR(CreateEventListenerService, nsIEventListenerService, - NS_NewEventListenerService) + +MAKE_GENERIC_CTOR(nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory) +MAKE_GENERIC_CTOR(nsIEventListenerService, NS_NewEventListenerService) MAKE_CTOR(CreateGlobalMessageManager, nsISupports, NS_NewGlobalMessageManager) MAKE_CTOR(CreateParentMessageManager, nsISupports, NS_NewParentProcessMessageManager) MAKE_CTOR(CreateChildMessageManager, nsISupports, NS_NewChildProcessMessageManager) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy) -MAKE_CTOR(CreateFocusManager, nsIFocusManager, NS_NewFocusManager) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init) - -typedef nsJSURI::Mutator nsJSURIMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURIMutator) +MAKE_GENERIC_CTOR(nsIFocusManager, NS_NewFocusManager) // views are not refcounted, so this is the same as // NS_GENERIC_FACTORY_CONSTRUCTOR without the NS_ADDREF/NS_RELEASE @@ -358,62 +216,14 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURIMutator) return rv; \ } -#define NS_GEOLOCATION_CID \ - { \ - 0x1E1C3FF, 0x94A, 0xD048, { \ - 0x44, 0xB4, 0x62, 0xD2, 0x9C, 0x7B, 0x4F, 0x39 \ - } \ - } - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Geolocation, - Geolocation::NonWindowSingleton) - -#define NS_WEBSOCKETEVENT_SERVICE_CID \ - { \ - 0x31689828, 0xda66, 0x49a6, { \ - 0x87, 0x0c, 0xdf, 0x62, 0xb8, 0x3f, 0xe7, 0x89 \ - } \ - } - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WebSocketEventService, - WebSocketEventService::GetOrCreate) - -#ifdef MOZ_WEBSPEECH_TEST_BACKEND -NS_GENERIC_FACTORY_CONSTRUCTOR(FakeSpeechRecognitionService) -#endif - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentSecurityManager) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSPContext) -NS_GENERIC_FACTORY_CONSTRUCTOR(CSPService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMixedContentBlocker) - -NS_GENERIC_FACTORY_CONSTRUCTOR(ContentPrincipal) -NS_GENERIC_FACTORY_CONSTRUCTOR(ExpandedPrincipal) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - SystemPrincipal, - nsScriptSecurityManager::SystemPrincipalSingletonConstructor) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NullPrincipal, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsStructuredCloneContainer) - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(OSFileConstantsService, - OSFileConstantsService::GetOrCreate); - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - GeckoMediaPluginService, - GeckoMediaPluginService::GetGeckoMediaPluginService) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptError) - #ifdef ACCESSIBILITY # include "xpcAccessibilityService.h" -MAKE_CTOR(CreateA11yService, nsIAccessibilityService, - NS_GetAccessibilityService) +MAKE_GENERIC_CTOR(nsIAccessibilityService, NS_GetAccessibilityService) #endif -static nsresult Construct_nsIScriptSecurityManager(nsISupports* aOuter, - REFNSIID aIID, - void** aResult) { +nsresult Construct_nsIScriptSecurityManager(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) return NS_ERROR_NULL_POINTER; *aResult = nullptr; if (aOuter) return NS_ERROR_NO_AGGREGATION; @@ -424,86 +234,8 @@ static nsresult Construct_nsIScriptSecurityManager(nsISupports* aOuter, return NS_OK; } -#ifdef DEBUG -NS_DEFINE_NAMED_CID(NS_LAYOUT_DEBUGGER_CID); -#endif -NS_DEFINE_NAMED_CID(NS_FRAMETRAVERSAL_CID); -NS_DEFINE_NAMED_CID(IN_DEEPTREEWALKER_CID); -NS_DEFINE_NAMED_CID(NS_CONTENT_VIEWER_CID); -NS_DEFINE_NAMED_CID(NS_XMLCONTENTSERIALIZER_CID); -NS_DEFINE_NAMED_CID(NS_XHTMLCONTENTSERIALIZER_CID); -NS_DEFINE_NAMED_CID(NS_HTMLCONTENTSERIALIZER_CID); -NS_DEFINE_NAMED_CID(NS_PLAINTEXTSERIALIZER_CID); -NS_DEFINE_NAMED_CID(NS_PARSERUTILS_CID); -NS_DEFINE_NAMED_CID(NS_CONTENTPOLICY_CID); -NS_DEFINE_NAMED_CID(NS_DATADOCUMENTCONTENTPOLICY_CID); -NS_DEFINE_NAMED_CID(NS_NODATAPROTOCOLCONTENTPOLICY_CID); -NS_DEFINE_NAMED_CID(NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID); -NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_JSURI_CID); -NS_DEFINE_NAMED_CID(NS_JSURIMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID); -NS_DEFINE_NAMED_CID(NS_STYLESHEETSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_HOSTOBJECTURI_CID); -NS_DEFINE_NAMED_CID(NS_HOSTOBJECTURIMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_SDBCONNECTION_CID); -NS_DEFINE_NAMED_CID(NS_DOMLOCALSTORAGEMANAGER_CID); -NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID); -NS_DEFINE_NAMED_CID(QUOTAMANAGER_SERVICE_CID); -NS_DEFINE_NAMED_CID(SERVICEWORKERMANAGER_CID); -NS_DEFINE_NAMED_CID(STORAGEACTIVITYSERVICE_CID); -NS_DEFINE_NAMED_CID(NOTIFICATIONTELEMETRYSERVICE_CID); -NS_DEFINE_NAMED_CID(PUSHNOTIFIER_CID); -NS_DEFINE_NAMED_CID(WORKERDEBUGGERMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID); -NS_DEFINE_NAMED_CID(NS_WEBSOCKETEVENT_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_CONTENTSECURITYMANAGER_CID); -NS_DEFINE_NAMED_CID(CSPSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_CSPCONTEXT_CID); -NS_DEFINE_NAMED_CID(NS_MIXEDCONTENTBLOCKER_CID); -NS_DEFINE_NAMED_CID(NS_EVENTLISTENERSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_GLOBALMESSAGEMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_PARENTPROCESSMESSAGEMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_CHILDPROCESSMESSAGEMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_SCRIPTSECURITYMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_PRINCIPAL_CID); -NS_DEFINE_NAMED_CID(NS_EXPANDEDPRINCIPAL_CID); -NS_DEFINE_NAMED_CID(NS_SYSTEMPRINCIPAL_CID); -NS_DEFINE_NAMED_CID(NS_NULLPRINCIPAL_CID); -NS_DEFINE_NAMED_CID(THIRDPARTYUTIL_CID); -NS_DEFINE_NAMED_CID(NS_STRUCTUREDCLONECONTAINER_CID); -NS_DEFINE_NAMED_CID(NS_DEVICE_SENSORS_CID); -#if defined(ANDROID) -NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID); -#endif -NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_MEDIAMANAGERSERVICE_CID); -#ifdef MOZ_WEBSPEECH_TEST_BACKEND -NS_DEFINE_NAMED_CID(NS_FAKE_SPEECH_RECOGNITION_SERVICE_CID); -#endif -#ifdef MOZ_WEBSPEECH -NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID); -#endif - -#ifdef ACCESSIBILITY -NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID); -#endif - -NS_DEFINE_NAMED_CID(GECKO_MEDIA_PLUGIN_SERVICE_CID); - -NS_DEFINE_NAMED_CID(PRESENTATION_SERVICE_CID); -NS_DEFINE_NAMED_CID(PRESENTATION_DEVICE_MANAGER_CID); -NS_DEFINE_NAMED_CID(PRESENTATION_TCP_SESSION_TRANSPORT_CID); - -NS_DEFINE_NAMED_CID(TEXT_INPUT_PROCESSOR_CID); - -NS_DEFINE_NAMED_CID(NS_SCRIPTERROR_CID); - -NS_DEFINE_NAMED_CID(SCRIPTABLE_CONTENT_ITERATOR_CID); - -static nsresult LocalStorageManagerConstructor(nsISupports* aOuter, - REFNSIID aIID, void** aResult) { +nsresult LocalStorageManagerConstructor(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (NextGenLocalStorageEnabled()) { RefPtr manager = new LocalStorageManager2(); return manager->QueryInterface(aIID, aResult); @@ -513,181 +245,20 @@ static nsresult LocalStorageManagerConstructor(nsISupports* aOuter, return manager->QueryInterface(aIID, aResult); } -static const mozilla::Module::CIDEntry kLayoutCIDs[] = { - // clang-format off - XPCONNECT_CIDENTRIES -#ifdef DEBUG - { &kNS_LAYOUT_DEBUGGER_CID, false, nullptr, CreateNewLayoutDebugger }, -#endif - { &kNS_FRAMETRAVERSAL_CID, false, nullptr, CreateNewFrameTraversal }, - { &kIN_DEEPTREEWALKER_CID, false, nullptr, inDeepTreeWalkerConstructor }, - { &kNS_CONTENT_VIEWER_CID, false, nullptr, CreateContentViewer }, - { &kNS_XMLCONTENTSERIALIZER_CID, false, nullptr, CreateXMLContentSerializer }, - { &kNS_HTMLCONTENTSERIALIZER_CID, false, nullptr, CreateHTMLContentSerializer }, - { &kNS_XHTMLCONTENTSERIALIZER_CID, false, nullptr, CreateXHTMLContentSerializer }, - { &kNS_PLAINTEXTSERIALIZER_CID, false, nullptr, CreatePlainTextSerializer }, - { &kNS_PARSERUTILS_CID, false, nullptr, nsParserUtilsConstructor }, - { &kNS_CONTENTPOLICY_CID, false, nullptr, CreateContentPolicy }, - { &kNS_DATADOCUMENTCONTENTPOLICY_CID, false, nullptr, nsDataDocumentContentPolicyConstructor }, - { &kNS_NODATAPROTOCOLCONTENTPOLICY_CID, false, nullptr, nsNoDataProtocolContentPolicyConstructor }, - { &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID, false, nullptr, CreateContentDLF }, - { &kNS_JSPROTOCOLHANDLER_CID, false, nullptr, nsJSProtocolHandler::Create }, - { &kNS_JSURI_CID, false, nullptr, nsJSURIMutatorConstructor }, // do_CreateInstance returns mutator - { &kNS_JSURIMUTATOR_CID, false, nullptr, nsJSURIMutatorConstructor }, - { &kNS_PLUGINDOCLOADERFACTORY_CID, false, nullptr, CreateContentDLF }, - { &kNS_STYLESHEETSERVICE_CID, false, nullptr, nsStyleSheetServiceConstructor }, - { &kNS_HOSTOBJECTURI_CID, false, nullptr, BlobURLMutatorConstructor }, // do_CreateInstance returns mutator - { &kNS_HOSTOBJECTURIMUTATOR_CID, false, nullptr, BlobURLMutatorConstructor }, - { &kNS_SDBCONNECTION_CID, false, nullptr, SDBConnection::Create }, - { &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, LocalStorageManagerConstructor }, - { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor }, - { &kQUOTAMANAGER_SERVICE_CID, false, nullptr, QuotaManagerServiceConstructor }, - { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor }, - { &kSTORAGEACTIVITYSERVICE_CID, false, nullptr, StorageActivityServiceConstructor }, - { &kNOTIFICATIONTELEMETRYSERVICE_CID, false, nullptr, NotificationTelemetryServiceConstructor }, - { &kPUSHNOTIFIER_CID, false, nullptr, PushNotifierConstructor }, - { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor }, - { &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor }, - { &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor }, - { &kNS_FOCUSMANAGER_CID, false, nullptr, CreateFocusManager }, -#ifdef MOZ_WEBSPEECH_TEST_BACKEND - { &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID, false, nullptr, FakeSpeechRecognitionServiceConstructor }, -#endif -#ifdef MOZ_WEBSPEECH - { &kNS_SYNTHVOICEREGISTRY_CID, true, nullptr, nsSynthVoiceRegistryConstructor }, -#endif - { &kNS_CONTENTSECURITYMANAGER_CID, false, nullptr, nsContentSecurityManagerConstructor }, - { &kCSPSERVICE_CID, false, nullptr, CSPServiceConstructor }, - { &kNS_CSPCONTEXT_CID, false, nullptr, nsCSPContextConstructor }, - { &kNS_MIXEDCONTENTBLOCKER_CID, false, nullptr, nsMixedContentBlockerConstructor }, - { &kNS_EVENTLISTENERSERVICE_CID, false, nullptr, CreateEventListenerService }, - { &kNS_GLOBALMESSAGEMANAGER_CID, false, nullptr, CreateGlobalMessageManager }, - { &kNS_PARENTPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateParentMessageManager }, - { &kNS_CHILDPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateChildMessageManager }, - { &kNS_SCRIPTSECURITYMANAGER_CID, false, nullptr, Construct_nsIScriptSecurityManager }, - { &kNS_PRINCIPAL_CID, false, nullptr, ContentPrincipalConstructor }, - { &kNS_EXPANDEDPRINCIPAL_CID, false, nullptr, ExpandedPrincipalConstructor }, - { &kNS_SYSTEMPRINCIPAL_CID, false, nullptr, SystemPrincipalConstructor }, - { &kNS_NULLPRINCIPAL_CID, false, nullptr, NullPrincipalConstructor }, - { &kNS_DEVICE_SENSORS_CID, false, nullptr, nsDeviceSensorsConstructor }, -#if defined(ANDROID) - { &kNS_HAPTICFEEDBACK_CID, false, nullptr, nsHapticFeedbackConstructor }, -#endif - { &kTHIRDPARTYUTIL_CID, false, nullptr, ThirdPartyUtilConstructor }, - { &kNS_STRUCTUREDCLONECONTAINER_CID, false, nullptr, nsStructuredCloneContainerConstructor }, - { &kOSFILECONSTANTSSERVICE_CID, true, nullptr, OSFileConstantsServiceConstructor }, - { &kGECKO_MEDIA_PLUGIN_SERVICE_CID, true, nullptr, GeckoMediaPluginServiceConstructor }, - { &kNS_MEDIAMANAGERSERVICE_CID, false, nullptr, nsIMediaManagerServiceConstructor }, -#ifdef ACCESSIBILITY - { &kNS_ACCESSIBILITY_SERVICE_CID, false, nullptr, CreateA11yService }, -#endif - { &kPRESENTATION_SERVICE_CID, false, nullptr, nsIPresentationServiceConstructor }, - { &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor }, - { &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor }, - { &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor }, - { &kNS_SCRIPTERROR_CID, false, nullptr, nsScriptErrorConstructor }, - { &kSCRIPTABLE_CONTENT_ITERATOR_CID, false, nullptr, ScriptableContentIteratorConstructor }, - { nullptr } - // clang-format on -}; - -static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { - // clang-format off - XPCONNECT_CONTRACTS - { "@mozilla.org/inspector/deep-tree-walker;1", &kIN_DEEPTREEWALKER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/xml", &kNS_XMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xml", &kNS_XMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xhtml+xml", &kNS_XHTMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "image/svg+xml", &kNS_XMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/html", &kNS_HTMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/vnd.mozilla.xul+xml", &kNS_XMLCONTENTSERIALIZER_CID }, - { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/plain", &kNS_PLAINTEXTSERIALIZER_CID }, - { NS_PARSERUTILS_CONTRACTID, &kNS_PARSERUTILS_CID }, - { NS_CONTENTPOLICY_CONTRACTID, &kNS_CONTENTPOLICY_CID }, - { NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID, &kNS_DATADOCUMENTCONTENTPOLICY_CID }, - { NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID, &kNS_NODATAPROTOCOLCONTENTPOLICY_CID }, - { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID }, - { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID }, - { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID }, - { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID }, - { NS_SDBCONNECTION_CONTRACTID, &kNS_SDBCONNECTION_CID }, - { "@mozilla.org/dom/localStorage-manager;1", &kNS_DOMLOCALSTORAGEMANAGER_CID }, - { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID }, - { QUOTAMANAGER_SERVICE_CONTRACTID, &kQUOTAMANAGER_SERVICE_CID }, - { SERVICEWORKERMANAGER_CONTRACTID, &kSERVICEWORKERMANAGER_CID }, - { STORAGE_ACTIVITY_SERVICE_CONTRACTID, &kSTORAGEACTIVITYSERVICE_CID }, - { NOTIFICATIONTELEMETRYSERVICE_CONTRACTID, &kNOTIFICATIONTELEMETRYSERVICE_CID }, - { PUSHNOTIFIER_CONTRACTID, &kPUSHNOTIFIER_CID }, - { WORKERDEBUGGERMANAGER_CONTRACTID, &kWORKERDEBUGGERMANAGER_CID }, - { "@mozilla.org/geolocation;1", &kNS_GEOLOCATION_CID }, - { "@mozilla.org/websocketevent/service;1", &kNS_WEBSOCKETEVENT_SERVICE_CID }, - { "@mozilla.org/focus-manager;1", &kNS_FOCUSMANAGER_CID }, -#ifdef MOZ_WEBSPEECH_TEST_BACKEND - { NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "fake", &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID }, -#endif -#ifdef MOZ_WEBSPEECH - { NS_SYNTHVOICEREGISTRY_CONTRACTID, &kNS_SYNTHVOICEREGISTRY_CID }, -#endif - { NS_CONTENTSECURITYMANAGER_CONTRACTID, &kNS_CONTENTSECURITYMANAGER_CID }, - { CSPSERVICE_CONTRACTID, &kCSPSERVICE_CID }, - { NS_CSPCONTEXT_CONTRACTID, &kNS_CSPCONTEXT_CID }, - { NS_MIXEDCONTENTBLOCKER_CONTRACTID, &kNS_MIXEDCONTENTBLOCKER_CID }, - { NS_EVENTLISTENERSERVICE_CONTRACTID, &kNS_EVENTLISTENERSERVICE_CID }, - { NS_GLOBALMESSAGEMANAGER_CONTRACTID, &kNS_GLOBALMESSAGEMANAGER_CID }, - { NS_PARENTPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_PARENTPROCESSMESSAGEMANAGER_CID }, - { NS_CHILDPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_CHILDPROCESSMESSAGEMANAGER_CID }, - { NS_SCRIPTSECURITYMANAGER_CONTRACTID, &kNS_SCRIPTSECURITYMANAGER_CID }, - { NS_PRINCIPAL_CONTRACTID, &kNS_PRINCIPAL_CID }, - { NS_EXPANDEDPRINCIPAL_CONTRACTID, &kNS_EXPANDEDPRINCIPAL_CID }, - { NS_SYSTEMPRINCIPAL_CONTRACTID, &kNS_SYSTEMPRINCIPAL_CID }, - { NS_NULLPRINCIPAL_CONTRACTID, &kNS_NULLPRINCIPAL_CID }, - { NS_DEVICE_SENSORS_CONTRACTID, &kNS_DEVICE_SENSORS_CID }, -#if defined(ANDROID) - { "@mozilla.org/widget/hapticfeedback;1", &kNS_HAPTICFEEDBACK_CID }, -#endif - { THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID }, - { NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID }, - { OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID }, - { MEDIAMANAGERSERVICE_CONTRACTID, &kNS_MEDIAMANAGERSERVICE_CID }, -#ifdef ACCESSIBILITY - { "@mozilla.org/accessibilityService;1", &kNS_ACCESSIBILITY_SERVICE_CID }, -#endif - { "@mozilla.org/gecko-media-plugin-service;1", &kGECKO_MEDIA_PLUGIN_SERVICE_CID }, - { PRESENTATION_SERVICE_CONTRACTID, &kPRESENTATION_SERVICE_CID }, - { PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID }, - { PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID, &kPRESENTATION_TCP_SESSION_TRANSPORT_CID }, - { "@mozilla.org/text-input-processor;1", &kTEXT_INPUT_PROCESSOR_CID }, - { NS_SCRIPTERROR_CONTRACTID, &kNS_SCRIPTERROR_CID }, - { "@mozilla.org/scriptable-content-iterator;1", &kSCRIPTABLE_CONTENT_ITERATOR_CID }, - { nullptr } -}; - static const mozilla::Module::CategoryEntry kLayoutCategories[] = { - { "content-policy", NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID, NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID }, - { "content-policy", NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID, NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID }, - { "content-policy", "CSPService", CSPSERVICE_CONTRACTID }, - { "content-policy", NS_MIXEDCONTENTBLOCKER_CONTRACTID, NS_MIXEDCONTENTBLOCKER_CONTRACTID }, - { "net-channel-event-sinks", "CSPService", CSPSERVICE_CONTRACTID }, - { "net-channel-event-sinks", NS_MIXEDCONTENTBLOCKER_CONTRACTID, NS_MIXEDCONTENTBLOCKER_CONTRACTID }, - { "app-startup", "Script Security Manager", "service," NS_SCRIPTSECURITYMANAGER_CONTRACTID }, - { "app-startup", "Push Notifier", "service," PUSHNOTIFIER_CONTRACTID }, + // clang-format off { "clear-origin-attributes-data", "QuotaManagerService", "service," QUOTAMANAGER_SERVICE_CONTRACTID }, - { OBSERVER_TOPIC_IDLE_DAILY, "QuotaManagerService", QUOTAMANAGER_SERVICE_CONTRACTID }, - CONTENTDLF_CATEGORIES - { "profile-after-change", "PresentationDeviceManager", PRESENTATION_DEVICE_MANAGER_CONTRACTID }, - { "profile-after-change", "PresentationService", PRESENTATION_SERVICE_CONTRACTID }, - { "profile-after-change", "Notification Telemetry Service", NOTIFICATIONTELEMETRYSERVICE_CONTRACTID }, - { nullptr } + {nullptr} // clang-format on }; -static nsresult Initialize() { - // nsLayoutModuleInitialize should be called first. - MOZ_RELEASE_ASSERT(gInitialized); - return NS_OK; -} +void nsLayoutModuleDtor() { + if (XRE_GetProcessType() == GeckoProcessType_GPU || + XRE_GetProcessType() == GeckoProcessType_VR || + XRE_GetProcessType() == GeckoProcessType_RDD) { + return; + } -static void LayoutModuleDtor() { Shutdown(); nsContentUtils::XPCOMShutdown(); @@ -701,9 +272,12 @@ static void LayoutModuleDtor() { xpcModuleDtor(); } -static const mozilla::Module kLayoutModule = { - mozilla::Module::kVersion, kLayoutCIDs, kLayoutContracts, - kLayoutCategories, nullptr, Initialize, - LayoutModuleDtor}; +static const mozilla::Module kLayoutModule = {mozilla::Module::kVersion, + nullptr, + nullptr, + kLayoutCategories, + nullptr, + nullptr, + nullptr}; NSMODULE_DEFN(nsLayoutModule) = &kLayoutModule; diff --git a/layout/build/nsLayoutModule.h b/layout/build/nsLayoutModule.h index 73124f947edd..0dc9f63f1bd7 100644 --- a/layout/build/nsLayoutModule.h +++ b/layout/build/nsLayoutModule.h @@ -9,9 +9,37 @@ #include "nscore.h" +class nsIPresentationService; + // This function initializes various layout statics, as well as XPConnect. // It should be called only once, and before the first time any XPCOM module in // nsLayoutModule is used. void nsLayoutModuleInitialize(); +void nsLayoutModuleDtor(); + +nsresult CreateXMLContentSerializer(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateHTMLContentSerializer(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateXHTMLContentSerializer(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreatePlainTextSerializer(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateContentPolicy(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateGlobalMessageManager(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateParentMessageManager(nsISupports* aOuter, const nsID& aIID, + void** aResult); +nsresult CreateChildMessageManager(nsISupports* aOuter, const nsID& aIID, + void** aResult); + +nsresult Construct_nsIScriptSecurityManager(nsISupports* aOuter, + const nsIID& aIID, void** aResult); +nsresult LocalStorageManagerConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +already_AddRefed NS_CreatePresentationService(); + #endif // nsLayoutModule_h diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 9df99854f754..c5e7742c41ba 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -110,8 +110,8 @@ static const char kPrintingPromptService[] = #include "nsFocusManager.h" #include "nsRange.h" -#include "nsCDefaultURIFixup.h" #include "nsIURIFixup.h" +#include "mozilla/Components.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/HTMLFrameElement.h" #include "nsContentList.h" @@ -298,7 +298,7 @@ static void GetDocumentTitleAndURL(Document* aDoc, nsAString& aTitle, nsIURI* url = aDoc->GetDocumentURI(); if (!url) return; - nsCOMPtr urifixup(do_GetService(NS_URIFIXUP_CONTRACTID)); + nsCOMPtr urifixup(components::URIFixup::Service()); if (!urifixup) return; nsCOMPtr exposableURI; diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index dfcebe4996bc..539eb408d1e3 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -922,6 +922,12 @@ VARCACHE_PREF( bool, true ) +VARCACHE_PREF( + "layout.lower_priority_refresh_driver_during_load", + layout_lower_priority_refresh_driver_during_load, + bool, true +) + // Pref to control enabling scroll anchoring. #ifndef ANDROID #define PREF_VALUE true diff --git a/netwerk/base/moz.build b/netwerk/base/moz.build index 71ef42025f4f..d61290927867 100644 --- a/netwerk/base/moz.build +++ b/netwerk/base/moz.build @@ -148,6 +148,7 @@ EXPORTS += [ 'nsSerializationHelper.h', 'nsSimpleNestedURI.h', 'nsSimpleURI.h', + 'nsStandardURL.h', 'nsStreamListenerWrapper.h', 'nsURIHashKey.h', 'nsURLHelper.h', diff --git a/netwerk/base/nsUDPSocket.h b/netwerk/base/nsUDPSocket.h index a3e992dcc49d..ac2f03ba9e7d 100644 --- a/netwerk/base/nsUDPSocket.h +++ b/netwerk/base/nsUDPSocket.h @@ -8,6 +8,7 @@ #include "nsIUDPSocket.h" #include "mozilla/Mutex.h" +#include "mozilla/net/DNS.h" #include "nsIOutputStream.h" #include "nsAutoPtr.h" #include "nsCycleCollectionParticipant.h" diff --git a/netwerk/build/components.conf b/netwerk/build/components.conf new file mode 100644 index 000000000000..0f1fbc62c88c --- /dev/null +++ b/netwerk/build/components.conf @@ -0,0 +1,622 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Headers = [ + '/netwerk/build/nsNetModule.h' +] + +InitFunc = 'nsNetStartup' +UnloadFunc = 'nsNetShutdown' + +Classes = [ + { + 'cid': '{3014dde6-aa1c-41db-87d0-48764a3710f6}', + 'contract_ids': ['@mozilla.org/io/arraybuffer-input-stream;1'], + 'type': 'ArrayBufferInputStream', + 'headers': ['/netwerk/base/ArrayBufferInputStream.h'], + }, + { + 'cid': '{62d4b190-3642-4450-b019-d1c1fba56025}', + 'contract_ids': ['@mozilla.org/load-context-info-factory;1'], + 'type': 'mozilla::net::LoadContextInfoFactory', + 'headers': ['mozilla/LoadContextInfo.h'], + }, + { + 'cid': '{ea70b098-5014-4e21-aee1-75e6b2c4b8e0}', + 'contract_ids': [ + '@mozilla.org/netwerk/cache-storage-service;1', + '@mozilla.org/network/cache-storage-service;1', + ], + 'singleton': True, + 'type': 'mozilla::net::CacheStorageService', + 'headers': ['CacheStorageService.h'], + }, + { + 'cid': '{02bf7a2a-39d8-4a23-a50c-2cbb085ab7a5}', + 'contract_ids': ['@mozilla.org/network/application-cache-service;1'], + 'singleton': True, + 'type': 'nsApplicationCacheService', + 'headers': ['nsApplicationCacheService.h'], + }, + { + 'cid': '{e746a8b1-c97a-4fc5-baa4-66607521bd08}', + 'contract_ids': ['@mozilla.org/network/async-stream-copier;1'], + 'type': 'nsAsyncStreamCopier', + 'headers': ['/netwerk/base/nsAsyncStreamCopier.h'], + }, + { + 'cid': '{6eae857e-4ba9-11e3-9b39-b4036188709b}', + 'contract_ids': ['@mozilla.org/network/atomic-file-output-stream;1'], + 'type': 'nsAtomicFileOutputStream', + 'headers': ['nsFileStreams.h'], + }, + { + 'cid': '{62147d1e-ef6a-40e8-aaf8-d039f5caaa81}', + 'contract_ids': ['@mozilla.org/network/background-file-saver;1?mode=outputstream'], + 'type': 'mozilla::net::BackgroundFileSaverOutputStream', + 'headers': ['/netwerk/base/BackgroundFileSaver.h'], + 'init_method': 'Init', + }, + { + 'cid': '{208de7fc-a781-4031-bbae-cc0de539f61a}', + 'contract_ids': ['@mozilla.org/network/background-file-saver;1?mode=streamlistener'], + 'type': 'mozilla::net::BackgroundFileSaverStreamListener', + 'headers': ['/netwerk/base/BackgroundFileSaver.h'], + 'init_method': 'Init', + }, + { + 'cid': '{a2027ec6-ba0d-4c72-805d-148233f5f33c}', + 'contract_ids': ['@mozilla.org/network/binary-detector;1'], + 'legacy_constructor': 'CreateNewBinaryDetectorFactory', + }, + { + 'cid': '{9226888e-da08-11d3-8cda-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/buffered-input-stream;1'], + 'legacy_constructor': 'nsBufferedInputStream::Create', + 'headers': ['/netwerk/base/nsBufferedStreams.h'], + }, + { + 'cid': '{9868b4ce-da08-11d3-8cda-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/buffered-output-stream;1'], + 'legacy_constructor': 'nsBufferedOutputStream::Create', + 'headers': ['/netwerk/base/nsBufferedStreams.h'], + }, + { + 'cid': '{6c84aec9-29a5-4264-8fbc-bee8f922ea67}', + 'contract_ids': ['@mozilla.org/network/cache-service;1'], + 'legacy_constructor': 'nsCacheServiceConstructor', + }, + { + 'cid': '{bdbe0555-fc3d-4f7b-9205-c309ceb2d641}', + 'contract_ids': ['@mozilla.org/network/captive-portal-service;1'], + 'singleton': True, + 'type': 'nsICaptivePortalService', + 'constructor': 'mozilla::net::CaptivePortalService::GetSingleton', + 'headers': ['mozilla/net/CaptivePortalService.h'], + }, + { + 'cid': '{c79eb3c6-091a-45a6-8544-5a8d1ab79537}', + 'contract_ids': ['@mozilla.org/network/dashboard;1'], + 'type': 'mozilla::net::Dashboard', + 'headers': ['mozilla/net/Dashboard.h'], + }, + { + 'cid': '{b0ff4572-dae4-4bef-a092-83c1b88f6be9}', + 'contract_ids': ['@mozilla.org/network/dns-service;1'], + 'singleton': True, + 'type': 'nsIDNSService', + 'constructor': 'nsDNSService::GetXPCOMSingleton', + 'headers': ['/netwerk/dns/nsDNSService2.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{510a86bb-6019-4ed1-bb4f-965cffd23ece}', + 'contract_ids': ['@mozilla.org/network/downloader;1'], + 'type': 'nsDownloader', + 'headers': ['/netwerk/base/nsDownloader.h'], + }, + { + 'cid': '{cb9abbae-66b6-4609-8594-5c4ff300888e}', + 'contract_ids': ['@mozilla.org/network/effective-tld-service;1'], + 'singleton': True, + 'type': 'nsEffectiveTLDService', + 'headers': ['/netwerk/dns/nsEffectiveTLDService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{be9a53ae-c7e9-11d3-8cda-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/file-input-stream;1'], + 'legacy_constructor': 'nsFileInputStream::Create', + 'headers': ['nsFileStreams.h'], + }, + { + 'cid': '{c272fee0-c7e9-11d3-8cda-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/file-output-stream;1'], + 'legacy_constructor': 'nsFileOutputStream::Create', + 'headers': ['nsFileStreams.h'], + }, + { + 'cid': '{15629ada-a41c-4a09-961f-6553cd60b1a2}', + 'contract_ids': ['@mozilla.org/network/http-activity-distributor;1'], + 'type': 'mozilla::net::nsHttpActivityDistributor', + 'headers': ['/netwerk/protocol/http/nsHttpActivityDistributor.h'], + }, + { + 'cid': '{36b63ef3-e0fa-4c49-9fd4-e065e85568f4}', + 'contract_ids': ['@mozilla.org/network/http-auth-manager;1'], + 'type': 'mozilla::net::nsHttpAuthManager', + 'headers': ['/netwerk/protocol/http/nsHttpAuthManager.h'], + 'init_method': 'Init', + }, + { + 'cid': '{62b778a6-bce3-456b-8c31-2865fbb68c91}', + 'contract_ids': ['@mozilla.org/network/idn-service;1'], + 'type': 'nsIDNService', + 'headers': ['/netwerk/dns/nsIDNService.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{a62af1ba-79b3-4896-8aaf-b148bfce4280}', + 'contract_ids': ['@mozilla.org/network/incremental-download;1'], + 'legacy_constructor': 'net_NewIncrementalDownload', + }, + { + 'cid': '{5d6352a3-b9c3-4fa3-87aa-b2a3c6e5a501}', + 'contract_ids': ['@mozilla.org/network/incremental-stream-loader;1'], + 'legacy_constructor': 'nsIncrementalStreamLoader::Create', + 'headers': ['/netwerk/base/nsIncrementalStreamLoader.h'], + }, + { + 'cid': '{6ddb050c-0d04-11d4-986e-00c04fa0cf4a}', + 'contract_ids': ['@mozilla.org/network/input-stream-channel;1'], + 'type': 'mozilla::net::nsInputStreamChannel', + 'headers': ['/netwerk/base/nsInputStreamChannel.h'], + 'init_method': 'Init', + }, + { + 'cid': '{ccd0e960-7947-4635-b70e-4c661b63d675}', + 'contract_ids': ['@mozilla.org/network/input-stream-pump;1'], + 'type': 'nsInputStreamPump', + 'headers': ['nsInputStreamPump.h'], + }, + { + 'cid': '{9ac9e770-18bc-11d3-9337-00104ba0fd40}', + 'contract_ids': [ + '@mozilla.org/network/io-service;1', + '@mozilla.org/network/util;1', + ], + 'singleton': True, + 'type': 'mozilla::net::nsIOService', + 'headers': ['/netwerk/base/nsIOService.h'], + 'constructor': 'mozilla::net::nsIOService::GetInstance', + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{e1c61582-2a84-11d3-8cce-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/load-group;1'], + 'legacy_constructor': 'nsLoadGroupConstructor', + }, + { + 'cid': '{1f4dbcf7-245c-4c8c-943d-8a1da0495e8a}', + 'contract_ids': ['@mozilla.org/network/mime-hdrparam;1'], + 'type': 'nsMIMEHeaderParamImpl', + 'headers': ['/netwerk/mime/nsMIMEHeaderParamImpl.h'], + }, + { + 'cid': '{58a1c31c-1dd2-11b2-a3f6-d36949d48268}', + 'contract_ids': ['@mozilla.org/network/mime-input-stream;1'], + 'legacy_constructor': 'nsMIMEInputStreamConstructor', + 'headers': ['nsMIMEInputStream.h'], + }, + { + 'cid': '{2693457e-3ba5-4455-991f-5350946adb12}', + 'contract_ids': ['@mozilla.org/network/network-connectivity-service;1'], + 'singleton': True, + 'type': 'nsINetworkConnectivityService', + 'constructor': 'mozilla::net::NetworkConnectivityService::GetSingleton', + 'headers': ['mozilla/net/NetworkConnectivityService.h'], + }, + { + 'cid': '{969adfdf-7221-4419-aecf-05f8faf00c9b}', + 'contract_ids': ['@mozilla.org/network/predictor;1'], + 'singleton': True, + 'legacy_constructor': 'mozilla::net::Predictor::Create', + 'headers': ['mozilla/net/Predictor.h'], + }, + { + 'cid': '{e9b301c0-e0e4-11d3-a1a8-0050041caf44}', + 'contract_ids': ['@mozilla.org/network/protocol-proxy-service;1'], + 'singleton': True, + 'type': 'mozilla::net::nsProtocolProxyService', + 'headers': ['/netwerk/base/nsProtocolProxyService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{3decd6c8-30ef-11d3-8cd0-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/protocol/about;1?what=blank'], + 'legacy_constructor': 'nsAboutBlank::Create', + 'headers': ['/netwerk/protocol/about/nsAboutBlank.h'], + }, + { + 'cid': '{9158c470-86e4-11d4-9be2-00e09872a416}', + 'contract_ids': ['@mozilla.org/network/protocol/about;1?what=cache'], + 'legacy_constructor': 'nsAboutCache::Create', + 'headers': ['/netwerk/protocol/about/nsAboutCache.h'], + }, + { + 'cid': '{7fa5237d-b0eb-438f-9e50-ca0166e63788}', + 'contract_ids': ['@mozilla.org/network/protocol/about;1?what=cache-entry'], + 'type': 'nsAboutCacheEntry', + 'headers': ['/netwerk/protocol/about/nsAboutCacheEntry.h'], + }, + { + 'cid': '{9e3b6c90-2f75-11d3-8cd0-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=about'], + 'singleton': True, + 'type': 'mozilla::net::nsAboutProtocolHandler', + 'headers': ['/netwerk/protocol/about/nsAboutProtocolHandler.h'], + }, + { + 'cid': '{b6ed3030-6183-11d3-a178-0050041caf44}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=data'], + 'singleton': True, + 'legacy_constructor': 'nsDataHandler::Create', + 'headers': ['/netwerk/protocol/data/nsDataHandler.h'], + }, + { + 'cid': '{fbc81170-1f69-11d3-9344-00104ba0fd40}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=file'], + 'singleton': True, + 'type': 'nsFileProtocolHandler', + 'headers': ['mozilla/net/nsFileProtocolHandler.h'], + 'init_method': 'Init', + }, + { + 'cid': '{25029490-f132-11d2-9588-00805f369f95}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=ftp'], + 'singleton': True, + 'type': 'nsFtpProtocolHandler', + 'headers': ['/netwerk/protocol/ftp/nsFtpProtocolHandler.h'], + 'init_method': 'Init', + }, + { + 'cid': '{4f47e42e-4d23-4dd3-bfda-eb29255e9ea3}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=http'], + 'singleton': True, + 'type': 'mozilla::net::nsHttpHandler', + }, + { + 'cid': '{dccbe7e4-7750-466b-a557-5ea36c8ff24e}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=https'], + 'singleton': True, + 'type': 'mozilla::net::nsHttpsHandler', + }, + { + 'cid': '{aea16cd0-f020-4138-b068-0716c4a15b5a}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-extension'], + 'singleton': True, + 'type': 'mozilla::net::ExtensionProtocolHandler', + 'headers': ['mozilla/net/ExtensionProtocolHandler.h'], + 'constructor': 'mozilla::net::ExtensionProtocolHandler::GetSingleton', + }, + { + 'cid': '{1423e739-782c-4081-b5d8-fe6fba68c0ef}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-safe-about'], + 'singleton': True, + 'type': 'mozilla::net::nsSafeAboutProtocolHandler', + 'headers': ['/netwerk/protocol/about/nsAboutProtocolHandler.h'], + }, + { + 'cid': '{e64f152a-9f07-11d3-8cda-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=resource'], + 'singleton': True, + 'type': 'nsResProtocolHandler', + 'headers': ['/netwerk/protocol/res/nsResProtocolHandler.h'], + 'init_method': 'Init', + }, + { + 'cid': '{9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=view-source'], + 'singleton': True, + 'type': 'mozilla::net::nsViewSourceHandler', + 'headers': ['/netwerk/protocol/viewsource/nsViewSourceHandler.h'], + }, + { + 'cid': '{dc01db59-a513-4c90-824b-085cce06c0aa}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=ws'], + 'singleton': True, + 'legacy_constructor': 'mozilla::net::WebSocketChannelConstructor', + }, + { + 'cid': '{dc01dbbb-a5bb-4cbb-82bb-085cce06c0bb}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=wss'], + 'singleton': True, + 'legacy_constructor': 'mozilla::net::WebSocketSSLChannelConstructor', + }, + { + 'cid': '{e7509b46-2eb2-410a-9d7c-c3ce73284d01}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=wyciwyg'], + 'singleton': True, + 'type': 'nsWyciwygProtocolHandler', + 'headers': ['/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h'], + }, + { + 'cid': '{a181af0d-68b8-4308-94db-d4f859058215}', + 'contract_ids': ['@mozilla.org/network/safe-file-output-stream;1'], + 'type': 'nsAtomicFileOutputStream', + 'headers': ['nsFileStreams.h'], + }, + { + 'cid': '{d6ef593d-a429-4b14-a887-d9e2f765d9ed}', + 'contract_ids': ['@mozilla.org/network/serialization-helper;1'], + 'type': 'nsSerializationHelper', + 'headers': ['nsSerializationHelper.h'], + }, + { + 'cid': '{2ec62893-3b35-48fa-ab1d-5e68a9f45f08}', + 'contract_ids': ['@mozilla.org/network/server-socket;1'], + 'type': 'mozilla::net::nsServerSocket', + 'headers': ['/netwerk/base/nsServerSocket.h'], + }, + { + 'cid': '{fb8cbf4e-4701-4ba1-b1d6-5388e041fb67}', + 'contract_ids': ['@mozilla.org/network/simple-stream-listener;1'], + 'type': 'mozilla::net::nsSimpleStreamListener', + 'headers': ['/netwerk/base/nsSimpleStreamListener.h'], + }, + { + 'cid': '{2be14592-28d4-4a83-8fe9-08e778849f6e}', + 'contract_ids': ['@mozilla.org/network/simple-uri-mutator;1'], + 'type': 'mozilla::net::nsSimpleURI::Mutator', + 'headers': ['nsSimpleURI.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{ad56b25f-e6bb-4db3-9f7b-5b7db33fd2b1}', + 'contract_ids': ['@mozilla.org/network/socket-transport-service;1'], + 'singleton': True, + 'type': 'mozilla::net::nsSocketTransportService', + 'headers': ['/netwerk/base/nsSocketTransportService2.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{ce7d7da0-fb28-44a3-8c7b-000c165918f4}', + 'contract_ids': ['@mozilla.org/network/standard-url-mutator;1'], + 'type': 'mozilla::net::nsStandardURL::Mutator', + 'headers': ['/netwerk/base/nsStandardURL.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{831f8f13-7aa8-485f-b02e-77c881cc5773}', + 'contract_ids': ['@mozilla.org/network/stream-listener-tee;1'], + 'type': 'mozilla::net::nsStreamListenerTee', + 'headers': ['/netwerk/base/nsStreamListenerTee.h'], + }, + { + 'cid': '{5ba6d920-d4e9-11d3-a1a5-0050041caf44}', + 'contract_ids': ['@mozilla.org/network/stream-loader;1'], + 'legacy_constructor': 'mozilla::net::nsStreamLoader::Create', + 'headers': ['/netwerk/base/nsStreamLoader.h'], + }, + { + 'cid': '{0885d4f8-f7b8-4cda-902e-94ba38bc256e}', + 'contract_ids': ['@mozilla.org/network/stream-transport-service;1'], + 'type': 'mozilla::net::nsStreamTransportService', + 'headers': ['/netwerk/base/nsStreamTransportService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{4c39159c-cd90-4dd3-97a7-06af5e6d84c4}', + 'contract_ids': ['@mozilla.org/network/throttlequeue;1'], + 'type': 'mozilla::net::ThrottleQueue', + 'headers': ['/netwerk/base/ThrottleQueue.h'], + }, + { + 'cid': '{1813cbb4-c98e-4622-8c7d-839167f3f272}', + 'contract_ids': ['@mozilla.org/network/tls-server-socket;1'], + 'type': 'mozilla::net::TLSServerSocket', + 'headers': ['/netwerk/base/TLSServerSocket.h'], + }, + { + 'cid': '{c9f74572-7b8e-4fec-bb4a-03c0d3021bd6}', + 'contract_ids': ['@mozilla.org/network/udp-socket;1'], + 'type': 'mozilla::net::nsUDPSocket', + 'headers': ['/netwerk/base/nsUDPSocket.h'], + }, + { + 'cid': '{ff41913b-546a-4bff-9201-dc9b2c032eba}', + 'contract_ids': ['@mozilla.org/network/url-parser;1?auth=maybe'], + 'type': 'nsStdURLParser', + 'headers': ['nsURLParsers.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{78804a84-8173-42b6-bb94-789f0816a810}', + 'contract_ids': ['@mozilla.org/network/url-parser;1?auth=no'], + 'type': 'nsNoAuthURLParser', + 'headers': ['nsURLParsers.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{275d800e-3f60-4896-adb7-d7f390ce0e42}', + 'contract_ids': ['@mozilla.org/network/url-parser;1?auth=yes'], + 'type': 'nsAuthURLParser', + 'headers': ['nsURLParsers.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{892ffeb0-3f80-11d3-a16c-0050041caf44}', + 'contract_ids': ['@mozilla.org/streamConverters;1'], + 'legacy_constructor': 'CreateNewStreamConvServiceFactory', + }, + { + 'cid': '{cf0f71fd-fafd-4e2b-9fdc-134d972e16e2}', + 'contract_ids': ['@mozilla.org/streamconv;1?from=application/http-index-format&to=text/html'], + 'legacy_constructor': 'nsIndexedToHTML::Create', + 'headers': ['/netwerk/streamconv/converters/nsIndexedToHTML.h'], + }, + { + 'cid': '{7d7008a0-c49a-11d3-9b22-0080c7cb1080}', + 'contract_ids': ['@mozilla.org/streamconv;1?from=application/x-unknown-content-type&to=*/*'], + 'legacy_constructor': 'CreateNewUnknownDecoderFactory', + }, + { + 'cid': '{66230b2b-17fa-4bd3-abf4-07986151022d}', + 'contract_ids': [ + '@mozilla.org/streamconv;1?from=br&to=uncompressed', + '@mozilla.org/streamconv;1?from=compress&to=uncompressed', + '@mozilla.org/streamconv;1?from=deflate&to=uncompressed', + '@mozilla.org/streamconv;1?from=gzip&to=uncompressed', + '@mozilla.org/streamconv;1?from=x-compress&to=uncompressed', + '@mozilla.org/streamconv;1?from=x-gzip&to=uncompressed', + ], + 'legacy_constructor': 'CreateNewHTTPCompressConvFactory', + }, + { + 'cid': '{7584ce90-5b25-11d3-a175-0050041caf44}', + 'contract_ids': [ + '@mozilla.org/streamconv;1?from=multipart/byteranges&to=*/*', + '@mozilla.org/streamconv;1?from=multipart/mixed&to=*/*', + '@mozilla.org/streamconv;1?from=multipart/x-mixed-replace&to=*/*', + ], + 'legacy_constructor': 'CreateNewMultiMixedConvFactory', + }, + { + 'cid': '{14c0e880-623e-11d3-a178-0050041caf44}', + 'contract_ids': ['@mozilla.org/streamconv;1?from=text/ftp-dir&to=application/http-index-format'], + 'legacy_constructor': 'CreateNewFTPDirListingConv', + }, + { + 'cid': '{77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b}', + 'contract_ids': ['@mozilla.org/txttohtmlconv;1'], + 'legacy_constructor': 'CreateNewTXTToHTMLConvFactory', + }, + { + 'cid': '{2f277c00-0eaf-4ddb-b936-41326ba48aae}', + 'contract_ids': [], + 'type': 'mozilla::net::nsNestedAboutURI::Mutator', + 'headers': ['/netwerk/protocol/about/nsAboutProtocolHandler.h'], + }, + { + 'cid': '{56388dad-287b-4240-a785-85c394012503}', + 'contract_ids': [], + 'type': 'mozilla::net::nsSimpleNestedURI::Mutator', + 'headers': ['nsSimpleNestedURI.h'], + }, + { + 'cid': '{9c4e9d49-ce64-4ca3-acef-3075c5e5aba7}', + 'contract_ids': [], + 'type': 'mozilla::net::nsSimpleNestedURI::Mutator', + 'headers': ['nsSimpleNestedURI.h'], + }, + { + 'cid': '{b0054ef3-b096-483d-8242-4ee36b7b2115}', + 'contract_ids': [], + 'type': 'mozilla::net::nsNestedAboutURI::Mutator', + 'headers': ['/netwerk/protocol/about/nsAboutProtocolHandler.h'], + }, + { + 'cid': '{b3cfeb91-332a-46c9-ad97-93ff39841494}', + 'contract_ids': [], + 'type': 'mozilla::net::SubstitutingURL::Mutator', + 'headers': ['mozilla/net/SubstitutingURL.h'], + }, + { + 'cid': '{de9472d0-8034-11d3-9399-00104ba0fd40}', + 'contract_ids': [], + 'type': 'mozilla::net::nsStandardURL::Mutator', + 'headers': ['/netwerk/base/nsStandardURL.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, + { + 'cid': '{dea9657c-18cf-4984-bde9-ccef5d8ab473}', + 'contract_ids': [], + 'type': 'mozilla::net::SubstitutingURL::Mutator', + 'headers': ['mozilla/net/SubstitutingURL.h'], + }, + { + 'cid': '{e0da1d70-2f7b-11d3-8cd0-0060b0fc14a3}', + 'contract_ids': [], + 'type': 'mozilla::net::nsSimpleURI::Mutator', + 'headers': ['nsSimpleURI.h'], + 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, + }, +] + +if defined('NECKO_COOKIES'): + Classes += [ + { + 'cid': '{c375fa80-150f-11d6-a618-0010a401eb10}', + 'contract_ids': [ + '@mozilla.org/cookieService;1', + '@mozilla.org/cookiemanager;1', + ], + 'singleton': True, + 'type': 'nsICookieService', + 'constructor': 'nsCookieService::GetXPCOMSingleton', + 'headers': ['/netwerk/cookie/nsCookieService.h'], + }, + ] + +if defined('NECKO_WIFI'): + Classes += [ + { + 'cid': '{3ff8fb9f-ee63-48df-89f0-dace0242fd82}', + 'contract_ids': ['@mozilla.org/wifi/monitor;1'], + 'singleton': True, + 'type': 'nsWifiMonitor', + 'headers': ['/netwerk/wifi/nsWifiMonitor.h'], + }, + ] + +if buildconfig.substs['OS_ARCH'] in ('WINNT', 'Darwin', 'Linux'): + Classes += [ + { + 'cid': '{296d0900-f8ef-4df0-9c35-db5862abc58d}', + 'contract_ids': ['@mozilla.org/network-info-service;1'], + 'type': 'mozilla::net::nsNetworkInfoService', + 'headers': ['/netwerk/base/nsNetworkInfoService.h'], + 'init_method': 'Init', + }, + ] + + +toolkit = buildconfig.substs['MOZ_WIDGET_TOOLKIT'] +link_service = None +if toolkit == 'windows': + link_service = { + 'type': 'nsNotifyAddrListener', + 'headers': ['/netwerk/system/win32/nsNotifyAddrListener.h'], + 'init_method': 'Init', + } +elif toolkit == 'cocoa': + link_service = { + 'type': 'nsNetworkLinkService', + 'headers': ['/netwerk/system/mac/nsNetworkLinkService.h'], + 'init_method': 'Init', + } +elif toolkit == 'android': + link_service = { + 'type': 'nsAndroidNetworkLinkService', + 'headers': ['/netwerk/system/android/nsAndroidNetworkLinkService.h'], + } +elif buildconfig.substs['OS_ARCH'] == 'Linux': + link_service = { + 'type': 'nsNotifyAddrListener', + 'headers': ['/netwerk/system/linux/nsNotifyAddrListener_Linux.h'], + 'init_method': 'Init', + } + +if link_service: + Classes += [ + dict({ + 'cid': '{75a500a2-0030-40f7-86f8-63f225b940ae}', + 'contract_ids': ['@mozilla.org/network/network-link-service;1'], + 'singleton': True, + }, **link_service) + ] diff --git a/netwerk/build/moz.build b/netwerk/build/moz.build index 592a81ebad10..6e099f5a7a02 100644 --- a/netwerk/build/moz.build +++ b/netwerk/build/moz.build @@ -12,6 +12,10 @@ SOURCES += [ 'nsNetModule.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' @@ -41,35 +45,6 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: '/netwerk/protocol/gio', ] -if CONFIG['OS_ARCH'] == 'WINNT': - LOCAL_INCLUDES += [ - '/netwerk/system/win32', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': - LOCAL_INCLUDES += [ - '/netwerk/system/mac', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': - LOCAL_INCLUDES += [ - '/netwerk/system/android', - ] - -elif CONFIG['OS_ARCH'] == 'Linux': - LOCAL_INCLUDES += [ - '/netwerk/system/linux', - ] - -if CONFIG['NECKO_COOKIES']: - LOCAL_INCLUDES += [ - '/netwerk/cookie', - ] - -if CONFIG['NECKO_WIFI']: - LOCAL_INCLUDES += [ - '/netwerk/wifi', - ] LOCAL_INCLUDES += [ '!/netwerk/dns', diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index 0e26b183a77a..41f8fc5164ea 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -11,30 +11,20 @@ #include "nsCOMPtr.h" #include "nsIClassInfoImpl.h" +#include "mozilla/Components.h" #include "mozilla/ModuleUtils.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsICategoryManager.h" #include "nscore.h" #include "nsSimpleURI.h" -#include "nsSimpleNestedURI.h" #include "nsLoadGroup.h" -#include "nsStreamLoader.h" -#include "nsIncrementalStreamLoader.h" -#include "nsFileStreams.h" -#include "nsBufferedStreams.h" -#include "nsMIMEInputStream.h" -#include "nsSOCKSSocketProvider.h" -#include "nsCacheService.h" -#include "nsDiskCacheDeviceSQL.h" -#include "nsApplicationCacheService.h" #include "nsMimeTypes.h" #include "nsDNSPrefetch.h" -#include "nsAboutProtocolHandler.h" #include "nsXULAppAPI.h" #include "nsCategoryCache.h" #include "nsIContentSniffer.h" -#include "Predictor.h" +#include "nsStandardURL.h" #include "nsIThreadPool.h" #include "mozilla/net/BackgroundChannelRegistrar.h" #include "mozilla/net/NeckoChild.h" @@ -47,185 +37,21 @@ # define BUILD_NETWORK_INFO_SERVICE 1 #endif +using namespace mozilla; + typedef nsCategoryCache ContentSnifferCache; ContentSnifferCache* gNetSniffers = nullptr; ContentSnifferCache* gDataSniffers = nullptr; -/////////////////////////////////////////////////////////////////////////////// - -#include "nsIOService.h" -typedef mozilla::net::nsIOService nsIOService; -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIOService, nsIOService::GetInstance) - -#include "nsDNSService2.h" -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIDNSService, - nsDNSService::GetXPCOMSingleton) - -#include "nsProtocolProxyService.h" -typedef mozilla::net::nsProtocolProxyService nsProtocolProxyService; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsProtocolProxyService, Init) - -#include "nsStreamTransportService.h" -typedef mozilla::net::nsStreamTransportService nsStreamTransportService; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStreamTransportService, Init) - -#include "nsSocketTransportService2.h" -typedef mozilla::net::nsSocketTransportService nsSocketTransportService; -#undef LOG -#undef LOG_ENABLED -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSocketTransportService, Init) - -#include "nsServerSocket.h" -typedef mozilla::net::nsServerSocket nsServerSocket; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsServerSocket) - -#include "TLSServerSocket.h" -typedef mozilla::net::TLSServerSocket TLSServerSocket; -NS_GENERIC_FACTORY_CONSTRUCTOR(TLSServerSocket) - -#include "nsUDPSocket.h" -typedef mozilla::net::nsUDPSocket nsUDPSocket; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsUDPSocket) - -#include "nsAsyncStreamCopier.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAsyncStreamCopier) - -#include "nsInputStreamPump.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsInputStreamPump) - -#include "nsInputStreamChannel.h" -typedef mozilla::net::nsInputStreamChannel nsInputStreamChannel; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsInputStreamChannel, Init) - -#include "nsDownloader.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloader) - -#include "BackgroundFileSaver.h" -namespace mozilla { -namespace net { -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(BackgroundFileSaverOutputStream, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(BackgroundFileSaverStreamListener, Init) -} // namespace net -} // namespace mozilla - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomicFileOutputStream) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeFileOutputStream) - +#define static typedef mozilla::net::nsLoadGroup nsLoadGroup; NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsLoadGroup, Init) - -#include "ArrayBufferInputStream.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(ArrayBufferInputStream) - -#include "nsEffectiveTLDService.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEffectiveTLDService, Init) - -#include "nsSerializationHelper.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSerializationHelper) - -#include "CacheStorageService.h" -typedef mozilla::net::CacheStorageService CacheStorageService; -NS_GENERIC_FACTORY_CONSTRUCTOR(CacheStorageService) - -#include "LoadContextInfo.h" -typedef mozilla::net::LoadContextInfoFactory LoadContextInfoFactory; -NS_GENERIC_FACTORY_CONSTRUCTOR(LoadContextInfoFactory) - -/////////////////////////////////////////////////////////////////////////////// - -#include "mozilla/net/CaptivePortalService.h" -namespace mozilla { -namespace net { -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsICaptivePortalService, - CaptivePortalService::GetSingleton) -} // namespace net -} // namespace mozilla - -#include "mozilla/net/NetworkConnectivityService.h" -namespace mozilla { -namespace net { -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - nsINetworkConnectivityService, NetworkConnectivityService::GetSingleton) -} // namespace net -} // namespace mozilla - -/////////////////////////////////////////////////////////////////////////////// - -extern nsresult net_NewIncrementalDownload(nsISupports*, const nsIID&, void**); - -#define NS_INCREMENTALDOWNLOAD_CID \ - { /* a62af1ba-79b3-4896-8aaf-b148bfce4280 */ \ - 0xa62af1ba, 0x79b3, 0x4896, { \ - 0x8a, 0xaf, 0xb1, 0x48, 0xbf, 0xce, 0x42, 0x80 \ - } \ - } - -/////////////////////////////////////////////////////////////////////////////// - -#include "nsMIMEHeaderParamImpl.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMIMEHeaderParamImpl) -/////////////////////////////////////////////////////////////////////////////// - -#include "nsSimpleStreamListener.h" - -typedef mozilla::net::nsSimpleStreamListener nsSimpleStreamListener; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleStreamListener) - -/////////////////////////////////////////////////////////////////////////////// - -#include "nsStreamListenerTee.h" -typedef mozilla::net::nsStreamListenerTee nsStreamListenerTee; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsStreamListenerTee) - -/////////////////////////////////////////////////////////////////////////////// - -#ifdef NECKO_COOKIES -# include "nsCookieService.h" -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsICookieService, - nsCookieService::GetXPCOMSingleton) -#endif - -/////////////////////////////////////////////////////////////////////////////// -#ifdef NECKO_WIFI - -# include "nsWifiMonitor.h" -# undef LOG -# undef LOG_ENABLED -NS_GENERIC_FACTORY_CONSTRUCTOR(nsWifiMonitor) - -#endif +#undef static /////////////////////////////////////////////////////////////////////////////// // protocols /////////////////////////////////////////////////////////////////////////////// -// about:blank is mandatory -#include "nsAboutProtocolHandler.h" -#include "nsAboutBlank.h" -typedef mozilla::net::nsAboutProtocolHandler nsAboutProtocolHandler; -typedef mozilla::net::nsSafeAboutProtocolHandler nsSafeAboutProtocolHandler; -typedef mozilla::net::nsNestedAboutURI::Mutator nsNestedAboutURIMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutProtocolHandler) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeAboutProtocolHandler) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNestedAboutURIMutator) - -// about -#include "nsAboutCache.h" -#include "nsAboutCacheEntry.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutCacheEntry) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCacheService) - -// file -#include "nsFileProtocolHandler.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFileProtocolHandler, Init) - -// ftp -#include "nsFtpProtocolHandler.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFtpProtocolHandler, Init) - // http/https #include "nsHttpHandler.h" #include "Http2Compression.h" @@ -236,46 +62,27 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFtpProtocolHandler, Init) #include "ThrottleQueue.h" #undef LOG #undef LOG_ENABLED -namespace mozilla { -namespace net { -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsHttpHandler, - nsHttpHandler::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpsHandler, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpAuthManager, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpActivityDistributor) -NS_GENERIC_FACTORY_CONSTRUCTOR(ThrottleQueue) -} // namespace net -} // namespace mozilla -#include "mozilla/net/Dashboard.h" -namespace mozilla { -namespace net { -NS_GENERIC_FACTORY_CONSTRUCTOR(Dashboard) -} // namespace net -} // namespace mozilla +NS_IMPL_COMPONENT_FACTORY(net::nsHttpHandler) { + return net::nsHttpHandler::GetInstance().downcast(); +} -// resource -#include "nsResProtocolHandler.h" -#include "ExtensionProtocolHandler.h" -#include "SubstitutingProtocolHandler.h" -typedef mozilla::net::ExtensionProtocolHandler ExtensionProtocolHandler; -typedef mozilla::net::SubstitutingURL::Mutator SubstitutingURLMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init) +NS_IMPL_COMPONENT_FACTORY(net::nsHttpsHandler) { + auto handler = MakeRefPtr(); -namespace mozilla { -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ExtensionProtocolHandler, - ExtensionProtocolHandler::GetSingleton) -NS_GENERIC_FACTORY_CONSTRUCTOR(SubstitutingURLMutator) -} // namespace mozilla + if (NS_FAILED(handler->Init())) { + return nullptr; + } + return handler.forget().downcast(); +} -#include "nsViewSourceHandler.h" -typedef mozilla::net::nsViewSourceHandler nsViewSourceHandler; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler) -#include "nsDataHandler.h" +#include "nsCacheService.h" -#include "nsWyciwygProtocolHandler.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler) +nsresult nsCacheServiceConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult) { + return nsCacheService::Create(aOuter, aIID, aResult); +} #include "WebSocketChannel.h" #include "WebSocketChannelChild.h" @@ -292,23 +99,23 @@ static BaseWebSocketChannel* WebSocketChannelConstructor(bool aSecure) { return new WebSocketChannel; } -#define WEB_SOCKET_HANDLER_CONSTRUCTOR(type, secure) \ - static nsresult type##Constructor(nsISupports* aOuter, REFNSIID aIID, \ - void** aResult) { \ - nsresult rv; \ - \ - BaseWebSocketChannel* inst; \ - \ - *aResult = nullptr; \ - if (nullptr != aOuter) { \ - rv = NS_ERROR_NO_AGGREGATION; \ - return rv; \ - } \ - inst = WebSocketChannelConstructor(secure); \ - NS_ADDREF(inst); \ - rv = inst->QueryInterface(aIID, aResult); \ - NS_RELEASE(inst); \ - return rv; \ +#define WEB_SOCKET_HANDLER_CONSTRUCTOR(type, secure) \ + nsresult type##Constructor(nsISupports* aOuter, REFNSIID aIID, \ + void** aResult) { \ + nsresult rv; \ + \ + BaseWebSocketChannel* inst; \ + \ + *aResult = nullptr; \ + if (nullptr != aOuter) { \ + rv = NS_ERROR_NO_AGGREGATION; \ + return rv; \ + } \ + inst = WebSocketChannelConstructor(secure); \ + NS_ADDREF(inst); \ + rv = inst->QueryInterface(aIID, aResult); \ + NS_RELEASE(inst); \ + return rv; \ } WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketChannel, false) @@ -319,42 +126,6 @@ WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketSSLChannel, true) /////////////////////////////////////////////////////////////////////////////// -#include "nsURLParsers.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoAuthURLParser) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthURLParser) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsStdURLParser) - -#include "nsStandardURL.h" -typedef mozilla::net::nsStandardURL::Mutator nsStandardURLMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandardURLMutator) -typedef mozilla::net::nsSimpleURI::Mutator nsSimpleURIMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleURIMutator) - -typedef mozilla::net::nsSimpleNestedURI::Mutator nsSimpleNestedURIMutator; -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURIMutator) - -/////////////////////////////////////////////////////////////////////////////// - -#include "nsIDNService.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init) - -/////////////////////////////////////////////////////////////////////////////// -#if defined(XP_WIN) -# include "nsNotifyAddrListener.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init) -#elif defined(MOZ_WIDGET_COCOA) -# include "nsNetworkLinkService.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init) -#elif defined(MOZ_WIDGET_ANDROID) -# include "nsAndroidNetworkLinkService.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidNetworkLinkService) -#elif defined(XP_LINUX) -# include "nsNotifyAddrListener_Linux.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init) -#endif - -/////////////////////////////////////////////////////////////////////////////// - #include "nsFTPDirListingConv.h" nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result); @@ -366,12 +137,6 @@ nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result); /////////////////////////////////////////////////////////////////////////////// -#ifdef BUILD_NETWORK_INFO_SERVICE -# include "nsNetworkInfoService.h" -typedef mozilla::net::nsNetworkInfoService nsNetworkInfoService; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkInfoService, Init) -#endif // BUILD_NETWORK_INFO_SERVICE - #include "nsIndexedToHTML.h" nsresult NS_NewMultiMixedConv(nsMultiMixedConv** result); @@ -408,9 +173,8 @@ static const mozilla::Module::CategoryEntry kNeckoCategories[] = { NS_BINARYDETECTOR_CATEGORYENTRY, {nullptr}}; -static nsresult CreateNewStreamConvServiceFactory(nsISupports* aOuter, - REFNSIID aIID, - void** aResult) { +nsresult CreateNewStreamConvServiceFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) { return NS_ERROR_INVALID_POINTER; } @@ -432,8 +196,8 @@ static nsresult CreateNewStreamConvServiceFactory(nsISupports* aOuter, return rv; } -static nsresult CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, - void** aResult) { +nsresult CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) { return NS_ERROR_INVALID_POINTER; } @@ -455,8 +219,8 @@ static nsresult CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, return rv; } -static nsresult CreateNewMultiMixedConvFactory(nsISupports* aOuter, - REFNSIID aIID, void** aResult) { +nsresult CreateNewMultiMixedConvFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) { return NS_ERROR_INVALID_POINTER; } @@ -478,8 +242,8 @@ static nsresult CreateNewMultiMixedConvFactory(nsISupports* aOuter, return rv; } -static nsresult CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, - REFNSIID aIID, void** aResult) { +nsresult CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) { return NS_ERROR_INVALID_POINTER; } @@ -501,9 +265,8 @@ static nsresult CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, return rv; } -static nsresult CreateNewHTTPCompressConvFactory(nsISupports* aOuter, - REFNSIID aIID, - void** aResult) { +nsresult CreateNewHTTPCompressConvFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { if (!aResult) { return NS_ERROR_INVALID_POINTER; } @@ -525,8 +288,8 @@ static nsresult CreateNewHTTPCompressConvFactory(nsISupports* aOuter, return rv; } -static nsresult CreateNewUnknownDecoderFactory(nsISupports* aOuter, - REFNSIID aIID, void** aResult) { +nsresult CreateNewUnknownDecoderFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { nsresult rv; if (!aResult) { @@ -551,8 +314,8 @@ static nsresult CreateNewUnknownDecoderFactory(nsISupports* aOuter, return rv; } -static nsresult CreateNewBinaryDetectorFactory(nsISupports* aOuter, - REFNSIID aIID, void** aResult) { +nsresult CreateNewBinaryDetectorFactory(nsISupports* aOuter, REFNSIID aIID, + void** aResult) { nsresult rv; if (!aResult) { @@ -579,13 +342,13 @@ static nsresult CreateNewBinaryDetectorFactory(nsISupports* aOuter, // Module implementation for the net library // Net module startup hook -static nsresult nsNetStartup() { +nsresult nsNetStartup() { mozilla::net::nsStandardURL::InitGlobalObjects(); return NS_OK; } // Net module shutdown hook -static void nsNetShutdown() { +void nsNetShutdown() { // Release the url parser that the stdurl is holding. mozilla::net::nsStandardURL::ShutdownGlobalObjects(); @@ -615,329 +378,13 @@ static void nsNetShutdown() { gDataSniffers = nullptr; } -NS_DEFINE_NAMED_CID(NS_IOSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_STREAMTRANSPORTSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_SOCKETTRANSPORTSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_SERVERSOCKET_CID); -NS_DEFINE_NAMED_CID(NS_TLSSERVERSOCKET_CID); -NS_DEFINE_NAMED_CID(NS_UDPSOCKET_CID); -NS_DEFINE_NAMED_CID(NS_DNSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_IDNSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_EFFECTIVETLDSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_SIMPLEURI_CID); -NS_DEFINE_NAMED_CID(NS_SIMPLEURIMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_SIMPLENESTEDURI_CID); -NS_DEFINE_NAMED_CID(NS_SIMPLENESTEDURIMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_ASYNCSTREAMCOPIER_CID); -NS_DEFINE_NAMED_CID(NS_INPUTSTREAMPUMP_CID); -NS_DEFINE_NAMED_CID(NS_INPUTSTREAMCHANNEL_CID); -NS_DEFINE_NAMED_CID(NS_STREAMLOADER_CID); -NS_DEFINE_NAMED_CID(NS_INCREMENTALSTREAMLOADER_CID); -NS_DEFINE_NAMED_CID(NS_DOWNLOADER_CID); -NS_DEFINE_NAMED_CID(NS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_BACKGROUNDFILESAVERSTREAMLISTENER_CID); -NS_DEFINE_NAMED_CID(NS_SIMPLESTREAMLISTENER_CID); -NS_DEFINE_NAMED_CID(NS_STREAMLISTENERTEE_CID); -NS_DEFINE_NAMED_CID(NS_LOADGROUP_CID); -NS_DEFINE_NAMED_CID(NS_LOCALFILEINPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_LOCALFILEOUTPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_ATOMICLOCALFILEOUTPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_SAFELOCALFILEOUTPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_INCREMENTALDOWNLOAD_CID); -NS_DEFINE_NAMED_CID(NS_STDURLPARSER_CID); -NS_DEFINE_NAMED_CID(NS_NOAUTHURLPARSER_CID); -NS_DEFINE_NAMED_CID(NS_AUTHURLPARSER_CID); -NS_DEFINE_NAMED_CID(NS_STANDARDURL_CID); -NS_DEFINE_NAMED_CID(NS_STANDARDURLMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_ARRAYBUFFERINPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_BUFFEREDINPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_BUFFEREDOUTPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_MIMEINPUTSTREAM_CID); -NS_DEFINE_NAMED_CID(NS_PROTOCOLPROXYSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_STREAMCONVERTERSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_DASHBOARD_CID); -NS_DEFINE_NAMED_CID(NS_FTPDIRLISTINGCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_NSINDEXEDTOHTMLCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_MULTIMIXEDCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_UNKNOWNDECODER_CID); -NS_DEFINE_NAMED_CID(NS_BINARYDETECTOR_CID); -NS_DEFINE_NAMED_CID(NS_HTTPCOMPRESSCONVERTER_CID); -NS_DEFINE_NAMED_CID(MOZITXTTOHTMLCONV_CID); -NS_DEFINE_NAMED_CID(NS_MIMEHEADERPARAM_CID); -NS_DEFINE_NAMED_CID(NS_FILEPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_HTTPPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_HTTPSPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_HTTPAUTHMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_HTTPACTIVITYDISTRIBUTOR_CID); -NS_DEFINE_NAMED_CID(NS_THROTTLEQUEUE_CID); -NS_DEFINE_NAMED_CID(NS_FTPPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_RESPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_EXTENSIONPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_SUBSTITUTINGURL_CID); -NS_DEFINE_NAMED_CID(NS_SUBSTITUTINGURLMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_ABOUTPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_SAFEABOUTPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_ABOUT_BLANK_MODULE_CID); -NS_DEFINE_NAMED_CID(NS_NESTEDABOUTURI_CID); -NS_DEFINE_NAMED_CID(NS_NESTEDABOUTURIMUTATOR_CID); -NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_MODULE_CID); -NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_ENTRY_MODULE_CID); -NS_DEFINE_NAMED_CID(NS_CACHESERVICE_CID); -NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHESERVICE_CID); -#ifdef NECKO_COOKIES -NS_DEFINE_NAMED_CID(NS_COOKIEMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_COOKIESERVICE_CID); -#endif -#ifdef NECKO_WIFI -NS_DEFINE_NAMED_CID(NS_WIFI_MONITOR_COMPONENT_CID); -#endif -NS_DEFINE_NAMED_CID(NS_DATAPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_VIEWSOURCEHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_WYCIWYGPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_WEBSOCKETPROTOCOLHANDLER_CID); -NS_DEFINE_NAMED_CID(NS_WEBSOCKETSSLPROTOCOLHANDLER_CID); -#if defined(XP_WIN) -NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); -#elif defined(MOZ_WIDGET_COCOA) -NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); -#elif defined(MOZ_WIDGET_ANDROID) -NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); -#elif defined(XP_LINUX) -NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); -#endif -NS_DEFINE_NAMED_CID(NS_SERIALIZATION_HELPER_CID); -NS_DEFINE_NAMED_CID(NS_CACHE_STORAGE_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_NSILOADCONTEXTINFOFACTORY_CID); -NS_DEFINE_NAMED_CID(NS_NETWORKPREDICTOR_CID); -NS_DEFINE_NAMED_CID(NS_CAPTIVEPORTAL_CID); -NS_DEFINE_NAMED_CID(NS_NETWORKCONNECTIVITYSERVICE_CID); -#ifdef BUILD_NETWORK_INFO_SERVICE -NS_DEFINE_NAMED_CID(NETWORKINFOSERVICE_CID); -#endif // BUILD_NETWORK_INFO_SERVICE - -static const mozilla::Module::CIDEntry kNeckoCIDs[] = { - // clang-format off - { &kNS_IOSERVICE_CID, false, nullptr, nsIOServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_STREAMTRANSPORTSERVICE_CID, false, nullptr, nsStreamTransportServiceConstructor }, - { &kNS_SOCKETTRANSPORTSERVICE_CID, false, nullptr, nsSocketTransportServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_SERVERSOCKET_CID, false, nullptr, nsServerSocketConstructor }, - { &kNS_TLSSERVERSOCKET_CID, false, nullptr, TLSServerSocketConstructor }, - { &kNS_UDPSOCKET_CID, false, nullptr, nsUDPSocketConstructor }, - { &kNS_DNSSERVICE_CID, false, nullptr, nsIDNSServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_IDNSERVICE_CID, false, nullptr, nsIDNServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_EFFECTIVETLDSERVICE_CID, false, nullptr, nsEffectiveTLDServiceConstructor }, - { &kNS_SIMPLEURI_CID, false, nullptr, nsSimpleURIMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, // do_CreateInstance returns mutator - { &kNS_SIMPLEURIMUTATOR_CID, false, nullptr, nsSimpleURIMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_SIMPLENESTEDURI_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor }, // do_CreateInstance returns mutator - { &kNS_SIMPLENESTEDURIMUTATOR_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor }, - { &kNS_ASYNCSTREAMCOPIER_CID, false, nullptr, nsAsyncStreamCopierConstructor }, - { &kNS_INPUTSTREAMPUMP_CID, false, nullptr, nsInputStreamPumpConstructor }, - { &kNS_INPUTSTREAMCHANNEL_CID, false, nullptr, nsInputStreamChannelConstructor }, - { &kNS_STREAMLOADER_CID, false, nullptr, mozilla::net::nsStreamLoader::Create }, - { &kNS_INCREMENTALSTREAMLOADER_CID, false, nullptr, nsIncrementalStreamLoader::Create }, - { &kNS_DOWNLOADER_CID, false, nullptr, nsDownloaderConstructor }, - { &kNS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID, false, nullptr, - mozilla::net::BackgroundFileSaverOutputStreamConstructor }, - { &kNS_BACKGROUNDFILESAVERSTREAMLISTENER_CID, false, nullptr, - mozilla::net::BackgroundFileSaverStreamListenerConstructor }, - { &kNS_SIMPLESTREAMLISTENER_CID, false, nullptr, nsSimpleStreamListenerConstructor }, - { &kNS_STREAMLISTENERTEE_CID, false, nullptr, nsStreamListenerTeeConstructor }, - { &kNS_LOADGROUP_CID, false, nullptr, nsLoadGroupConstructor }, - { &kNS_LOCALFILEINPUTSTREAM_CID, false, nullptr, nsFileInputStream::Create }, - { &kNS_LOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsFileOutputStream::Create }, - { &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsAtomicFileOutputStreamConstructor }, - { &kNS_SAFELOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsSafeFileOutputStreamConstructor }, - { &kNS_INCREMENTALDOWNLOAD_CID, false, nullptr, net_NewIncrementalDownload }, - { &kNS_STDURLPARSER_CID, false, nullptr, nsStdURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_NOAUTHURLPARSER_CID, false, nullptr, nsNoAuthURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_AUTHURLPARSER_CID, false, nullptr, nsAuthURLParserConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_STANDARDURL_CID, false, nullptr, nsStandardURLMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, // do_CreateInstance returns mutator - { &kNS_STANDARDURLMUTATOR_CID, false, nullptr, nsStandardURLMutatorConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { &kNS_ARRAYBUFFERINPUTSTREAM_CID, false, nullptr, ArrayBufferInputStreamConstructor }, - { &kNS_BUFFEREDINPUTSTREAM_CID, false, nullptr, nsBufferedInputStream::Create }, - { &kNS_BUFFEREDOUTPUTSTREAM_CID, false, nullptr, nsBufferedOutputStream::Create }, - { &kNS_MIMEINPUTSTREAM_CID, false, nullptr, nsMIMEInputStreamConstructor }, - { &kNS_PROTOCOLPROXYSERVICE_CID, true, nullptr, nsProtocolProxyServiceConstructor }, - { &kNS_STREAMCONVERTERSERVICE_CID, false, nullptr, CreateNewStreamConvServiceFactory }, - { &kNS_DASHBOARD_CID, false, nullptr, mozilla::net::DashboardConstructor }, - { &kNS_FTPDIRLISTINGCONVERTER_CID, false, nullptr, CreateNewFTPDirListingConv }, - { &kNS_NSINDEXEDTOHTMLCONVERTER_CID, false, nullptr, nsIndexedToHTML::Create }, - { &kNS_MULTIMIXEDCONVERTER_CID, false, nullptr, CreateNewMultiMixedConvFactory }, - { &kNS_UNKNOWNDECODER_CID, false, nullptr, CreateNewUnknownDecoderFactory }, - { &kNS_BINARYDETECTOR_CID, false, nullptr, CreateNewBinaryDetectorFactory }, - { &kNS_HTTPCOMPRESSCONVERTER_CID, false, nullptr, CreateNewHTTPCompressConvFactory }, - { &kMOZITXTTOHTMLCONV_CID, false, nullptr, CreateNewTXTToHTMLConvFactory }, - { &kNS_MIMEHEADERPARAM_CID, false, nullptr, nsMIMEHeaderParamImplConstructor }, - { &kNS_FILEPROTOCOLHANDLER_CID, false, nullptr, nsFileProtocolHandlerConstructor }, - { &kNS_HTTPPROTOCOLHANDLER_CID, false, nullptr, mozilla::net::nsHttpHandlerConstructor }, - { &kNS_HTTPSPROTOCOLHANDLER_CID, false, nullptr, mozilla::net::nsHttpsHandlerConstructor }, - { &kNS_HTTPAUTHMANAGER_CID, false, nullptr, mozilla::net::nsHttpAuthManagerConstructor }, - { &kNS_HTTPACTIVITYDISTRIBUTOR_CID, false, nullptr, mozilla::net::nsHttpActivityDistributorConstructor }, - { &kNS_THROTTLEQUEUE_CID, false, nullptr, mozilla::net::ThrottleQueueConstructor }, - { &kNS_FTPPROTOCOLHANDLER_CID, false, nullptr, nsFtpProtocolHandlerConstructor }, - { &kNS_RESPROTOCOLHANDLER_CID, false, nullptr, nsResProtocolHandlerConstructor }, - { &kNS_EXTENSIONPROTOCOLHANDLER_CID, false, nullptr, mozilla::ExtensionProtocolHandlerConstructor }, - { &kNS_SUBSTITUTINGURL_CID, false, nullptr, mozilla::SubstitutingURLMutatorConstructor }, // do_CreateInstance returns mutator - { &kNS_SUBSTITUTINGURLMUTATOR_CID, false, nullptr, mozilla::SubstitutingURLMutatorConstructor }, - { &kNS_ABOUTPROTOCOLHANDLER_CID, false, nullptr, nsAboutProtocolHandlerConstructor }, - { &kNS_SAFEABOUTPROTOCOLHANDLER_CID, false, nullptr, nsSafeAboutProtocolHandlerConstructor }, - { &kNS_ABOUT_BLANK_MODULE_CID, false, nullptr, nsAboutBlank::Create }, - { &kNS_NESTEDABOUTURI_CID, false, nullptr, nsNestedAboutURIMutatorConstructor }, // do_CreateInstance returns mutator - { &kNS_NESTEDABOUTURIMUTATOR_CID, false, nullptr, nsNestedAboutURIMutatorConstructor }, - { &kNS_ABOUT_CACHE_MODULE_CID, false, nullptr, nsAboutCache::Create }, - { &kNS_ABOUT_CACHE_ENTRY_MODULE_CID, false, nullptr, nsAboutCacheEntryConstructor }, - { &kNS_CACHESERVICE_CID, false, nullptr, nsCacheService::Create }, - { &kNS_APPLICATIONCACHESERVICE_CID, false, nullptr, nsApplicationCacheServiceConstructor }, -#ifdef NECKO_COOKIES - { &kNS_COOKIEMANAGER_CID, false, nullptr, nsICookieServiceConstructor }, - { &kNS_COOKIESERVICE_CID, false, nullptr, nsICookieServiceConstructor }, -#endif -#ifdef NECKO_WIFI - { &kNS_WIFI_MONITOR_COMPONENT_CID, false, nullptr, nsWifiMonitorConstructor }, -#endif - { &kNS_DATAPROTOCOLHANDLER_CID, false, nullptr, nsDataHandler::Create }, - { &kNS_VIEWSOURCEHANDLER_CID, false, nullptr, nsViewSourceHandlerConstructor }, - { &kNS_WYCIWYGPROTOCOLHANDLER_CID, false, nullptr, nsWyciwygProtocolHandlerConstructor }, - { &kNS_WEBSOCKETPROTOCOLHANDLER_CID, false, nullptr, - mozilla::net::WebSocketChannelConstructor }, - { &kNS_WEBSOCKETSSLPROTOCOLHANDLER_CID, false, nullptr, - mozilla::net::WebSocketSSLChannelConstructor }, -#if defined(XP_WIN) - { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNotifyAddrListenerConstructor }, -#elif defined(MOZ_WIDGET_COCOA) - { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNetworkLinkServiceConstructor }, -#elif defined(MOZ_WIDGET_ANDROID) - { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsAndroidNetworkLinkServiceConstructor }, -#elif defined(XP_LINUX) - { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNotifyAddrListenerConstructor }, -#endif - { &kNS_SERIALIZATION_HELPER_CID, false, nullptr, nsSerializationHelperConstructor }, - { &kNS_CACHE_STORAGE_SERVICE_CID, false, nullptr, CacheStorageServiceConstructor }, - { &kNS_NSILOADCONTEXTINFOFACTORY_CID, false, nullptr, LoadContextInfoFactoryConstructor }, - { &kNS_NETWORKPREDICTOR_CID, false, nullptr, mozilla::net::Predictor::Create }, - { &kNS_CAPTIVEPORTAL_CID, false, nullptr, mozilla::net::nsICaptivePortalServiceConstructor }, - { &kNS_NETWORKCONNECTIVITYSERVICE_CID, false, nullptr, mozilla::net::nsINetworkConnectivityServiceConstructor }, -#ifdef BUILD_NETWORK_INFO_SERVICE - { &kNETWORKINFOSERVICE_CID, false, nullptr, nsNetworkInfoServiceConstructor }, -#endif - { nullptr } - // clang-format on -}; - -static const mozilla::Module::ContractIDEntry kNeckoContracts[] = { - // clang-format off - { NS_IOSERVICE_CONTRACTID, &kNS_IOSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_NETUTIL_CONTRACTID, &kNS_IOSERVICE_CID }, - { NS_STREAMTRANSPORTSERVICE_CONTRACTID, &kNS_STREAMTRANSPORTSERVICE_CID }, - { NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &kNS_SOCKETTRANSPORTSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_SERVERSOCKET_CONTRACTID, &kNS_SERVERSOCKET_CID }, - { NS_TLSSERVERSOCKET_CONTRACTID, &kNS_TLSSERVERSOCKET_CID }, - { NS_UDPSOCKET_CONTRACTID, &kNS_UDPSOCKET_CID }, - { NS_DNSSERVICE_CONTRACTID, &kNS_DNSSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_IDNSERVICE_CONTRACTID, &kNS_IDNSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_EFFECTIVETLDSERVICE_CONTRACTID, &kNS_EFFECTIVETLDSERVICE_CID }, - { NS_SIMPLEURIMUTATOR_CONTRACTID, &kNS_SIMPLEURIMUTATOR_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_ASYNCSTREAMCOPIER_CONTRACTID, &kNS_ASYNCSTREAMCOPIER_CID }, - { NS_INPUTSTREAMPUMP_CONTRACTID, &kNS_INPUTSTREAMPUMP_CID }, - { NS_INPUTSTREAMCHANNEL_CONTRACTID, &kNS_INPUTSTREAMCHANNEL_CID }, - { NS_STREAMLOADER_CONTRACTID, &kNS_STREAMLOADER_CID }, - { NS_INCREMENTALSTREAMLOADER_CONTRACTID, &kNS_INCREMENTALSTREAMLOADER_CID }, - { NS_DOWNLOADER_CONTRACTID, &kNS_DOWNLOADER_CID }, - { NS_BACKGROUNDFILESAVEROUTPUTSTREAM_CONTRACTID, &kNS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID }, - { NS_BACKGROUNDFILESAVERSTREAMLISTENER_CONTRACTID, &kNS_BACKGROUNDFILESAVERSTREAMLISTENER_CID }, - { NS_SIMPLESTREAMLISTENER_CONTRACTID, &kNS_SIMPLESTREAMLISTENER_CID }, - { NS_STREAMLISTENERTEE_CONTRACTID, &kNS_STREAMLISTENERTEE_CID }, - { NS_LOADGROUP_CONTRACTID, &kNS_LOADGROUP_CID }, - { NS_LOCALFILEINPUTSTREAM_CONTRACTID, &kNS_LOCALFILEINPUTSTREAM_CID }, - { NS_LOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_LOCALFILEOUTPUTSTREAM_CID }, - { NS_ATOMICLOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID }, - { NS_SAFELOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_SAFELOCALFILEOUTPUTSTREAM_CID }, - { NS_INCREMENTALDOWNLOAD_CONTRACTID, &kNS_INCREMENTALDOWNLOAD_CID }, - { NS_STDURLPARSER_CONTRACTID, &kNS_STDURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_NOAUTHURLPARSER_CONTRACTID, &kNS_NOAUTHURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_AUTHURLPARSER_CONTRACTID, &kNS_AUTHURLPARSER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_STANDARDURLMUTATOR_CONTRACTID, &kNS_STANDARDURLMUTATOR_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS }, - { NS_ARRAYBUFFERINPUTSTREAM_CONTRACTID, &kNS_ARRAYBUFFERINPUTSTREAM_CID }, - { NS_BUFFEREDINPUTSTREAM_CONTRACTID, &kNS_BUFFEREDINPUTSTREAM_CID }, - { NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &kNS_BUFFEREDOUTPUTSTREAM_CID }, - { NS_MIMEINPUTSTREAM_CONTRACTID, &kNS_MIMEINPUTSTREAM_CID }, - { NS_PROTOCOLPROXYSERVICE_CONTRACTID, &kNS_PROTOCOLPROXYSERVICE_CID }, - { NS_STREAMCONVERTERSERVICE_CONTRACTID, &kNS_STREAMCONVERTERSERVICE_CID }, - { NS_DASHBOARD_CONTRACTID, &kNS_DASHBOARD_CID }, - { NS_ISTREAMCONVERTER_KEY FTP_TO_INDEX, &kNS_FTPDIRLISTINGCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY INDEX_TO_HTML, &kNS_NSINDEXEDTOHTMLCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY MULTI_MIXED_X, &kNS_MULTIMIXEDCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY MULTI_BYTERANGES, &kNS_MULTIMIXEDCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY MULTI_MIXED, &kNS_MULTIMIXEDCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY UNKNOWN_CONTENT, &kNS_UNKNOWNDECODER_CID }, - { NS_BINARYDETECTOR_CONTRACTID, &kNS_BINARYDETECTOR_CID }, - { NS_ISTREAMCONVERTER_KEY GZIP_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY XGZIP_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY BROTLI_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY COMPRESS_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY XCOMPRESS_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { NS_ISTREAMCONVERTER_KEY DEFLATE_TO_UNCOMPRESSED, &kNS_HTTPCOMPRESSCONVERTER_CID }, - { MOZ_TXTTOHTMLCONV_CONTRACTID, &kMOZITXTTOHTMLCONV_CID }, - { NS_MIMEHEADERPARAM_CONTRACTID, &kNS_MIMEHEADERPARAM_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file", &kNS_FILEPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &kNS_HTTPPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "https", &kNS_HTTPSPROTOCOLHANDLER_CID }, - { NS_HTTPAUTHMANAGER_CONTRACTID, &kNS_HTTPAUTHMANAGER_CID }, - { NS_HTTPACTIVITYDISTRIBUTOR_CONTRACTID, &kNS_HTTPACTIVITYDISTRIBUTOR_CID }, - { NS_THROTTLEQUEUE_CONTRACTID, &kNS_THROTTLEQUEUE_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &kNS_FTPPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "resource", &kNS_RESPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-extension", &kNS_EXTENSIONPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "about", &kNS_ABOUTPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-safe-about", &kNS_SAFEABOUTPROTOCOLHANDLER_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "blank", &kNS_ABOUT_BLANK_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache", &kNS_ABOUT_CACHE_MODULE_CID }, - { NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache-entry", &kNS_ABOUT_CACHE_ENTRY_MODULE_CID }, - { NS_CACHESERVICE_CONTRACTID, &kNS_CACHESERVICE_CID }, - { NS_APPLICATIONCACHESERVICE_CONTRACTID, &kNS_APPLICATIONCACHESERVICE_CID }, -#ifdef NECKO_COOKIES - { NS_COOKIEMANAGER_CONTRACTID, &kNS_COOKIEMANAGER_CID }, - { NS_COOKIESERVICE_CONTRACTID, &kNS_COOKIESERVICE_CID }, -#endif -#ifdef NECKO_WIFI - { NS_WIFI_MONITOR_CONTRACTID, &kNS_WIFI_MONITOR_COMPONENT_CID }, -#endif - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data", &kNS_DATAPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source", &kNS_VIEWSOURCEHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg", &kNS_WYCIWYGPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ws", &kNS_WEBSOCKETPROTOCOLHANDLER_CID }, - { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wss", &kNS_WEBSOCKETSSLPROTOCOLHANDLER_CID }, -#if defined(XP_WIN) - { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, -#elif defined(MOZ_WIDGET_COCOA) - { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, -#elif defined(MOZ_WIDGET_ANDROID) - { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, -#elif defined(XP_LINUX) - { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, -#endif - { NS_SERIALIZATION_HELPER_CONTRACTID, &kNS_SERIALIZATION_HELPER_CID }, - { NS_CACHE_STORAGE_SERVICE_CONTRACTID, &kNS_CACHE_STORAGE_SERVICE_CID }, - { NS_CACHE_STORAGE_SERVICE_CONTRACTID2, &kNS_CACHE_STORAGE_SERVICE_CID }, - { NS_NSILOADCONTEXTINFOFACTORY_CONTRACTID, &kNS_NSILOADCONTEXTINFOFACTORY_CID }, - { NS_NETWORKPREDICTOR_CONTRACTID, &kNS_NETWORKPREDICTOR_CID }, - { NS_CAPTIVEPORTAL_CONTRACTID, &kNS_CAPTIVEPORTAL_CID }, - { NS_NETWORKCONNECTIVITYSERVICE_CONTRACTID, &kNS_NETWORKCONNECTIVITYSERVICE_CID }, -#ifdef BUILD_NETWORK_INFO_SERVICE - { NETWORKINFOSERVICE_CONTRACT_ID, &kNETWORKINFOSERVICE_CID }, -#endif - { nullptr } - // clang-format on -}; - -static const mozilla::Module kNeckoModule = { - mozilla::Module::kVersion, - kNeckoCIDs, - kNeckoContracts, - kNeckoCategories, - nullptr, - nsNetStartup, - nsNetShutdown, - mozilla::Module::ALLOW_IN_SOCKET_PROCESS}; +static const mozilla::Module kNeckoModule = {mozilla::Module::kVersion, + nullptr, + nullptr, + kNeckoCategories, + nullptr, + nullptr, + nullptr, + mozilla::Module::ALLOW_IN_SOCKET_PROCESS}; NSMODULE_DEFN(necko) = &kNeckoModule; diff --git a/netwerk/build/nsNetModule.h b/netwerk/build/nsNetModule.h new file mode 100644 index 000000000000..05df49827a7f --- /dev/null +++ b/netwerk/build/nsNetModule.h @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +#ifndef nsNetModule_h +#define nsNetModule_h + +#include "nsID.h" + +class nsISupports; + +nsresult nsNetStartup(); +void nsNetShutdown(); + +nsresult CreateNewStreamConvServiceFactory(nsISupports* aOuter, + const nsIID& aIID, void** aResult); +nsresult CreateNewFTPDirListingConv(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult CreateNewMultiMixedConvFactory(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult CreateNewHTTPCompressConvFactory(nsISupports* aOuter, + const nsIID& aIID, void** aResult); +nsresult CreateNewUnknownDecoderFactory(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult CreateNewBinaryDetectorFactory(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult nsLoadGroupConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +nsresult nsCacheServiceConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +extern nsresult net_NewIncrementalDownload(nsISupports*, const nsIID&, void**); + +namespace mozilla { +namespace net { +nsresult WebSocketChannelConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +nsresult WebSocketSSLChannelConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aResult); +} +} + +#endif diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp index 7e06d22c1152..e9bd937ae815 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -39,6 +39,7 @@ #include "nsIOutputStream.h" #include "nsIStreamConverterService.h" #include "nsNetUtil.h" +#include "nsURLHelper.h" #include "prio.h" #include "SimpleChannel.h" diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 2997ec111f0a..644bfde08191 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -9,6 +9,7 @@ #include "mozilla/Unused.h" #include "SubstitutingProtocolHandler.h" +#include "SubstitutingURL.h" #include "nsIChannel.h" #include "nsIIOService.h" #include "nsIFile.h" diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.h b/netwerk/protocol/res/SubstitutingProtocolHandler.h index ba3c81ccb582..956166ef340e 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.h +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.h @@ -9,10 +9,8 @@ #include "nsISubstitutingProtocolHandler.h" -#include "nsIOService.h" #include "nsISubstitutionObserver.h" #include "nsDataHashtable.h" -#include "nsStandardURL.h" #include "mozilla/chrome/RegistryMessageUtils.h" #include "mozilla/Maybe.h" @@ -117,49 +115,6 @@ class SubstitutingProtocolHandler { bool mEnforceFileOrJar; }; -// SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile -// resolution -class SubstitutingURL : public nsStandardURL { - public: - virtual nsStandardURL* StartClone() override; - virtual MOZ_MUST_USE nsresult EnsureFile() override; - NS_IMETHOD GetClassIDNoAlloc(nsCID* aCID) override; - - private: - explicit SubstitutingURL() : nsStandardURL(true) {} - explicit SubstitutingURL(bool aSupportsFileURL) : nsStandardURL(true) { - MOZ_ASSERT(aSupportsFileURL); - } - virtual nsresult Clone(nsIURI** aURI) override { - return nsStandardURL::Clone(aURI); - } - - public: - class Mutator : public TemplatedMutator { - NS_DECL_ISUPPORTS - public: - explicit Mutator() = default; - - private: - virtual ~Mutator() = default; - - SubstitutingURL* Create() override { return new SubstitutingURL(); } - }; - - NS_IMETHOD Mutate(nsIURIMutator** aMutator) override { - RefPtr mutator = new SubstitutingURL::Mutator(); - nsresult rv = mutator->InitFromURI(this); - if (NS_FAILED(rv)) { - return rv; - } - mutator.forget(aMutator); - return NS_OK; - } - - friend BaseURIMutator; - friend TemplatedMutator; -}; - } // namespace net } // namespace mozilla diff --git a/netwerk/protocol/res/SubstitutingURL.h b/netwerk/protocol/res/SubstitutingURL.h new file mode 100644 index 000000000000..6212121331c9 --- /dev/null +++ b/netwerk/protocol/res/SubstitutingURL.h @@ -0,0 +1,63 @@ +/* -*- 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 + * 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/. */ + +#ifndef SubstitutingURL_h +#define SubstitutingURL_h + +#include "nsStandardURL.h" + +class nsIIOService; + +namespace mozilla { +namespace net { + +// SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile +// resolution +class SubstitutingURL : public nsStandardURL { + public: + virtual nsStandardURL* StartClone() override; + virtual MOZ_MUST_USE nsresult EnsureFile() override; + NS_IMETHOD GetClassIDNoAlloc(nsCID* aCID) override; + + private: + explicit SubstitutingURL() : nsStandardURL(true) {} + explicit SubstitutingURL(bool aSupportsFileURL) : nsStandardURL(true) { + MOZ_ASSERT(aSupportsFileURL); + } + virtual nsresult Clone(nsIURI** aURI) override { + return nsStandardURL::Clone(aURI); + } + + public: + class Mutator : public TemplatedMutator { + NS_DECL_ISUPPORTS + public: + explicit Mutator() = default; + + private: + virtual ~Mutator() = default; + + SubstitutingURL* Create() override { return new SubstitutingURL(); } + }; + + NS_IMETHOD Mutate(nsIURIMutator** aMutator) override { + RefPtr mutator = new SubstitutingURL::Mutator(); + nsresult rv = mutator->InitFromURI(this); + if (NS_FAILED(rv)) { + return rv; + } + mutator.forget(aMutator); + return NS_OK; + } + + friend BaseURIMutator; + friend TemplatedMutator; +}; + +} // namespace net +} // namespace mozilla + +#endif /* SubstitutingURL_h */ diff --git a/netwerk/protocol/res/moz.build b/netwerk/protocol/res/moz.build index 1ac1fb62f3ce..feb34c3e3ff1 100644 --- a/netwerk/protocol/res/moz.build +++ b/netwerk/protocol/res/moz.build @@ -15,6 +15,7 @@ XPIDL_MODULE = 'necko_res' EXPORTS.mozilla.net += [ 'ExtensionProtocolHandler.h', 'SubstitutingProtocolHandler.h', + 'SubstitutingURL.h', ] UNIFIED_SOURCES += [ diff --git a/netwerk/protocol/res/nsResProtocolHandler.h b/netwerk/protocol/res/nsResProtocolHandler.h index 42fef6470906..3d879560edf5 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.h +++ b/netwerk/protocol/res/nsResProtocolHandler.h @@ -11,7 +11,6 @@ #include "nsIResProtocolHandler.h" #include "nsInterfaceHashtable.h" #include "nsWeakReference.h" -#include "nsStandardURL.h" class nsISubstitutionObserver; diff --git a/netwerk/test/gtest/TestPACMan.cpp b/netwerk/test/gtest/TestPACMan.cpp index 0cd940621a10..4a3a92045f00 100644 --- a/netwerk/test/gtest/TestPACMan.cpp +++ b/netwerk/test/gtest/TestPACMan.cpp @@ -127,13 +127,13 @@ class TestPACMan : public ::testing::Test { virtual void SetUp() { ASSERT_EQ(NS_OK, GetNetworkProxyType(&originalNetworkProxyTypePref)); - nsFactoryEntry* factoryEntry = - nsComponentManagerImpl::gComponentManager->GetFactoryEntry( - kNS_TESTDHCPCLIENTSERVICE_CID); - if (factoryEntry) { - nsresult rv = - nsComponentManagerImpl::gComponentManager->UnregisterFactory( - kNS_TESTDHCPCLIENTSERVICE_CID, factoryEntry->mFactory); + nsCOMPtr factory; + nsresult rv = nsComponentManagerImpl::gComponentManager->GetClassObject( + kNS_TESTDHCPCLIENTSERVICE_CID, NS_GET_IID(nsIFactory), + getter_AddRefs(factory)); + if (NS_SUCCEEDED(rv) && factory) { + rv = nsComponentManagerImpl::gComponentManager->UnregisterFactory( + kNS_TESTDHCPCLIENTSERVICE_CID, factory); ASSERT_EQ(NS_OK, rv); } nsComponentManagerImpl::gComponentManager->RegisterModule( diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build index b5f8b5b1f582..c359d114d94d 100644 --- a/netwerk/test/gtest/moz.build +++ b/netwerk/test/gtest/moz.build @@ -36,4 +36,4 @@ FINAL_LIBRARY = 'xul-gtest' LOCAL_INCLUDES += [ '!/xpcom', '/xpcom/components' -] \ No newline at end of file +] diff --git a/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp b/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp index f348cb3f0465..890e26032c0b 100644 --- a/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp +++ b/netwerk/url-classifier/AsyncUrlChannelClassifier.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Classifier.h" +#include "mozilla/Components.h" #include "mozilla/ErrorNames.h" #include "mozilla/net/AsyncUrlChannelClassifier.h" #include "mozilla/net/UrlClassifierCommon.h" @@ -92,7 +93,7 @@ class URIData { data->mURI = aURI; nsCOMPtr utilsService = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); if (NS_WARN_IF(!utilsService)) { return NS_ERROR_FAILURE; } diff --git a/netwerk/url-classifier/nsChannelClassifier.cpp b/netwerk/url-classifier/nsChannelClassifier.cpp index 778bef291ff9..ffef0b451774 100644 --- a/netwerk/url-classifier/nsChannelClassifier.cpp +++ b/netwerk/url-classifier/nsChannelClassifier.cpp @@ -24,6 +24,7 @@ #include "nsIUrlClassifierFeature.h" #include "nsPrintfCString.h" +#include "mozilla/Components.h" #include "mozilla/ErrorNames.h" #include "mozilla/Logging.h" #include "mozilla/Preferences.h" @@ -369,7 +370,7 @@ nsresult nsChannelClassifier::SendThreatHitReport(nsIChannel* aChannel, } nsCOMPtr uriClassifier = - do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID); + components::UrlClassifierDB::Service(); if (!uriClassifier) { return NS_ERROR_UNEXPECTED; } diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index abb916a51533..dcfb6c1cee49 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -42,6 +42,7 @@ from mozbuild.frontend.data import ( StaticLibrary, UnifiedSources, XPIDLModule, + XPCOMComponentManifests, WebIDLCollection, ) from mozbuild.jar import ( @@ -148,6 +149,9 @@ class CommonBackend(BuildBackend): list(sorted(obj.all_regular_sources())), obj.unified_source_mapping) + elif isinstance(obj, XPCOMComponentManifests): + self._handle_xpcom_collection(obj) + elif isinstance(obj, UnifiedSources): # Unified sources aren't relevant to artifact builds. if self.environment.is_artifact_build: @@ -369,6 +373,20 @@ class CommonBackend(BuildBackend): manager.expected_build_output_files(), manager.GLOBAL_DEFINE_FILES) + def _handle_xpcom_collection(self, manifests): + components_dir = mozpath.join(manifests.topobjdir, + 'xpcom', 'components') + + # The code generators read their configuration from this file, so it + # needs to be written early. + o = dict( + manifests=sorted(manifests.all_sources()), + ) + + conf_file = mozpath.join(components_dir, 'manifest-lists.json') + with self._write_file(conf_file) as fh: + json.dump(o, fh, sort_keys=True, indent=2) + def _write_unified_file(self, unified_file, source_filenames, output_directory, poison_windows_h=False): with self._write_file(mozpath.join(output_directory, unified_file)) as f: diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index ff511d7b324b..3aa706bf610a 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -1766,6 +1766,13 @@ VARIABLES = { as ``MODULE``. """), + 'XPCOM_MANIFESTS': (ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList), list, + """XPCOM Component Manifest Files. + + This is a list of files that define XPCOM components to be added + to the component registry. + """), + 'PREPROCESSED_IPDL_SOURCES': (StrictOrderingOnAppendList, list, """Preprocessed IPDL source files. diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 43e32cf12ea7..12a62d832a8a 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -373,6 +373,20 @@ class IPDLCollection(ContextDerived): return sorted(set(p for p, _ in self.unified_source_mapping)) +class XPCOMComponentManifests(ContextDerived): + """Collects XPCOM manifest files during the build.""" + + def __init__(self, context): + ContextDerived.__init__(self, context) + self.manifests = set() + + def all_sources(self): + return self.manifests + + def all_source_files(self): + return [] + + class LinkageWrongKindError(Exception): """Error thrown when trying to link objects of the wrong kind""" diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index c5ff89cd22b9..be484eb4fa03 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -72,6 +72,7 @@ from .data import ( TestManifest, UnifiedSources, VariablePassthru, + XPCOMComponentManifests, XPIDLModule, ) from mozpack.chrome.manifest import ( @@ -213,12 +214,17 @@ class TreeMetadataEmitter(LoggingMixin): ('IPDL_SOURCES', lambda c: c.sources), ('PREPROCESSED_IPDL_SOURCES', lambda c: c.preprocessed_sources), ] + xpcom_attrs = [ + ('XPCOM_MANIFESTS', lambda c: c.manifests), + ] idl_sources = {} for root, cls, attrs in ((self.config.substs.get('WEBIDL_ROOT'), WebIDLCollection, webidl_attrs), (self.config.substs.get('IPDL_ROOT'), - IPDLCollection, ipdl_attrs)): + IPDLCollection, ipdl_attrs), + (self.config.substs.get('XPCOM_ROOT'), + XPCOMComponentManifests, xpcom_attrs)): if root: collection = cls(contexts[root]) for var, src_getter in attrs: @@ -1164,6 +1170,7 @@ class TreeMetadataEmitter(LoggingMixin): 'WEBIDL_FILES', 'IPDL_SOURCES', 'PREPROCESSED_IPDL_SOURCES', + 'XPCOM_MANIFESTS', ) for context_var in idl_vars: for name in context.get(context_var, []): diff --git a/security/manager/ssl/components.conf b/security/manager/ssl/components.conf new file mode 100644 index 000000000000..6701e4512b80 --- /dev/null +++ b/security/manager/ssl/components.conf @@ -0,0 +1,187 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Headers = [ + '/security/manager/ssl/nsNSSModule.h', +] + +Classes = [ + { + 'cid': '{4cb64dfd-ca98-4e24-befd-0d9285a33bcb}', + 'contract_ids': ['@mozilla.org/psm;1'], + 'type': 'nsNSSComponent', + 'headers': ['nsNSSComponent.h'], + 'init_method': 'Init', + }, + { + 'cid': '{c94f4a30-64d7-11d4-9960-00b0d02354a0}', + 'contract_ids': [ + '@mozilla.org/security/psmdownload;1', + '@mozilla.org/uriloader/psm-external-content-listener;1', + ], + 'type': 'mozilla::psm::PSMContentListener', + 'headers': ['mozilla/psm/PSMContentListener.h'], + 'init_method': 'init', + 'categories': { + 'external-uricontentlisteners': [ + 'application/x-x509-ca-cert', + 'application/x-x509-email-cert', + 'application/x-x509-server-cert', + 'application/x-x509-user-cert', + ], + }, + }, + { + 'cid': '{9ef18451-a157-4d17-8132-47afef213689}', + 'contract_ids': ['@mozilla.org/nss_errors_service;1'], + 'type': 'mozilla::psm::NSSErrorsService', + 'headers': ['NSSErrorsService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{23ad3531-11d2-4e8e-805a-6a752e91681a}', + 'contract_ids': ['@mozilla.org/security/nssversion;1'], + 'type': 'nsNSSVersion', + 'headers': ['/security/manager/ssl/nsNSSVersion.h'], + }, + { + 'cid': '{cc75499a-1dd1-11b2-8a82-ca410ac907b8}', + 'contract_ids': ['@mozilla.org/secure_browser_ui;1'], + 'type': 'nsSecureBrowserUIImpl', + 'headers': ['/security/manager/ssl/nsSecureBrowserUIImpl.h'], + }, + { + 'cid': '{47402be2-e653-45d0-8daa-9f0dce0ac148}', + 'contract_ids': ['@mozilla.org/security/local-cert-service;1'], + 'type': 'mozilla::LocalCertService', + 'headers': ['/security/manager/ssl/LocalCertService.h'], + }, + { + 'cid': '{0ae53c0f-8ea2-4916-bedc-717443c3e185}', + 'contract_ids': ['@mozilla.org/layout/form-processor;1'], + 'legacy_constructor': 'nsKeygenFormProcessor::Create', + 'headers': ['/security/manager/ssl/nsKeygenHandler.h'], + }, + { + 'cid': '{0c4f1ddc-1dd2-11b2-9d95-f2fdf113044b}', + 'contract_ids': ['@mozilla.org/security/sdr;1'], + 'type': 'SecretDecoderRing', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{b084a2ce-1dd1-11b2-bf10-8324f8e065cc}', + 'contract_ids': ['@mozilla.org/security/pk11tokendb;1'], + 'type': 'nsPK11TokenDB', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{ff9fbcd7-9517-4334-b97a-ceed78909974}', + 'contract_ids': ['@mozilla.org/security/pkcs11moduledb;1'], + 'type': 'mozilla::psm::PKCS11ModuleDB', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{660a3226-915c-4ffb-bb20-8985a632df05}', + 'contract_ids': [], + 'type': 'nsNSSCertificate', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{fb0bbc5c-452e-4783-b32c-80124693d871}', + 'contract_ids': ['@mozilla.org/security/x509certdb;1'], + 'type': 'nsNSSCertificateDB', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{959fb165-6517-487f-ab9b-d8913be53197}', + 'contract_ids': ['@mozilla.org/security/x509certlist;1'], + 'type': 'nsNSSCertList', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{36a1d3b3-d886-4317-96ff-87b0005cfef7}', + 'contract_ids': ['@mozilla.org/security/hash;1'], + 'type': 'nsCryptoHash', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{a496d0a2-dff7-4e23-bd65-1ca742fa178a}', + 'contract_ids': ['@mozilla.org/security/hmac;1'], + 'type': 'nsCryptoHMAC', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{9d383ddd-6856-4187-8485-f36195b29a0e}', + 'contract_ids': ['@mozilla.org/security/keyobject;1'], + 'type': 'nsKeyObject', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{2a35dd47-b026-4e8d-b6b7-5740f61ab902}', + 'contract_ids': ['@mozilla.org/security/keyobjectfactory;1'], + 'type': 'nsKeyObjectFactory', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{45a5fe2f-c350-4b86-962d-02d5aaaa955a}', + 'contract_ids': ['@mozilla.org/security/contentsignatureverifier;1'], + 'type': 'ContentSignatureVerifier', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{67ba681d-5485-4fff-952c-2ee337ffdcd6}', + 'contract_ids': ['@mozilla.org/security/certoverride;1'], + 'type': 'nsCertOverrideService', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{be65e2b7-fe46-4e0f-88e0-4b385db4d68a}', + 'contract_ids': ['@mozilla.org/security/random-generator;1'], + 'type': 'nsRandomGenerator', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{16786594-0296-4471-8096-8f84497ca428}', + 'contract_ids': [], + 'type': 'mozilla::psm::TransportSecurityInfo', + 'legacy_constructor': + 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{16955eee-6c48-4152-9309-c42a465138a1}', + 'contract_ids': ['@mozilla.org/ssservice;1'], + 'type': 'nsSiteSecurityService', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{11aefd53-2fbb-4c92-a0c1-053212ae42d0}', + 'contract_ids': ['@mozilla.org/security/certblocklist;1'], + 'type': 'CertBlocklist', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{57972956-5718-42d2-8070-b3fc72212eaf}', + 'contract_ids': ['@mozilla.org/security/oskeystore;1'], + 'type': 'OSKeyStore', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + { + 'cid': '{4fe082ae-6ff0-4b41-b24f-eaa664f6e46a}', + 'contract_ids': ['@mozilla.org/security/osreauthenticator;1'], + 'type': 'OSReauthenticator', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, +] + +if defined('MOZ_XUL'): + Classes += [ + { + 'cid': '{4ea60761-31d6-491d-9e34-4b53a26c416c}', + 'contract_ids': ['@mozilla.org/security/nsCertTree;1'], + 'type': 'nsCertTree', + 'legacy_constructor': 'mozilla::psm::NSSConstructor', + }, + ] diff --git a/security/manager/ssl/moz.build b/security/manager/ssl/moz.build index 9a04c5a1f729..cf6625ef2790 100644 --- a/security/manager/ssl/moz.build +++ b/security/manager/ssl/moz.build @@ -51,6 +51,10 @@ if CONFIG['MOZ_XUL']: XPIDL_MODULE = 'pipnss' +XPCOM_MANIFESTS += [ + 'components.conf', +] + # These aren't actually used in production code yet, so we don't want to # ship them with the browser. TESTING_JS_MODULES.psm += [ diff --git a/security/manager/ssl/nsNSSModule.cpp b/security/manager/ssl/nsNSSModule.cpp index 5f8cd5f6305a..c7ee273c9809 100644 --- a/security/manager/ssl/nsNSSModule.cpp +++ b/security/manager/ssl/nsNSSModule.cpp @@ -4,6 +4,8 @@ * 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/. */ +#include "nsNSSModule.h" + #include "CertBlocklist.h" #include "ContentSignatureVerifier.h" #include "NSSErrorsService.h" @@ -11,6 +13,7 @@ #include "PSMContentListener.h" #include "SecretDecoderRing.h" #include "TransportSecurityInfo.h" +#include "mozilla/MacroArgs.h" #include "mozilla/ModuleUtils.h" #include "mozilla/SyncRunnable.h" #include "nsCURILoader.h" @@ -114,154 +117,44 @@ static nsresult Constructor(nsISupports* aOuter, REFNSIID aIID, return Instantiate(aIID, aResult); } -} // namespace psm -} // namespace mozilla - -using namespace mozilla::psm; - -namespace { - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(PSMContentListener, init) - -typedef mozilla::psm::NSSErrorsService NSSErrorsService; -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NSSErrorsService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNSSVersion) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecureBrowserUIImpl) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNSSComponent, Init) - -NS_DEFINE_NAMED_CID(NS_NSSCOMPONENT_CID); -NS_DEFINE_NAMED_CID(NS_SECRETDECODERRING_CID); -NS_DEFINE_NAMED_CID(NS_PK11TOKENDB_CID); -NS_DEFINE_NAMED_CID(NS_PKCS11MODULEDB_CID); -NS_DEFINE_NAMED_CID(NS_PSMCONTENTLISTEN_CID); -NS_DEFINE_NAMED_CID(NS_X509CERT_CID); -NS_DEFINE_NAMED_CID(NS_X509CERTDB_CID); -NS_DEFINE_NAMED_CID(NS_X509CERTLIST_CID); -NS_DEFINE_NAMED_CID(NS_FORMPROCESSOR_CID); -#ifdef MOZ_XUL -NS_DEFINE_NAMED_CID(NS_CERTTREE_CID); -#endif -NS_DEFINE_NAMED_CID(NS_CRYPTO_HASH_CID); -NS_DEFINE_NAMED_CID(NS_CRYPTO_HMAC_CID); -NS_DEFINE_NAMED_CID(NS_KEYMODULEOBJECT_CID); -NS_DEFINE_NAMED_CID(NS_KEYMODULEOBJECTFACTORY_CID); -NS_DEFINE_NAMED_CID(NS_CONTENTSIGNATUREVERIFIER_CID); -NS_DEFINE_NAMED_CID(NS_CERTOVERRIDE_CID); -NS_DEFINE_NAMED_CID(NS_RANDOMGENERATOR_CID); -NS_DEFINE_NAMED_CID(TRANSPORTSECURITYINFO_CID); -NS_DEFINE_NAMED_CID(NS_NSSERRORSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_NSSVERSION_CID); -NS_DEFINE_NAMED_CID(NS_SECURE_BROWSER_UI_CID); -NS_DEFINE_NAMED_CID(NS_SITE_SECURITY_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_CERT_BLOCKLIST_CID); -NS_DEFINE_NAMED_CID(NS_OSKEYSTORE_CID); -NS_DEFINE_NAMED_CID(NS_OSREAUTHENTICATOR_CID); +#define IMPL(type, ...) \ + template <> \ + nsresult NSSConstructor(nsISupports * aOuter, const nsIID& aIID, \ + void** aResult) { \ + return Constructor(aOuter, aIID, aResult); \ + } // Components that require main thread initialization could cause a deadlock // in necko code (bug 1418752). To prevent it we initialize all such components // on main thread in advance in net_EnsurePSMInit(). Update that function when // new component with ThreadRestriction::MainThreadOnly is added. -static const mozilla::Module::CIDEntry kNSSCIDs[] = { - {&kNS_NSSCOMPONENT_CID, false, nullptr, nsNSSComponentConstructor}, - {&kNS_SECRETDECODERRING_CID, false, nullptr, - Constructor}, - {&kNS_PK11TOKENDB_CID, false, nullptr, Constructor}, - {&kNS_PKCS11MODULEDB_CID, false, nullptr, Constructor}, - {&kNS_PSMCONTENTLISTEN_CID, false, nullptr, PSMContentListenerConstructor}, - {&kNS_X509CERT_CID, false, nullptr, - Constructor}, - {&kNS_X509CERTDB_CID, false, nullptr, Constructor}, - {&kNS_X509CERTLIST_CID, false, nullptr, - Constructor}, - {&kNS_FORMPROCESSOR_CID, false, nullptr, nsKeygenFormProcessor::Create}, +IMPL(SecretDecoderRing, nullptr) +IMPL(nsPK11TokenDB, nullptr) +IMPL(PKCS11ModuleDB, nullptr) +IMPL(nsNSSCertificate, nullptr, ProcessRestriction::AnyProcess) +IMPL(nsNSSCertificateDB, nullptr) +IMPL(nsNSSCertList, nullptr, ProcessRestriction::AnyProcess) #ifdef MOZ_XUL - {&kNS_CERTTREE_CID, false, nullptr, Constructor}, +IMPL(nsCertTree, nullptr) #endif - {&kNS_CRYPTO_HASH_CID, false, nullptr, - Constructor}, - {&kNS_CRYPTO_HMAC_CID, false, nullptr, - Constructor}, - {&kNS_KEYMODULEOBJECT_CID, false, nullptr, - Constructor}, - {&kNS_KEYMODULEOBJECTFACTORY_CID, false, nullptr, - Constructor}, - {&kNS_CONTENTSIGNATUREVERIFIER_CID, false, nullptr, - Constructor}, - {&kNS_CERTOVERRIDE_CID, false, nullptr, - Constructor}, - {&kNS_RANDOMGENERATOR_CID, false, nullptr, - Constructor}, - {&kTRANSPORTSECURITYINFO_CID, false, nullptr, - Constructor}, - {&kNS_NSSERRORSSERVICE_CID, false, nullptr, NSSErrorsServiceConstructor}, - {&kNS_NSSVERSION_CID, false, nullptr, nsNSSVersionConstructor}, - {&kNS_SECURE_BROWSER_UI_CID, false, nullptr, - nsSecureBrowserUIImplConstructor}, - {&kNS_SITE_SECURITY_SERVICE_CID, false, nullptr, - Constructor}, - {&kNS_CERT_BLOCKLIST_CID, false, nullptr, - Constructor}, - {&kNS_OSKEYSTORE_CID, false, nullptr, - Constructor}, - {&kNS_OSREAUTHENTICATOR_CID, false, nullptr, - Constructor}, - {nullptr}}; +IMPL(nsCryptoHash, nullptr, ProcessRestriction::AnyProcess) +IMPL(nsCryptoHMAC, nullptr, ProcessRestriction::AnyProcess) +IMPL(nsKeyObject, nullptr, ProcessRestriction::AnyProcess) +IMPL(nsKeyObjectFactory, nullptr, ProcessRestriction::AnyProcess) +IMPL(ContentSignatureVerifier, nullptr) +IMPL(nsCertOverrideService, &nsCertOverrideService::Init, + ProcessRestriction::ParentProcessOnly, ThreadRestriction::MainThreadOnly) +IMPL(nsRandomGenerator, nullptr, ProcessRestriction::AnyProcess) +IMPL(TransportSecurityInfo, nullptr, ProcessRestriction::AnyProcess) +IMPL(nsSiteSecurityService, &nsSiteSecurityService::Init, + ProcessRestriction::AnyProcess, ThreadRestriction::MainThreadOnly) +IMPL(CertBlocklist, &CertBlocklist::Init, ProcessRestriction::ParentProcessOnly, + ThreadRestriction::MainThreadOnly) +IMPL(OSKeyStore, nullptr, ProcessRestriction::ParentProcessOnly, + ThreadRestriction::MainThreadOnly) +IMPL(OSReauthenticator, nullptr, ProcessRestriction::ParentProcessOnly, + ThreadRestriction::MainThreadOnly) +#undef IMPL -static const mozilla::Module::ContractIDEntry kNSSContracts[] = { - {PSM_COMPONENT_CONTRACTID, &kNS_NSSCOMPONENT_CID}, - {NS_NSS_ERRORS_SERVICE_CONTRACTID, &kNS_NSSERRORSSERVICE_CID}, - {NS_NSSVERSION_CONTRACTID, &kNS_NSSVERSION_CID}, - {NS_SECRETDECODERRING_CONTRACTID, &kNS_SECRETDECODERRING_CID}, - {NS_PK11TOKENDB_CONTRACTID, &kNS_PK11TOKENDB_CID}, - {NS_PKCS11MODULEDB_CONTRACTID, &kNS_PKCS11MODULEDB_CID}, - {NS_PSMCONTENTLISTEN_CONTRACTID, &kNS_PSMCONTENTLISTEN_CID}, - {NS_X509CERTDB_CONTRACTID, &kNS_X509CERTDB_CID}, - {NS_X509CERTLIST_CONTRACTID, &kNS_X509CERTLIST_CID}, - {NS_FORMPROCESSOR_CONTRACTID, &kNS_FORMPROCESSOR_CID}, -#ifdef MOZ_XUL - {NS_CERTTREE_CONTRACTID, &kNS_CERTTREE_CID}, -#endif - {NS_CRYPTO_HASH_CONTRACTID, &kNS_CRYPTO_HASH_CID}, - {NS_CRYPTO_HMAC_CONTRACTID, &kNS_CRYPTO_HMAC_CID}, - {"@mozilla.org/uriloader/psm-external-content-listener;1", - &kNS_PSMCONTENTLISTEN_CID}, - {NS_KEYMODULEOBJECT_CONTRACTID, &kNS_KEYMODULEOBJECT_CID}, - {NS_KEYMODULEOBJECTFACTORY_CONTRACTID, &kNS_KEYMODULEOBJECTFACTORY_CID}, - {NS_CONTENTSIGNATUREVERIFIER_CONTRACTID, &kNS_CONTENTSIGNATUREVERIFIER_CID}, - {NS_CERTOVERRIDE_CONTRACTID, &kNS_CERTOVERRIDE_CID}, - {NS_RANDOMGENERATOR_CONTRACTID, &kNS_RANDOMGENERATOR_CID}, - {NS_SECURE_BROWSER_UI_CONTRACTID, &kNS_SECURE_BROWSER_UI_CID}, - {NS_SSSERVICE_CONTRACTID, &kNS_SITE_SECURITY_SERVICE_CID}, - {NS_CERTBLOCKLIST_CONTRACTID, &kNS_CERT_BLOCKLIST_CID}, - {NS_OSKEYSTORE_CONTRACTID, &kNS_OSKEYSTORE_CID}, - {NS_OSREAUTHENTICATOR_CONTRACTID, &kNS_OSREAUTHENTICATOR_CID}, - {nullptr}}; - -static const mozilla::Module::CategoryEntry kNSSCategories[] = { - {NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY, "application/x-x509-ca-cert", - "@mozilla.org/uriloader/psm-external-content-listener;1"}, - {NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY, - "application/x-x509-server-cert", - "@mozilla.org/uriloader/psm-external-content-listener;1"}, - {NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY, "application/x-x509-user-cert", - "@mozilla.org/uriloader/psm-external-content-listener;1"}, - {NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY, "application/x-x509-email-cert", - "@mozilla.org/uriloader/psm-external-content-listener;1"}, - {nullptr}}; - -static const mozilla::Module kNSSModule = {mozilla::Module::kVersion, kNSSCIDs, - kNSSContracts, kNSSCategories}; - -} // unnamed namespace - -NSMODULE_DEFN(NSS) = &kNSSModule; +} // namespace psm +} // namespace mozilla diff --git a/security/manager/ssl/nsNSSModule.h b/security/manager/ssl/nsNSSModule.h new file mode 100644 index 000000000000..1f2024f5736c --- /dev/null +++ b/security/manager/ssl/nsNSSModule.h @@ -0,0 +1,23 @@ +/* -*- 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 + * 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/. */ + +#ifndef nsNSSModule_h +#define nsNSSModule_h + +#include "nsID.h" + +class nsISupports; + +namespace mozilla { +namespace psm { +template +nsresult NSSConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aInstancePtr); + +} +} // namespace mozilla + +#endif // nsNSSModule_h diff --git a/security/manager/ssl/nsSecureBrowserUIImpl.h b/security/manager/ssl/nsSecureBrowserUIImpl.h index cc7827aa1906..8a2556723202 100644 --- a/security/manager/ssl/nsSecureBrowserUIImpl.h +++ b/security/manager/ssl/nsSecureBrowserUIImpl.h @@ -8,6 +8,7 @@ #include "nsCOMPtr.h" #include "nsISecureBrowserUI.h" +#include "nsITransportSecurityInfo.h" #include "nsIWebProgressListener.h" #include "nsWeakReference.h" diff --git a/taskcluster/ci/test/mochitest.yml b/taskcluster/ci/test/mochitest.yml index a93e7bb75dee..99b56fca534a 100644 --- a/taskcluster/ci/test/mochitest.yml +++ b/taskcluster/ci/test/mochitest.yml @@ -231,6 +231,21 @@ mochitest-devtools-chrome: # Bug 1296086: high number of intermittents observed with software GL and large instances allow-software-gl-layers: false +mochitest-devtools-webreplay: + description: "Mochitest devtools-webreplay run" + suite: mochitest/mochitest-devtools-webreplay + treeherder-symbol: M(dt-wr) + loopback-video: true + tier: 2 + max-run-time: 900 + mozharness: + mochitest-flavor: chrome + allow-software-gl-layers: false + run-on-projects: + by-test-platform: + macosx64.*/opt: ['trunk', 'try'] + default: [] + mochitest-gpu: description: "Mochitest GPU run" suite: mochitest/gpu diff --git a/taskcluster/ci/test/test-sets.yml b/taskcluster/ci/test/test-sets.yml index 49c0f626264a..d7699012220a 100644 --- a/taskcluster/ci/test/test-sets.yml +++ b/taskcluster/ci/test/test-sets.yml @@ -279,6 +279,7 @@ macosx64-tests: - mochitest-chrome - mochitest-clipboard - mochitest-devtools-chrome + - mochitest-devtools-webreplay - mochitest-gpu - mochitest-media - mochitest-webgl1-core diff --git a/testing/modules/MockRegistrar.jsm b/testing/modules/MockRegistrar.jsm index 2a08e2464e74..7c7e3dd11eef 100644 --- a/testing/modules/MockRegistrar.jsm +++ b/testing/modules/MockRegistrar.jsm @@ -11,8 +11,13 @@ var EXPORTED_SYMBOLS = [ const Cm = Components.manager; const {Log} = ChromeUtils.import("resource://gre/modules/Log.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); var logger = Log.repository.getLogger("MockRegistrar"); +XPCOMUtils.defineLazyServiceGetter(this, "UUIDGen", + "@mozilla.org/uuid-generator;1", + "nsIUUIDGenerator"); + var MockRegistrar = Object.freeze({ _registeredComponents: new Map(), _originalCIDs: new Map(), @@ -44,6 +49,8 @@ var MockRegistrar = Object.freeze({ let originalFactory = Cm.getClassObject(originalCID, Ci.nsIFactory); + let cid = UUIDGen.generateUUID(); + let factory = { createInstance(outer, iid) { if (outer) { @@ -73,19 +80,18 @@ var MockRegistrar = Object.freeze({ QueryInterface: ChromeUtils.generateQI([Ci.nsIFactory]), }; - this.registrar.unregisterFactory(originalCID, originalFactory); - this.registrar.registerFactory(originalCID, + this.registrar.registerFactory(cid, "A Mock for " + contractID, contractID, factory); - this._registeredComponents.set(originalCID, { + this._registeredComponents.set(cid, { contractID, factory, - originalFactory, + originalCID, }); - return originalCID; + return cid; }, /** @@ -100,11 +106,12 @@ var MockRegistrar = Object.freeze({ } this.registrar.unregisterFactory(cid, component.factory); - if (component.originalFactory) { - this.registrar.registerFactory(cid, - "", + if (component.originalCID) { + // Passing `null` for the factory re-maps the contract ID to the + // entry for its original CID. + this.registrar.registerFactory(component.originalCID, "", component.contractID, - component.originalFactory); + null); } this._registeredComponents.delete(cid); diff --git a/testing/mozharness/configs/unittests/mac_unittest.py b/testing/mozharness/configs/unittests/mac_unittest.py index 4e752b7e992f..f0e72b631cc8 100644 --- a/testing/mozharness/configs/unittests/mac_unittest.py +++ b/testing/mozharness/configs/unittests/mac_unittest.py @@ -144,6 +144,7 @@ config = { "mochitest-webgl2-deqp": ["--subsuite=webgl2-deqp"], "mochitest-devtools-chrome": ["--flavor=browser", "--subsuite=devtools"], "mochitest-devtools-chrome-chunked": ["--flavor=browser", "--subsuite=devtools", "--chunk-by-runtime"], + "mochitest-devtools-webreplay": ["--flavor=browser", "--subsuite=devtools-webreplay"], "a11y": ["--flavor=a11y"], }, # local reftest suites diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 9fc80bf110c0..0eeb0d289bed 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -248,18 +248,17 @@ var _fakeIdleService = { Components.manager.QueryInterface(Ci.nsIComponentRegistrar); }, contractID: "@mozilla.org/widget/idleservice;1", - get CID() { - return this.registrar.contractIDToCID(this.contractID); - }, + CID: Components.ID("{9163a4ae-70c2-446c-9ac1-bbe4ab93004e}"), activate: function FIS_activate() { - if (!this.originalFactory) { - // Save original factory. - this.originalFactory = - Components.manager.getClassObject(Cc[this.contractID], - Ci.nsIFactory); - // Unregister original factory. - this.registrar.unregisterFactory(this.CID, this.originalFactory); + if (!this.originalCID) { + // This is useless, except to the extent that it has the + // side-effect of initializing the widget module, which some + // callers unfortunately accidentally rely on. + void Components.manager.getClassObject(Cc[this.contractID], + Ci.nsIFactory); + + this.originalCID = this.registrar.contractIDToCID(this.contractID); // Replace with the mock. this.registrar.registerFactory(this.CID, "Fake Idle Service", this.contractID, this.factory @@ -268,13 +267,13 @@ var _fakeIdleService = { }, deactivate: function FIS_deactivate() { - if (this.originalFactory) { + if (this.originalCID) { // Unregister the mock. this.registrar.unregisterFactory(this.CID, this.factory); // Restore original factory. - this.registrar.registerFactory(this.CID, "Idle Service", - this.contractID, this.originalFactory); - delete this.originalFactory; + this.registrar.registerFactory(this.originalCID, "Idle Service", + this.contractID, null); + delete this.originalCID; } }, diff --git a/toolkit/components/build/components.conf b/toolkit/components/build/components.conf new file mode 100644 index 000000000000..9d0beafff031 --- /dev/null +++ b/toolkit/components/build/components.conf @@ -0,0 +1,207 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +IS_ANDROID = buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'android' +IS_WINDOWS = buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'windows' + +MOZ_HAS_TERMINATOR = not IS_ANDROID + +Classes = [ + { + 'name': 'AddonContentPolicy', + 'cid': '{c26a8241-ecf4-4aed-9f3c-f1f5c713b9a5}', + 'contract_ids': ['@mozilla.org/addons/content-policy;1'], + 'type': 'AddonContentPolicy', + 'headers': ['mozilla/AddonContentPolicy.h'], + 'categories': {'content-policy': '@mozilla.org/addons/content-policy;1'}, + }, + { + 'cid': '{17a59a6b-92b8-42e5-bce0-ab434c7a7135}', + 'contract_ids': ['@mozilla.org/addons/addon-manager-startup;1'], + 'singleton': True, + 'type': 'mozilla::AddonManagerStartup', + 'headers': ['mozilla/AddonManagerStartup.h'], + 'constructor': 'mozilla::AddonManagerStartup::GetInstance', + }, + { + 'name': 'AlertNotification', + 'cid': '{9a7b7a41-0b47-47f7-b61b-15a210d6f020}', + 'contract_ids': ['@mozilla.org/alert-notification;1'], + 'type': 'mozilla::AlertNotification', + 'headers': ['mozilla/AlertNotification.h'], + }, + { + 'name': 'ApplicationReputation', + 'cid': '{d21b4c33-716f-4117-8041-2770b59ff8a6}', + 'contract_ids': ['@mozilla.org/reputationservice/application-reputation-service;1'], + 'singleton': True, + 'type': 'ApplicationReputationService', + 'headers': ['/toolkit/components/reputationservice/ApplicationReputation.h'], + 'constructor': 'ApplicationReputationService::GetSingleton', + }, + { + 'name': 'DownloadPlatform', + 'cid': '{649a14c9-fe5c-48ec-9c85-00cad9ccf32e}', + 'contract_ids': ['@mozilla.org/toolkit/download-platform;1'], + 'type': 'DownloadPlatform', + 'headers': ['/toolkit/components/downloads/DownloadPlatform.h'], + }, + { + 'name': 'ExtensionPolicy', + 'cid': '{562de129-8338-482c-bb96-a1ff09ee53cc}', + 'contract_ids': ['@mozilla.org/addons/policy-service;1'], + 'singleton': True, + 'type': 'mozilla::ExtensionPolicyService', + 'headers': ['mozilla/ExtensionPolicyService.h'], + 'constructor': 'mozilla::ExtensionPolicyService::GetInstance', + }, + { + 'cid': '{15686f9d-483e-4361-98cd-37f1e8f1e61d}', + 'contract_ids': ['@mozilla.org/toolkit/finalizationwitness;1'], + 'type': 'mozilla::FinalizationWitnessService', + 'headers': ['mozilla/FinalizationWitnessService.h'], + 'init_method': 'Init', + }, + { + 'name': 'LoginReputation', + 'cid': '{91fa9e67-1427-4ee9-8ee0-1a6ed578bee1}', + 'contract_ids': ['@mozilla.org/reputationservice/login-reputation-service;1'], + 'singleton': True, + 'type': 'mozilla::LoginReputationService', + 'headers': ['/toolkit/components/reputationservice/LoginReputation.h'], + 'constructor': 'mozilla::LoginReputationService::GetSingleton', + }, + { + 'name': 'NativeFileWatcher', + 'cid': '{6f488507-469d-4350-a68d-99c807be0a78}', + 'contract_ids': ['@mozilla.org/toolkit/filewatcher/native-file-watcher;1'], + 'type': 'mozilla::NativeFileWatcherService', + 'headers': ['NativeFileWatcherWin.h' if IS_WINDOWS else 'NativeFileWatcherNotSupported.h'], + 'init_method': 'Init', + }, + { + 'cid': '{63a69303-8a64-45a9-848c-d4e2792794e6}', + 'contract_ids': ['@mozilla.org/toolkit/osfile/native-internals;1'], + 'type': 'mozilla::NativeOSFileInternalsService', + 'headers': ['mozilla/NativeOSFileInternals.h'], + }, + { + 'name': 'Alerts', + 'cid': '{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}', + 'contract_ids': ['@mozilla.org/alerts-service;1'], + 'type': 'nsAlertsService', + 'headers': ['/toolkit/components/alerts/nsAlertsService.h'], + 'overridable': True, + }, + { + 'name': 'AppStartup', + 'cid': '{7dd4d320-c84b-4624-8d45-7bb9b2356977}', + 'contract_ids': ['@mozilla.org/toolkit/app-startup;1'], + 'type': 'nsAppStartup', + 'headers': ['/toolkit/components/startup/nsAppStartup.h'], + 'init_method': 'Init', + }, + { + 'cid': '{6356aa16-7916-4215-a825-cbc2692ca87a}', + 'contract_ids': ['@mozilla.org/appshell/component/browser-status-filter;1'], + 'type': 'nsBrowserStatusFilter', + 'headers': ['/toolkit/components/statusfilter/nsBrowserStatusFilter.h'], + }, + { + 'name': 'FindService', + 'cid': '{5060b803-340e-11d5-be5b-b3e063ec6a3c}', + 'contract_ids': ['@mozilla.org/find/find_service;1'], + 'type': 'nsFindService', + 'headers': ['/toolkit/components/find/nsFindService.h'], + }, + { + 'name': 'TypeAheadFind', + 'cid': '{e7f70966-9a37-48d7-8aeb-35998f31090e}', + 'contract_ids': ['@mozilla.org/typeaheadfind;1'], + 'type': 'nsTypeAheadFind', + 'headers': ['/toolkit/components/typeaheadfind/nsTypeAheadFind.h'], + }, + { + 'name': 'UrlClassifierDB', + 'cid': '{7a258022-6765-11e5-b379-b37b1f2354be}', + 'contract_ids': [ + '@mozilla.org/uriclassifierservice', + '@mozilla.org/url-classifier/dbservice;1', + ], + 'type': 'nsISupports', + 'legacy_constructor': 'nsUrlClassifierDBServiceConstructor', + 'headers': ['/toolkit/components/build/nsToolkitCompsModule.h'], + }, + { + 'name': 'UrlClassifierPrefixSet', + 'cid': '{3d8579f0-75fa-4e00-ba41-38661d5b5d17}', + 'contract_ids': ['@mozilla.org/url-classifier/prefixset;1'], + 'type': 'nsUrlClassifierPrefixSet', + 'headers': ['nsUrlClassifierPrefixSet.h'], + }, + { + 'name': 'UrlClassifierStreamUpdater', + 'cid': '{e1797597-f4d6-4dd3-a1e1-745ad352cd80}', + 'contract_ids': ['@mozilla.org/url-classifier/streamupdater;1'], + 'type': 'nsUrlClassifierStreamUpdater', + 'headers': ['/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h'], + }, + { + 'name': 'UrlClassifierUtils', + 'cid': '{b7b2ccec-7912-4ea6-a548-b038447004bd}', + 'contract_ids': ['@mozilla.org/url-classifier/utils;1'], + 'type': 'nsUrlClassifierUtils', + 'headers': ['/toolkit/components/url-classifier/nsUrlClassifierUtils.h'], + 'init_method': 'Init', + }, + { + 'name': 'UserInfo', + 'cid': '{14c13684-1dd2-11b2-9463-bb10ba742554}', + 'contract_ids': ['@mozilla.org/userinfo;1'], + 'type': 'nsUserInfo', + 'headers': ['/toolkit/components/startup/nsUserInfo.h'], + }, +] + +if defined('MOZ_UPDATER') and not IS_ANDROID: + Classes += [ + { + 'cid': '{f3dcf644-79e8-4f59-a1bb-878454488ef9}', + 'contract_ids': ['@mozilla.org/updates/update-processor;1'], + 'type': 'nsUpdateProcessor', + 'headers': ['/toolkit/xre/nsUpdateDriver.h'], + }, + ] + +if not defined('MOZ_DISABLE_PARENTAL_CONTROLS'): + Classes += [ + { + 'cid': '{580530e5-118c-4bc7-ab88-bc2cd2b97223}', + 'contract_ids': ['@mozilla.org/parental-controls-service;1'], + 'type': 'nsParentalControlsService', + 'headers': ['/toolkit/components/parentalcontrols/nsParentalControlsService.h'], + }, + ] + +if MOZ_HAS_TERMINATOR: + Classes += [ + { + 'cid': '{2e59cc70-f83a-412f-89d4-453885837217}', + 'contract_ids': ['@mozilla.org/toolkit/shutdown-terminator;1'], + 'type': 'mozilla::nsTerminator', + 'headers': ['nsTerminator.h'], + }, + ] + +if defined('ENABLE_TESTS'): + Classes += [ + { + 'cid': '{aaa3f7f2-8ef0-41ec-8d03-aed667cf7fa2}', + 'contract_ids': ['@mozilla.org/telemetry/geckoview-testing;1'], + 'type': 'TelemetryGeckoViewTestingImpl', + 'headers': ['/toolkit/components/telemetry/geckoview/TelemetryGeckoViewTesting.h'], + }, + ] diff --git a/toolkit/components/build/moz.build b/toolkit/components/build/moz.build index c1744991f6b6..294d2112499a 100644 --- a/toolkit/components/build/moz.build +++ b/toolkit/components/build/moz.build @@ -15,27 +15,15 @@ SOURCES += [ 'nsToolkitCompsModule.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ - '../../xre', - '../alerts', - '../downloads', - '../find', - '../perfmonitoring', - '../protobuf', - '../reputationservice', - '../startup', - '../statusfilter', - '../telemetry', - '../typeaheadfind', '../url-classifier', ] -if not CONFIG['MOZ_DISABLE_PARENTAL_CONTROLS']: - LOCAL_INCLUDES += [ - '../parentalcontrols', - ] - if CONFIG['CC_TYPE'] == 'clang-cl': AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/toolkit/components/build/nsToolkitCompsCID.h b/toolkit/components/build/nsToolkitCompsCID.h index 6c9b76aa93e6..459f2e07b192 100644 --- a/toolkit/components/build/nsToolkitCompsCID.h +++ b/toolkit/components/build/nsToolkitCompsCID.h @@ -2,8 +2,6 @@ * 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/. */ -#define NS_ALERTSERVICE_CONTRACTID "@mozilla.org/alerts-service;1" - // This separate service uses the same nsIAlertsService interface, // but instead sends a notification to a platform alerts API // if available. Using a separate CID allows us to overwrite the XUL @@ -19,9 +17,6 @@ #define NS_AUTOCOMPLETEMDBRESULT_CONTRACTID \ "@mozilla.org/autocomplete/mdb-result;1" -#define NS_DOWNLOADPLATFORM_CONTRACTID \ - "@mozilla.org/toolkit/download-platform;1" - #define NS_FORMHISTORY_CONTRACTID "@mozilla.org/satchel/form-history;1" #define NS_FORMFILLCONTROLLER_CONTRACTID \ @@ -30,22 +25,6 @@ #define NS_FORMHISTORYAUTOCOMPLETE_CONTRACTID \ "@mozilla.org/autocomplete/search;1?name=form-history" -#define NS_TYPEAHEADFIND_CONTRACTID "@mozilla.org/typeaheadfind;1" - -#define NS_PARENTALCONTROLSSERVICE_CONTRACTID \ - "@mozilla.org/parental-controls-service;1" - -#define NS_URLCLASSIFIERPREFIXSET_CONTRACTID \ - "@mozilla.org/url-classifier/prefixset;1" - -#define NS_URLCLASSIFIERDBSERVICE_CONTRACTID \ - "@mozilla.org/url-classifier/dbservice;1" - -#define NS_URLCLASSIFIERSTREAMUPDATER_CONTRACTID \ - "@mozilla.org/url-classifier/streamupdater;1" - -#define NS_URLCLASSIFIERUTILS_CONTRACTID "@mozilla.org/url-classifier/utils;1" - #define NS_URLCLASSIFIERHASHCOMPLETER_CONTRACTID \ "@mozilla.org/url-classifier/hashcompleter;1" @@ -62,37 +41,8 @@ #define NS_FAVICONSERVICE_CONTRACTID "@mozilla.org/browser/favicon-service;1" -#define NS_APPSTARTUP_CONTRACTID "@mozilla.org/toolkit/app-startup;1" - -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) -# define NS_UPDATEPROCESSOR_CONTRACTID \ - "@mozilla.org/updates/update-processor;1" -#endif - -#define NS_ADDONCONTENTPOLICY_CONTRACTID "@mozilla.org/addons/content-policy;1" - -#if defined(ENABLE_TESTS) -# define NS_TELEMETRYGECKOVIEWTESTING_CONTRACTID \ - "@mozilla.org/telemetry/geckoview-testing;1" -#endif - ///////////////////////////////////////////////////////////////////////////// -#define ALERT_NOTIFICATION_CID \ - { \ - 0x9a7b7a41, 0x0b47, 0x47f7, { \ - 0xb6, 0x1b, 0x15, 0xa2, 0x10, 0xd6, 0xf0, 0x20 \ - } \ - } - -// {A0CCAAF8-09DA-44D8-B250-9AC3E93C8117} -#define NS_ALERTSSERVICE_CID \ - { \ - 0xa0ccaaf8, 0x9da, 0x44d8, { \ - 0xb2, 0x50, 0x9a, 0xc3, 0xe9, 0x3c, 0x81, 0x17 \ - } \ - } - // {84E11F80-CA55-11DD-AD8B-0800200C9A66} #define NS_SYSTEMALERTSSERVICE_CID \ { \ @@ -125,13 +75,6 @@ } \ } -#define NS_DOWNLOADPLATFORM_CID \ - { \ - 0x649a14c9, 0xfe5c, 0x48ec, { \ - 0x9c, 0x85, 0x00, 0xca, 0xd9, 0xcc, 0xf3, 0x2e \ - } \ - } - // {895DB6C7-DBDF-40ea-9F64-B175033243DC} #define NS_FORMFILLCONTROLLER_CID \ { \ @@ -148,30 +91,6 @@ } \ } -// {59648a91-5a60-4122-8ff2-54b839c84aed} -#define NS_PARENTALCONTROLSSERVICE_CID \ - { \ - 0x580530e5, 0x118c, 0x4bc7, { \ - 0xab, 0x88, 0xbc, 0x2c, 0xd2, 0xb9, 0x72, 0x23 \ - } \ - } - -// {e7f70966-9a37-48d7-8aeb-35998f31090e} -#define NS_TYPEAHEADFIND_CID \ - { \ - 0xe7f70966, 0x9a37, 0x48d7, { \ - 0x8a, 0xeb, 0x35, 0x99, 0x8f, 0x31, 0x09, 0x0e \ - } \ - } - -// {3d8579f0-75fa-4e00-ba41-38661d5b5d17} -#define NS_URLCLASSIFIERPREFIXSET_CID \ - { \ - 0x3d8579f0, 0x75fa, 0x4e00, { \ - 0xba, 0x41, 0x38, 0x66, 0x1d, 0x5b, 0x5d, 0x17 \ - } \ - } - // {7a258022-6765-11e5-b379-b37b1f2354be} #define NS_URLCLASSIFIERDBSERVICE_CID \ { \ @@ -180,22 +99,6 @@ } \ } -// e1797597-f4d6-4dd3-a1e1-745ad352cd80 -#define NS_URLCLASSIFIERSTREAMUPDATER_CID \ - { \ - 0xe1797597, 0xf4d6, 0x4dd3, { \ - 0xa1, 0xe1, 0x74, 0x5a, 0xd3, 0x52, 0xcd, 0x80 \ - } \ - } - -// {b7b2ccec-7912-4ea6-a548-b038447004bd} -#define NS_URLCLASSIFIERUTILS_CID \ - { \ - 0xb7b2ccec, 0x7912, 0x4ea6, { \ - 0xa5, 0x48, 0xb0, 0x38, 0x44, 0x70, 0x04, 0xbd \ - } \ - } - #define NS_NAVHISTORYSERVICE_CID \ { \ 0x88cecbb7, 0x6c63, 0x4b3b, { \ @@ -230,57 +133,3 @@ 0xb6, 0x05, 0x60, 0xb0, 0x22, 0xa0, 0x07, 0x56 \ } \ } - -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) -# define NS_UPDATEPROCESSOR_CID \ - { \ - 0xf3dcf644, 0x79e8, 0x4f59, { \ - 0xa1, 0xbb, 0x87, 0x84, 0x54, 0x48, 0x8e, 0xf9 \ - } \ - } -#endif - -#define NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID \ - "@mozilla.org/reputationservice/application-reputation-service;1" - -#define NS_APPLICATION_REPUTATION_SERVICE_CID \ - { \ - 0xd21b4c33, 0x716f, 0x4117, { \ - 0x80, 0x41, 0x27, 0x70, 0xb5, 0x9f, 0xf8, 0xa6 \ - } \ - } - -#define NS_LOGIN_REPUTATION_SERVICE_CONTRACTID \ - "@mozilla.org/reputationservice/login-reputation-service;1" - -#define NS_LOGIN_REPUTATION_SERVICE_CID \ - { \ - 0x91fa9e67, 0x1427, 0x4ee9, { \ - 0x8e, 0xe0, 0x1a, 0x6e, 0xd5, 0x78, 0xbe, 0xe1 \ - } \ - } - -#define NS_ADDONCONTENTPOLICY_CID \ - { \ - 0xc26a8241, 0xecf4, 0x4aed, { \ - 0x9f, 0x3c, 0xf1, 0xf5, 0xc7, 0x13, 0xb9, 0xa5 \ - } \ - } - -#define NS_ADDON_POLICY_SERVICE_CID \ - { \ - 0x562de129, 0x8338, 0x482c, { \ - 0xbb, 0x96, 0xa1, 0xff, 0x09, 0xee, 0x53, 0xcc \ - } \ - } - -#define NS_ADDON_POLICY_SERVICE_CONTRACTID \ - "@mozilla.org/addons/policy-service;1" - -#if defined(ENABLE_TESTS) -# define NS_TELEMETRYGECKOVIEWTESTING_CID \ - {0xaaa3f7f2, \ - 0x8ef0, \ - 0x41ec, \ - {0x8d, 0x3, 0xae, 0xd6, 0x67, 0xcf, 0x7f, 0xa2}}; -#endif diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp index 51772a08dd8e..d17e8fff2a21 100644 --- a/toolkit/components/build/nsToolkitCompsModule.cpp +++ b/toolkit/components/build/nsToolkitCompsModule.cpp @@ -2,256 +2,36 @@ * 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/. */ -#include "mozilla/ModuleUtils.h" -#include "nsAppStartup.h" -#include "nsNetCID.h" -#include "nsUserInfo.h" -#include "nsToolkitCompsCID.h" -#include "nsFindService.h" -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) -# include "nsUpdateDriver.h" -#endif +#include "nsToolkitCompsModule.h" -#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) -# include "nsParentalControlsService.h" -#endif - -#include "mozilla/AlertNotification.h" -#include "nsAlertsService.h" - -#include "DownloadPlatform.h" - -#include "nsTypeAheadFind.h" - -#include "ApplicationReputation.h" -#include "LoginReputation.h" #include "nsUrlClassifierDBService.h" -#include "nsUrlClassifierStreamUpdater.h" -#include "nsUrlClassifierUtils.h" -#include "nsUrlClassifierPrefixSet.h" - -#include "nsBrowserStatusFilter.h" -#include "mozilla/FinalizationWitnessService.h" -#include "mozilla/NativeOSFileInternals.h" -#include "mozilla/AddonContentPolicy.h" -#include "mozilla/AddonManagerStartup.h" -#include "mozilla/ExtensionPolicyService.h" +#include "nsISupports.h" #if defined(XP_WIN) # include "NativeFileWatcherWin.h" #else # include "NativeFileWatcherNotSupported.h" + +NS_IMPL_ISUPPORTS(mozilla::NativeFileWatcherService, + nsINativeFileWatcherService); #endif // (XP_WIN) -#if !defined(MOZ_WIDGET_ANDROID) -# define MOZ_HAS_TERMINATOR -#endif - -#if defined(MOZ_HAS_TERMINATOR) -# include "nsTerminator.h" -#endif - -#if defined(ENABLE_TESTS) -# include "geckoview/TelemetryGeckoViewTesting.h" -#endif - using namespace mozilla; ///////////////////////////////////////////////////////////////////////////// -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAppStartup, Init) - -#if defined(MOZ_HAS_TERMINATOR) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTerminator) -#endif - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsUserInfo) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFindService) - -#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsParentalControlsService) -#endif - -NS_GENERIC_FACTORY_CONSTRUCTOR(AlertNotification) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService) - -NS_GENERIC_FACTORY_CONSTRUCTOR(DownloadPlatform) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind) - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - ApplicationReputationService, ApplicationReputationService::GetSingleton) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(LoginReputationService, - LoginReputationService::GetSingleton) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierPrefixSet) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierStreamUpdater) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlClassifierUtils, Init) - -static nsresult nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, - REFNSIID aIID, - void **aResult) { +nsresult nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) { nsresult rv; NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_NO_AGGREGATION(aOuter); - nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv); - if (nullptr == inst) { + RefPtr inst = + nsUrlClassifierDBService::GetInstance(&rv); + if (!inst) { return rv; } - /* NS_ADDREF(inst); */ - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - return rv; + return inst->QueryInterface(aIID, aResult); } - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter) -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsUpdateProcessor) -#endif -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(FinalizationWitnessService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(NativeOSFileInternalsService) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NativeFileWatcherService, Init) - -NS_GENERIC_FACTORY_CONSTRUCTOR(AddonContentPolicy) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(AddonManagerStartup, - AddonManagerStartup::GetInstance) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ExtensionPolicyService, - ExtensionPolicyService::GetInstance) - -#if defined(ENABLE_TESTS) -NS_GENERIC_FACTORY_CONSTRUCTOR(TelemetryGeckoViewTestingImpl) -#endif - -NS_DEFINE_NAMED_CID(NS_TOOLKIT_APPSTARTUP_CID); -#if defined(MOZ_HAS_TERMINATOR) -NS_DEFINE_NAMED_CID(NS_TOOLKIT_TERMINATOR_CID); -#endif -NS_DEFINE_NAMED_CID(NS_USERINFO_CID); -NS_DEFINE_NAMED_CID(ALERT_NOTIFICATION_CID); -NS_DEFINE_NAMED_CID(NS_ALERTSSERVICE_CID); -#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) -NS_DEFINE_NAMED_CID(NS_PARENTALCONTROLSSERVICE_CID); -#endif -NS_DEFINE_NAMED_CID(NS_DOWNLOADPLATFORM_CID); -NS_DEFINE_NAMED_CID(NS_FIND_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_TYPEAHEADFIND_CID); -NS_DEFINE_NAMED_CID(NS_APPLICATION_REPUTATION_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_LOGIN_REPUTATION_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERPREFIXSET_CID); -NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERDBSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERSTREAMUPDATER_CID); -NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERUTILS_CID); -NS_DEFINE_NAMED_CID(NS_BROWSERSTATUSFILTER_CID); -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) -NS_DEFINE_NAMED_CID(NS_UPDATEPROCESSOR_CID); -#endif -NS_DEFINE_NAMED_CID(FINALIZATIONWITNESSSERVICE_CID); -NS_DEFINE_NAMED_CID(NATIVE_OSFILE_INTERNALS_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_ADDONCONTENTPOLICY_CID); -NS_DEFINE_NAMED_CID(NS_ADDON_MANAGER_STARTUP_CID); -NS_DEFINE_NAMED_CID(NS_ADDON_POLICY_SERVICE_CID); -NS_DEFINE_NAMED_CID(NATIVE_FILEWATCHER_SERVICE_CID); -#if defined(ENABLE_TESTS) -NS_DEFINE_NAMED_CID(NS_TELEMETRYGECKOVIEWTESTING_CID); -#endif - -static const Module::CIDEntry kToolkitCIDs[] = { - {&kNS_TOOLKIT_APPSTARTUP_CID, false, nullptr, nsAppStartupConstructor}, -#if defined(MOZ_HAS_TERMINATOR) - {&kNS_TOOLKIT_TERMINATOR_CID, false, nullptr, nsTerminatorConstructor}, -#endif - {&kNS_USERINFO_CID, false, nullptr, nsUserInfoConstructor}, - {&kALERT_NOTIFICATION_CID, false, nullptr, AlertNotificationConstructor}, - {&kNS_ALERTSSERVICE_CID, false, nullptr, nsAlertsServiceConstructor}, -#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) - {&kNS_PARENTALCONTROLSSERVICE_CID, false, nullptr, - nsParentalControlsServiceConstructor}, -#endif - {&kNS_DOWNLOADPLATFORM_CID, false, nullptr, DownloadPlatformConstructor}, - {&kNS_FIND_SERVICE_CID, false, nullptr, nsFindServiceConstructor}, - {&kNS_TYPEAHEADFIND_CID, false, nullptr, nsTypeAheadFindConstructor}, - {&kNS_APPLICATION_REPUTATION_SERVICE_CID, false, nullptr, - ApplicationReputationServiceConstructor}, - {&kNS_LOGIN_REPUTATION_SERVICE_CID, false, nullptr, - LoginReputationServiceConstructor}, - {&kNS_URLCLASSIFIERPREFIXSET_CID, false, nullptr, - nsUrlClassifierPrefixSetConstructor}, - {&kNS_URLCLASSIFIERDBSERVICE_CID, false, nullptr, - nsUrlClassifierDBServiceConstructor}, - {&kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, nullptr, - nsUrlClassifierStreamUpdaterConstructor}, - {&kNS_URLCLASSIFIERUTILS_CID, false, nullptr, - nsUrlClassifierUtilsConstructor}, - {&kNS_BROWSERSTATUSFILTER_CID, false, nullptr, - nsBrowserStatusFilterConstructor}, -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) - {&kNS_UPDATEPROCESSOR_CID, false, nullptr, nsUpdateProcessorConstructor}, -#endif - {&kFINALIZATIONWITNESSSERVICE_CID, false, nullptr, - FinalizationWitnessServiceConstructor}, - {&kNATIVE_OSFILE_INTERNALS_SERVICE_CID, false, nullptr, - NativeOSFileInternalsServiceConstructor}, - {&kNS_ADDONCONTENTPOLICY_CID, false, nullptr, - AddonContentPolicyConstructor}, - {&kNS_ADDON_MANAGER_STARTUP_CID, false, nullptr, - AddonManagerStartupConstructor}, - {&kNS_ADDON_POLICY_SERVICE_CID, false, nullptr, - ExtensionPolicyServiceConstructor}, - {&kNATIVE_FILEWATCHER_SERVICE_CID, false, nullptr, - NativeFileWatcherServiceConstructor}, -#if defined(ENABLE_TESTS) - {&kNS_TELEMETRYGECKOVIEWTESTING_CID, false, nullptr, - TelemetryGeckoViewTestingImplConstructor}, -#endif - {nullptr}}; - -static const Module::ContractIDEntry kToolkitContracts[] = { - {NS_APPSTARTUP_CONTRACTID, &kNS_TOOLKIT_APPSTARTUP_CID}, -#if defined(MOZ_HAS_TERMINATOR) - {NS_TOOLKIT_TERMINATOR_CONTRACTID, &kNS_TOOLKIT_TERMINATOR_CID}, -#endif - {NS_USERINFO_CONTRACTID, &kNS_USERINFO_CID}, - {ALERT_NOTIFICATION_CONTRACTID, &kALERT_NOTIFICATION_CID}, - {NS_ALERTSERVICE_CONTRACTID, &kNS_ALERTSSERVICE_CID}, -#if !defined(MOZ_DISABLE_PARENTAL_CONTROLS) - {NS_PARENTALCONTROLSSERVICE_CONTRACTID, &kNS_PARENTALCONTROLSSERVICE_CID}, -#endif - {NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID}, - {NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID}, - {NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID}, - {NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID, - &kNS_APPLICATION_REPUTATION_SERVICE_CID}, - {NS_LOGIN_REPUTATION_SERVICE_CONTRACTID, &kNS_LOGIN_REPUTATION_SERVICE_CID}, - {NS_URLCLASSIFIERPREFIXSET_CONTRACTID, &kNS_URLCLASSIFIERPREFIXSET_CID}, - {NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID}, - {NS_URICLASSIFIERSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID}, - {NS_URLCLASSIFIERSTREAMUPDATER_CONTRACTID, - &kNS_URLCLASSIFIERSTREAMUPDATER_CID}, - {NS_URLCLASSIFIERUTILS_CONTRACTID, &kNS_URLCLASSIFIERUTILS_CID}, - {NS_BROWSERSTATUSFILTER_CONTRACTID, &kNS_BROWSERSTATUSFILTER_CID}, -#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID) - {NS_UPDATEPROCESSOR_CONTRACTID, &kNS_UPDATEPROCESSOR_CID}, -#endif - {FINALIZATIONWITNESSSERVICE_CONTRACTID, &kFINALIZATIONWITNESSSERVICE_CID}, - {NATIVE_OSFILE_INTERNALS_SERVICE_CONTRACTID, - &kNATIVE_OSFILE_INTERNALS_SERVICE_CID}, - {NS_ADDONCONTENTPOLICY_CONTRACTID, &kNS_ADDONCONTENTPOLICY_CID}, - {NS_ADDONMANAGERSTARTUP_CONTRACTID, &kNS_ADDON_MANAGER_STARTUP_CID}, - {NS_ADDON_POLICY_SERVICE_CONTRACTID, &kNS_ADDON_POLICY_SERVICE_CID}, - {NATIVE_FILEWATCHER_SERVICE_CONTRACTID, &kNATIVE_FILEWATCHER_SERVICE_CID}, -#if defined(ENABLE_TESTS) - {NS_TELEMETRYGECKOVIEWTESTING_CONTRACTID, - &kNS_TELEMETRYGECKOVIEWTESTING_CID}, -#endif - {nullptr}}; - -static const mozilla::Module::CategoryEntry kToolkitCategories[] = { - {"content-policy", NS_ADDONCONTENTPOLICY_CONTRACTID, - NS_ADDONCONTENTPOLICY_CONTRACTID}, - {nullptr}}; - -static const Module kToolkitModule = {Module::kVersion, kToolkitCIDs, - kToolkitContracts, kToolkitCategories}; - -NSMODULE_DEFN(nsToolkitCompsModule) = &kToolkitModule; diff --git a/toolkit/components/build/nsToolkitCompsModule.h b/toolkit/components/build/nsToolkitCompsModule.h new file mode 100644 index 000000000000..e9715909f0b6 --- /dev/null +++ b/toolkit/components/build/nsToolkitCompsModule.h @@ -0,0 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +#include "nscore.h" +#include "nsID.h" + +class nsISupports; + +nsresult nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, + const nsIID& aIID, + void **aResult); diff --git a/toolkit/components/filewatcher/NativeFileWatcherNotSupported.h b/toolkit/components/filewatcher/NativeFileWatcherNotSupported.h index 6d77224a018f..c9d858fff0db 100644 --- a/toolkit/components/filewatcher/NativeFileWatcherNotSupported.h +++ b/toolkit/components/filewatcher/NativeFileWatcherNotSupported.h @@ -37,8 +37,6 @@ class NativeFileWatcherService final : public nsINativeFileWatcherService { void operator=(const NativeFileWatcherService& other) = delete; }; -NS_IMPL_ISUPPORTS(NativeFileWatcherService, nsINativeFileWatcherService); - } // namespace mozilla #endif // mozilla_nativefilewatcher_h__ diff --git a/toolkit/components/places/nsAnnotationService.h b/toolkit/components/places/nsAnnotationService.h index 249ea9d93ebc..516520c97193 100644 --- a/toolkit/components/places/nsAnnotationService.h +++ b/toolkit/components/places/nsAnnotationService.h @@ -12,7 +12,6 @@ #include "nsCOMPtr.h" #include "nsServiceManagerUtils.h" #include "nsWeakReference.h" -#include "nsToolkitCompsCID.h" #include "Database.h" #include "nsString.h" #include "mozilla/Attributes.h" diff --git a/toolkit/components/reputationservice/ApplicationReputation.cpp b/toolkit/components/reputationservice/ApplicationReputation.cpp index 5cff38458ea6..e0e50f8f173d 100644 --- a/toolkit/components/reputationservice/ApplicationReputation.cpp +++ b/toolkit/components/reputationservice/ApplicationReputation.cpp @@ -29,6 +29,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/BasePrincipal.h" +#include "mozilla/Components.h" #include "mozilla/ErrorNames.h" #include "mozilla/LoadContext.h" #include "mozilla/Preferences.h" @@ -368,7 +369,7 @@ nsresult PendingDBLookup::LookupSpecInternal(const nsACString& aSpec) { // blacklisted. LOG(("Checking DB service for principal %s [this = %p]", mSpec.get(), this)); nsCOMPtr dbService = - do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &rv); + mozilla::components::UrlClassifierDB::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString tables; diff --git a/toolkit/components/reputationservice/LoginReputation.cpp b/toolkit/components/reputationservice/LoginReputation.cpp index 494f2257f12f..c999f4276cfc 100644 --- a/toolkit/components/reputationservice/LoginReputation.cpp +++ b/toolkit/components/reputationservice/LoginReputation.cpp @@ -5,6 +5,7 @@ #include "LoginReputation.h" #include "nsThreadUtils.h" +#include "mozilla/Components.h" #include "mozilla/ErrorNames.h" #include "mozilla/Logging.h" #include "mozilla/net/UrlClassifierFeatureFactory.h" @@ -113,7 +114,7 @@ RefPtr LoginWhitelist::QueryLoginWhitelist( } nsCOMPtr uriClassifier = - do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &rv); + mozilla::components::UrlClassifierDB::Service(&rv); if (NS_WARN_IF(NS_FAILED(rv))) { return p; } diff --git a/toolkit/components/reputationservice/LoginReputationIPC.cpp b/toolkit/components/reputationservice/LoginReputationIPC.cpp index d302f08047ae..3bac1992198f 100644 --- a/toolkit/components/reputationservice/LoginReputationIPC.cpp +++ b/toolkit/components/reputationservice/LoginReputationIPC.cpp @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "LoginReputationIPC.h" +#include "mozilla/Components.h" #include "mozilla/Unused.h" using namespace mozilla; @@ -23,7 +24,7 @@ NS_IMPL_ISUPPORTS(LoginReputationParent, nsILoginReputationQueryCallback) mozilla::ipc::IPCResult LoginReputationParent::QueryReputation(nsIURI* aURI) { nsresult rv; nsCOMPtr service = - do_GetService(NS_LOGIN_REPUTATION_SERVICE_CONTRACTID, &rv); + components::LoginReputation::Service(&rv); if (NS_FAILED(rv)) { Unused << Send__delete__(this); return IPC_OK(); diff --git a/toolkit/components/url-classifier/Classifier.cpp b/toolkit/components/url-classifier/Classifier.cpp index ecc8b550690e..c1434881ac42 100644 --- a/toolkit/components/url-classifier/Classifier.cpp +++ b/toolkit/components/url-classifier/Classifier.cpp @@ -15,6 +15,7 @@ #include "nsNetCID.h" #include "nsPrintfCString.h" #include "nsThreadUtils.h" +#include "mozilla/Components.h" #include "mozilla/EndianUtils.h" #include "mozilla/Telemetry.h" #include "mozilla/IntegerPrintfMacros.h" @@ -721,7 +722,7 @@ nsresult Classifier::ApplyUpdatesBackground(TableUpdateArray& aUpdates, } nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsCString provider; // Assume all TableUpdate objects should have the same provider. @@ -1159,7 +1160,7 @@ bool Classifier::CheckValidUpdate(TableUpdateArray& aUpdates, nsCString Classifier::GetProvider(const nsACString& aTableName) { nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsCString provider; nsresult rv = urlUtil->GetProvider(aTableName, provider); diff --git a/toolkit/components/url-classifier/ProtocolParser.cpp b/toolkit/components/url-classifier/ProtocolParser.cpp index 94930ad0b80b..53de3928f7fe 100644 --- a/toolkit/components/url-classifier/ProtocolParser.cpp +++ b/toolkit/components/url-classifier/ProtocolParser.cpp @@ -6,6 +6,7 @@ #include "ProtocolParser.h" #include "LookupCache.h" #include "nsNetCID.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" #include "prnetdb.h" #include "prprf.h" @@ -773,7 +774,7 @@ nsresult ProtocolParserProtobuf::ProcessOneResponse( // Convert threat type to list name. nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsCString possibleListNames; nsresult rv = urlUtil->ConvertThreatTypeToListNames(aResponse.threat_type(), possibleListNames); diff --git a/toolkit/components/url-classifier/nsCheckSummedOutputStream.h b/toolkit/components/url-classifier/nsCheckSummedOutputStream.h index fcf3ca3f39e2..b8dd79543920 100644 --- a/toolkit/components/url-classifier/nsCheckSummedOutputStream.h +++ b/toolkit/components/url-classifier/nsCheckSummedOutputStream.h @@ -12,7 +12,6 @@ #include "nsNetCID.h" #include "nsNetUtil.h" #include "nsString.h" -#include "nsToolkitCompsCID.h" #include "../../../netwerk/base/nsBufferedStreams.h" #include "prio.h" diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 0b680fe66956..715ff3f2d14d 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -14,8 +14,8 @@ #include "nsIPrefBranch.h" #include "nsIPrefService.h" #include "nsIProperties.h" -#include "nsToolkitCompsCID.h" #include "nsIXULRuntime.h" +#include "nsToolkitCompsCID.h" #include "nsUrlClassifierDBService.h" #include "nsUrlClassifierUtils.h" #include "nsUrlClassifierProxies.h" @@ -28,12 +28,14 @@ #include "nsProxyRelease.h" #include "nsString.h" #include "mozilla/Atomics.h" +#include "mozilla/Components.h" #include "mozilla/DebugOnly.h" #include "mozilla/ErrorNames.h" #include "mozilla/Mutex.h" #include "mozilla/Preferences.h" #include "mozilla/TimeStamp.h" #include "mozilla/Telemetry.h" +#include "mozilla/Unused.h" #include "mozilla/Logging.h" #include "prnetdb.h" #include "Entries.h" @@ -777,7 +779,7 @@ nsresult nsUrlClassifierDBServiceWorker::NotifyUpdateObserver( mUpdateStatus = aUpdateStatus; nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsCString provider; // Assume that all the tables in update should have the same provider. @@ -1547,7 +1549,7 @@ nsUrlClassifierClassifyCallback::HandleResult(const nsACString& aTable, matchedInfo->fullhash = aFullHash; nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsCString provider; nsresult rv = urlUtil->GetProvider(aTable, provider); @@ -1579,8 +1581,8 @@ NS_INTERFACE_MAP_BEGIN(nsUrlClassifierDBService) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIClassifier) NS_INTERFACE_MAP_END -/* static */ nsUrlClassifierDBService* nsUrlClassifierDBService::GetInstance( - nsresult* result) { +/* static */ already_AddRefed +nsUrlClassifierDBService::GetInstance(nsresult* result) { *result = NS_OK; if (!sUrlClassifierDBService) { sUrlClassifierDBService = new (fallible) nsUrlClassifierDBService(); @@ -1589,18 +1591,12 @@ NS_INTERFACE_MAP_END return nullptr; } - NS_ADDREF(sUrlClassifierDBService); // addref the global - *result = sUrlClassifierDBService->Init(); if (NS_FAILED(*result)) { - NS_RELEASE(sUrlClassifierDBService); return nullptr; } - } else { - // Already exists, just add a ref - NS_ADDREF(sUrlClassifierDBService); // addref the return result } - return sUrlClassifierDBService; + return do_AddRef(sUrlClassifierDBService); } nsUrlClassifierDBService::nsUrlClassifierDBService() : mInUpdate(false) {} @@ -1653,7 +1649,8 @@ nsresult nsUrlClassifierDBService::Init() { { // Force nsIUrlClassifierUtils loading on main thread. nsCOMPtr dummy = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID, &rv); + components::UrlClassifierUtils::Service(&rv); + Unused << dummy; NS_ENSURE_SUCCESS(rv, rv); } @@ -1794,7 +1791,7 @@ nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal, nsAutoCString key; // Canonicalize the url nsCOMPtr utilsService = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); rv = utilsService->GetKeyForURI(uri, key); NS_ENSURE_SUCCESS(rv, rv); @@ -1964,7 +1961,7 @@ nsUrlClassifierDBService::SendThreatHitReport(nsIChannel* aChannel, } nsCOMPtr utilsService = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); if (!utilsService) { return NS_ERROR_FAILURE; } @@ -2073,7 +2070,7 @@ nsUrlClassifierDBService::Lookup(nsIPrincipal* aPrincipal, nsAutoCString key; // Canonicalize the url nsCOMPtr utilsService = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); rv = utilsService->GetKeyForURI(uri, key); NS_ENSURE_SUCCESS(rv, rv); @@ -2433,7 +2430,7 @@ nsUrlClassifierDBService::AsyncClassifyLocalWithFeatures( nsAutoCString key; // Canonicalize the url nsCOMPtr utilsService = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + components::UrlClassifierUtils::Service(); nsresult rv = utilsService->GetKeyForURI(uri, key); NS_ENSURE_SUCCESS(rv, rv); diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.h b/toolkit/components/url-classifier/nsUrlClassifierDBService.h index df6d9c226bab..fb7ab43128b4 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.h +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.h @@ -17,7 +17,6 @@ #include "nsIUrlClassifierDBService.h" #include "nsIUrlClassifierInfo.h" #include "nsIURIClassifier.h" -#include "nsToolkitCompsCID.h" #include "nsICryptoHMAC.h" #include "mozilla/Attributes.h" #include "mozilla/Mutex.h" @@ -85,7 +84,8 @@ class nsUrlClassifierDBService final : public nsIUrlClassifierDBService, nsresult Init(); - static nsUrlClassifierDBService* GetInstance(nsresult* result); + static already_AddRefed GetInstance( + nsresult* result); NS_DECLARE_STATIC_IID_ACCESSOR(NS_URLCLASSIFIERDBSERVICE_CID) diff --git a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp index a39dfaf1e788..e25ffd9c0cdb 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp @@ -13,7 +13,6 @@ #include "nsTArray.h" #include "nsString.h" #include "nsIFile.h" -#include "nsToolkitCompsCID.h" #include "nsTArray.h" #include "nsThreadUtils.h" #include "nsNetUtil.h" diff --git a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp index d3a017b1b325..e5d790056a8c 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/Components.h" #include "nsCRT.h" #include "nsIHttpChannel.h" #include "nsIObserverService.h" @@ -14,7 +15,6 @@ #include "nsNetUtil.h" #include "nsStreamUtils.h" #include "nsStringStream.h" -#include "nsToolkitCompsCID.h" #include "nsUrlClassifierStreamUpdater.h" #include "mozilla/BasePrincipal.h" #include "mozilla/ErrorNames.h" @@ -294,7 +294,7 @@ nsUrlClassifierStreamUpdater::DownloadUpdates( observerService->AddObserver(this, gQuitApplicationMessage, false); - mDBService = do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &rv); + mDBService = mozilla::components::UrlClassifierDB::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); mInitialized = true; @@ -327,7 +327,7 @@ nsUrlClassifierStreamUpdater::DownloadUpdates( } nsCOMPtr urlUtil = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID); + mozilla::components::UrlClassifierUtils::Service(); nsTArray tables; mozilla::safebrowsing::Classifier::SplitTables(aRequestTables, tables); diff --git a/toolkit/components/url-classifier/tests/gtest/Common.cpp b/toolkit/components/url-classifier/tests/gtest/Common.cpp index f3043c38f08b..9ed041ee13fd 100644 --- a/toolkit/components/url-classifier/tests/gtest/Common.cpp +++ b/toolkit/components/url-classifier/tests/gtest/Common.cpp @@ -6,6 +6,8 @@ #include "nsIThread.h" #include "nsThreadUtils.h" #include "nsUrlClassifierUtils.h" +#include "mozilla/Components.h" +#include "mozilla/Unused.h" using namespace mozilla; using namespace mozilla::safebrowsing; @@ -95,7 +97,8 @@ void ApplyUpdate(TableUpdateArray& updates) { // in gtest. nsresult rv; nsCOMPtr dummy = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID, &rv); + mozilla::components::UrlClassifierUtils::Service(&rv); + Unused << dummy; ASSERT_TRUE(NS_SUCCEEDED(rv)); } diff --git a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp index 6f786b14a992..2af51be759d5 100644 --- a/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp +++ b/toolkit/components/url-classifier/tests/gtest/TestUrlClassifierTableUpdateV4.cpp @@ -10,6 +10,8 @@ #include "string.h" #include "gtest/gtest.h" #include "nsThreadUtils.h" +#include "mozilla/Components.h" +#include "mozilla/Unused.h" using namespace mozilla; using namespace mozilla::safebrowsing; @@ -191,7 +193,8 @@ static void testUpdate(TableUpdateArray& tableUpdates, // in gtest. nsresult rv; nsCOMPtr dummy = - do_GetService(NS_URLCLASSIFIERUTILS_CONTRACTID, &rv); + components::UrlClassifierUtils::Service(&rv); + Unused << dummy; ASSERT_TRUE(NS_SUCCEEDED(rv)); } diff --git a/toolkit/content/tests/browser/browser_label_textlink.js b/toolkit/content/tests/browser/browser_label_textlink.js index 2480f7ce713f..d92bd77c134c 100644 --- a/toolkit/content/tests/browser/browser_label_textlink.js +++ b/toolkit/content/tests/browser/browser_label_textlink.js @@ -3,12 +3,12 @@ add_task(async function() { let newTabURL = "http://www.example.com/"; await ContentTask.spawn(browser, newTabURL, async function(newTabURL) { let doc = content.document; - let label = doc.createElement("label"); + let label = doc.createXULElement("label"); label.href = newTabURL; label.id = "textlink-test"; label.className = "text-link"; label.textContent = "click me"; - doc.documentElement.append(label); + doc.body.prepend(label); }); // Test that click will open tab in foreground. diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index ab39aaaa4f9c..76694939973c 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -319,7 +319,6 @@ var BrowserUtils = { */ canFindInPage(location) { return !location.startsWith("about:addons") && - !location.startsWith("about:config") && !location.startsWith("about:preferences"); }, diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 327778134c70..845b6c07e3e4 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -1077,10 +1077,13 @@ with only_when('--enable-compile-environment'): def idl_roots(build_env): return namespace(ipdl_root=os.path.join(build_env.topobjdir, 'ipc', 'ipdl'), webidl_root=os.path.join(build_env.topobjdir, - 'dom', 'bindings')) + 'dom', 'bindings'), + xpcom_root=os.path.join(build_env.topobjdir, + 'xpcom', 'components')) set_config('WEBIDL_ROOT', idl_roots.webidl_root) set_config('IPDL_ROOT', idl_roots.ipdl_root) +set_config('XPCOM_ROOT', idl_roots.xpcom_root) # Proxy bypass protection # ============================================================== diff --git a/toolkit/xre/ProfileReset.cpp b/toolkit/xre/ProfileReset.cpp index f6be74b5be82..57472aa96c2f 100644 --- a/toolkit/xre/ProfileReset.cpp +++ b/toolkit/xre/ProfileReset.cpp @@ -16,8 +16,8 @@ #include "nsPIDOMWindow.h" #include "nsPrintfCString.h" #include "nsString.h" -#include "nsToolkitCompsCID.h" #include "nsXPCOMCIDInternal.h" +#include "mozilla/Components.h" #include "mozilla/XREAppData.h" #include "mozilla/Services.h" @@ -148,7 +148,7 @@ nsresult ProfileResetCleanup(nsIToolkitProfile* aOldProfile) { do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (!windowWatcher) return NS_ERROR_FAILURE; - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr appStartup(components::AppStartup::Service()); if (!appStartup) return NS_ERROR_FAILURE; nsCOMPtr progressWindow; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index e1b87c1ed5a2..31a597e1eeee 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -10,6 +10,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" +#include "mozilla/Components.h" #include "mozilla/FilePreferences.h" #include "mozilla/ChaosMode.h" #include "mozilla/CmdLineAndEnvUtils.h" @@ -150,7 +151,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsXULAppAPI.h" #include "nsXREDirProvider.h" -#include "nsToolkitCompsCID.h" #include "nsINIParser.h" #include "mozilla/Omnijar.h" @@ -1298,7 +1298,7 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup() { mozilla::MacAutoreleasePool pool; #endif - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr appStartup(components::AppStartup::Service()); if (appStartup) appStartup->DestroyHiddenWindow(); gDirServiceProvider->DoShutdown(); @@ -1422,7 +1422,7 @@ nsresult ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native) { if (cr) cr->CheckForOSAccessibility(); - nsCOMPtr creator(do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr creator(components::AppStartup::Service()); if (!creator) return NS_ERROR_UNEXPECTED; nsCOMPtr wwatch( @@ -1998,8 +1998,7 @@ static ReturnAbortOnError ShowProfileManager( ioParamBlock->SetObjects(dlgArray); - nsCOMPtr appStartup( - do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr appStartup(components::AppStartup::Service()); NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE); nsCOMPtr newWindow; @@ -4220,7 +4219,7 @@ nsresult XREMain::XRE_mainRun() { nsAppStartupNotifier::NotifyObservers(APPSTARTUP_TOPIC); - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr appStartup(components::AppStartup::Service()); NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE); mDirProvider.DoStartup(); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index a094e318d6f1..f591529797be 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -4,7 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsAppRunner.h" -#include "nsToolkitCompsCID.h" #include "nsXREDirProvider.h" #include "jsapi.h" @@ -38,6 +37,7 @@ #include "mozilla/dom/ScriptSettings.h" #include "mozilla/AutoRestore.h" +#include "mozilla/Components.h" #include "mozilla/Services.h" #include "mozilla/Omnijar.h" #include "mozilla/Preferences.h" @@ -962,7 +962,8 @@ nsXREDirProvider::DoStartup() { MOZ_ASSERT(mPrefsInitialized); bool safeModeNecessary = false; - nsCOMPtr appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID)); + nsCOMPtr appStartup( + mozilla::components::AppStartup::Service()); if (appStartup) { rv = appStartup->TrackStartupCrashBegin(&safeModeNecessary); if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE) diff --git a/uriloader/base/nsCURILoader.idl b/uriloader/base/nsCURILoader.idl index 5d9d8f0131b4..b77422abe94e 100644 --- a/uriloader/base/nsCURILoader.idl +++ b/uriloader/base/nsCURILoader.idl @@ -13,19 +13,6 @@ nsIURILoader */ %{ C++ -// {9F6D5D40-90E7-11d3-AF93-00A024FFC08C} - -#define NS_URI_LOADER_CID \ -{ 0x9f6d5d40, 0x90e7, 0x11d3, { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } } -#define NS_URI_LOADER_CONTRACTID \ -"@mozilla.org/uriloader;1" - -/* 057b04d0-0ccf-11d2-beba-00805f8a66dc */ -#define NS_DOCUMENTLOADER_SERVICE_CID \ - { 0x057b04d0, 0x0ccf, 0x11d2,{0xbe, 0xba, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc}} - -#define NS_DOCUMENTLOADER_SERVICE_CONTRACTID \ -"@mozilla.org/docloaderservice;1" - #define NS_CONTENT_HANDLER_CONTRACTID "@mozilla.org/uriloader/content-handler;1" #define NS_CONTENT_HANDLER_CONTRACTID_PREFIX NS_CONTENT_HANDLER_CONTRACTID "?type=" diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 7274282f7742..6d399fa892b0 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -5,11 +5,11 @@ #include "nspr.h" #include "mozilla/dom/Document.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" #include "mozilla/IntegerPrintfMacros.h" #include "nsDocLoader.h" -#include "nsCURILoader.h" #include "nsNetUtil.h" #include "nsIHttpChannel.h" #include "nsIWebNavigation.h" @@ -39,6 +39,7 @@ #include "nsILoadURIDelegate.h" #include "nsIBrowserDOMWindow.h" +using namespace mozilla; using mozilla::DebugOnly; using mozilla::LogLevel; using mozilla::dom::Document; @@ -198,10 +199,9 @@ already_AddRefed nsDocLoader::GetAsDocLoader( /* static */ nsresult nsDocLoader::AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader) { - nsresult rv; nsCOMPtr docLoaderService = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + components::DocLoader::Service(); + NS_ENSURE_TRUE(docLoaderService, NS_ERROR_UNEXPECTED); RefPtr rootDocLoader = GetAsDocLoader(docLoaderService); NS_ENSURE_TRUE(rootDocLoader, NS_ERROR_UNEXPECTED); diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index 9cb058299e4d..a0e9a339ce31 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -39,7 +39,7 @@ #include "nsError.h" #include "nsICategoryManager.h" -#include "nsCExternalHandlerService.h" // contains contractids for the helper app service +#include "nsCExternalHandlerService.h" #include "nsIMIMEHeaderParam.h" #include "nsNetCID.h" diff --git a/uriloader/exthandler/ContentHandlerService.h b/uriloader/exthandler/ContentHandlerService.h index 4c9a94736c47..22e40443d3e0 100644 --- a/uriloader/exthandler/ContentHandlerService.h +++ b/uriloader/exthandler/ContentHandlerService.h @@ -1,19 +1,15 @@ #ifndef ContentHandlerService_h #define ContentHandlerService_h +#include "mozilla/dom/PHandlerService.h" #include "nsIHandlerService.h" #include "nsClassHashtable.h" -#include "HandlerServiceChild.h" #include "nsIMIMEInfo.h" -#define NS_CONTENTHANDLERSERVICE_CID \ - { \ - 0xc4b6fb7c, 0xbfb1, 0x49dc, { \ - 0xa6, 0x5f, 0x03, 0x57, 0x96, 0x52, 0x4b, 0x53 \ - } \ - } - namespace mozilla { + +class HandlerServiceChild; + namespace dom { class PHandlerServiceChild; diff --git a/uriloader/exthandler/android/nsExternalURLHandlerService.h b/uriloader/exthandler/android/nsExternalURLHandlerService.h index c5435d014335..18389c528676 100644 --- a/uriloader/exthandler/android/nsExternalURLHandlerService.h +++ b/uriloader/exthandler/android/nsExternalURLHandlerService.h @@ -8,14 +8,6 @@ #include "nsIExternalURLHandlerService.h" -// {4BF1F8EF-D947-4BA3-9CD3-8C9A54A63A1C} -#define NS_EXTERNALURLHANDLERSERVICE_CID \ - { \ - 0x4bf1f8ef, 0xd947, 0x4ba3, { \ - 0x9c, 0xd3, 0x8c, 0x9a, 0x54, 0xa6, 0x3a, 0x1c \ - } \ - } - class nsExternalURLHandlerService final : public nsIExternalURLHandlerService { public: NS_DECL_ISUPPORTS diff --git a/uriloader/exthandler/mac/nsOSHelperAppService.h b/uriloader/exthandler/mac/nsOSHelperAppService.h index 7a05a22665e0..c68db4b206d0 100644 --- a/uriloader/exthandler/mac/nsOSHelperAppService.h +++ b/uriloader/exthandler/mac/nsOSHelperAppService.h @@ -14,9 +14,10 @@ #include "nsExternalHelperAppService.h" #include "nsCExternalHandlerService.h" -#include "nsMIMEInfoImpl.h" #include "nsCOMPtr.h" +class nsIMimeInfo; + class nsOSHelperAppService : public nsExternalHelperAppService { public: virtual ~nsOSHelperAppService(); diff --git a/uriloader/exthandler/moz.build b/uriloader/exthandler/moz.build index 0992f9783e2a..059777ffa400 100644 --- a/uriloader/exthandler/moz.build +++ b/uriloader/exthandler/moz.build @@ -43,6 +43,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': 'nsExternalURLHandlerService.h', ]] +EXPORTS += [ + 'nsLocalHandlerApp.h', +] + EXPORTS.mozilla.dom += [ 'ExternalHelperAppChild.h', 'ExternalHelperAppParent.h', diff --git a/uriloader/exthandler/nsCExternalHandlerService.idl b/uriloader/exthandler/nsCExternalHandlerService.idl index 6aa25a01dbc9..bdf59e9ae658 100644 --- a/uriloader/exthandler/nsCExternalHandlerService.idl +++ b/uriloader/exthandler/nsCExternalHandlerService.idl @@ -14,10 +14,6 @@ nsIExternalHelperAppService %{ C++ -/* A7F800E0-4306-11d4-98D0-001083010E9B */ -#define NS_EXTERNALHELPERAPPSERVICE_CID \ - { 0xa7f800e0, 0x4306, 0x11d4, { 0x98, 0xd0, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } - #define NS_EXTERNALHELPERAPPSERVICE_CONTRACTID \ "@mozilla.org/uriloader/external-helper-app-service;1" @@ -30,29 +26,8 @@ nsIExternalHelperAppService #define NS_MIMESERVICE_CONTRACTID \ "@mozilla.org/mime;1" -#define NS_EXTERNALPROTOCOLHANDLER_CID \ -{ 0xbd6390c8, 0xfbea, 0x11d4, {0x98, 0xf6, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } - -/* 9fa83ce7-d0ab-4ed3-938e-afafee435670 */ -#define NS_BLOCKEDEXTERNALPROTOCOLHANDLER_CID \ -{ 0x9fa83ce7, 0xd0ab, 0x4ed3, {0x93, 0x8e, 0xaf, 0xaf, 0xee, 0x43, 0x56, 0x70 } } - -/* bc0017e3-2438-47be-a567-41db58f17627 */ -#define NS_LOCALHANDLERAPP_CID \ -{ 0xbc0017e3, 0x2438, 0x47be, {0xa5, 0x67, 0x41, 0xdb, 0x58, 0xf1, 0x76, 0x27 } } - -/*6c3c274b-4cbf-4bb5-a635-05ad2cbb6535*/ -#define NS_DBUSHANDLERAPP_CID \ -{ 0x6c3c274b, 0x4cbf, 0x4bb5, {0xa6, 0x35, 0x05, 0xad, 0x2c, 0xbb, 0x65, 0x35 } } - -#define NS_DBUSHANDLERAPP_CONTRACTID \ -"@mozilla.org/uriloader/dbus-handler-app;1" - #define NS_LOCALHANDLERAPP_CONTRACTID \ "@mozilla.org/uriloader/local-handler-app;1" -#define NS_WEBHANDLERAPP_CONTRACTID \ -"@mozilla.org/uriloader/web-handler-app;1" - %} diff --git a/uriloader/exthandler/nsDBusHandlerApp.cpp b/uriloader/exthandler/nsDBusHandlerApp.cpp index aa63c27c4195..85be0c952f6d 100644 --- a/uriloader/exthandler/nsDBusHandlerApp.cpp +++ b/uriloader/exthandler/nsDBusHandlerApp.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include +#include "mozilla/Components.h" #include "mozilla/DBusHelpers.h" #include "nsDBusHandlerApp.h" #include "nsIURI.h" @@ -12,9 +13,12 @@ #include "nsCOMPtr.h" #include "nsCExternalHandlerService.h" +using namespace mozilla; + // XXX why does nsMIMEInfoImpl have a threadsafe nsISupports? do we need one // here too? -NS_IMPL_CLASSINFO(nsDBusHandlerApp, nullptr, 0, NS_DBUSHANDLERAPP_CID) +NS_IMPL_CLASSINFO(nsDBusHandlerApp, nullptr, 0, + components::DBusHandlerApp::CID()) NS_IMPL_ISUPPORTS_CI(nsDBusHandlerApp, nsIDBusHandlerApp, nsIHandlerApp) //////////////////////////////////////////////////////////////////////////////// diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.h b/uriloader/exthandler/unix/nsOSHelperAppService.h index b66c46a6e8a4..45866b859f71 100644 --- a/uriloader/exthandler/unix/nsOSHelperAppService.h +++ b/uriloader/exthandler/unix/nsOSHelperAppService.h @@ -14,10 +14,10 @@ #include "nsExternalHelperAppService.h" #include "nsCExternalHandlerService.h" -#include "nsMIMEInfoImpl.h" #include "nsCOMPtr.h" class nsILineInputStream; +class nsMIMEInfoBase; class nsOSHelperAppService : public nsExternalHelperAppService { public: diff --git a/uriloader/exthandler/win/nsOSHelperAppService.h b/uriloader/exthandler/win/nsOSHelperAppService.h index 98bede8393ce..728a831759ff 100644 --- a/uriloader/exthandler/win/nsOSHelperAppService.h +++ b/uriloader/exthandler/win/nsOSHelperAppService.h @@ -13,7 +13,6 @@ #include "nsExternalHelperAppService.h" #include "nsCExternalHandlerService.h" -#include "nsMIMEInfoImpl.h" #include "nsCOMPtr.h" #include @@ -24,6 +23,7 @@ #include class nsMIMEInfoWin; +class nsIMIMEInfo; class nsOSHelperAppService : public nsExternalHelperAppService { public: diff --git a/uriloader/prefetch/moz.build b/uriloader/prefetch/moz.build index e500ab92e2f7..b64105ff4685 100644 --- a/uriloader/prefetch/moz.build +++ b/uriloader/prefetch/moz.build @@ -14,10 +14,6 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'prefetch' -EXPORTS += [ - 'nsCPrefetchService.h', -] - EXPORTS.mozilla.docshell += [ 'OfflineCacheUpdateChild.h', 'OfflineCacheUpdateParent.h', diff --git a/uriloader/prefetch/nsCPrefetchService.h b/uriloader/prefetch/nsCPrefetchService.h deleted file mode 100644 index 83f17b580d1a..000000000000 --- a/uriloader/prefetch/nsCPrefetchService.h +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -#ifndef nsCPrefetchService_h__ -#define nsCPrefetchService_h__ - -#include "nsIPrefetchService.h" - -/** - * nsPrefetchService : nsIPrefetchService - */ -#define NS_PREFETCHSERVICE_CONTRACTID "@mozilla.org/prefetch-service;1" -#define NS_PREFETCHSERVICE_CID \ - { /* 6b8bdffc-3394-417d-be83-a81b7c0f63bf */ \ - 0x6b8bdffc, 0x3394, 0x417d, { \ - 0xbe, 0x83, 0xa8, 0x1b, 0x7c, 0x0f, 0x63, 0xbf \ - } \ - } - -/** - * nsOfflineCacheUpdateService : nsIOfflineCacheUpdateService - */ - -#define NS_OFFLINECACHEUPDATESERVICE_CONTRACTID \ - "@mozilla.org/offlinecacheupdate-service;1" -#define NS_OFFLINECACHEUPDATESERVICE_CID \ - { /* ec06f3fc-70db-4ecd-94e0-a6e91ca44d8a */ \ - 0xec06f3fc, 0x70db, 0x4ecd, { \ - 0x94, 0xe0, 0xa6, 0xe9, 0x1c, 0xa4, 0x4d, 0x8a \ - } \ - } - -#endif // !nsCPrefetchService_h__ diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp index a44f281a9026..9344c60bbea9 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -5,7 +5,6 @@ #include "nsOfflineCacheUpdate.h" -#include "nsCPrefetchService.h" #include "nsCURILoader.h" #include "nsIApplicationCacheContainer.h" #include "nsIApplicationCacheChannel.h" diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index e29e0347da6c..13b16e363351 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -9,7 +9,6 @@ #include "OfflineCacheUpdateGlue.h" #include "nsOfflineCacheUpdate.h" -#include "nsCPrefetchService.h" #include "nsCURILoader.h" #include "nsIApplicationCacheContainer.h" #include "nsIApplicationCacheChannel.h" @@ -28,12 +27,14 @@ #include "nsIPermissionManager.h" #include "nsIPrincipal.h" #include "nsNetCID.h" +#include "nsNetUtil.h" #include "nsServiceManagerUtils.h" #include "nsStreamUtils.h" #include "nsThreadUtils.h" #include "nsProxyRelease.h" #include "mozilla/Logging.h" #include "nsIAsyncVerifyRedirectCallback.h" +#include "mozilla/Components.h" #include "mozilla/Preferences.h" #include "mozilla/Attributes.h" #include "mozilla/Unused.h" @@ -285,7 +286,8 @@ nsOfflineCacheUpdateService *nsOfflineCacheUpdateService::EnsureService() { if (!gOfflineCacheUpdateService) { // Make the service manager hold a long-lived reference to the service nsCOMPtr service = - do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID); + components::OfflineCacheUpdate::Service(); + Unused << service; } return gOfflineCacheUpdateService; diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp index b4df60edeb91..f50591a03ace 100644 --- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -8,6 +8,7 @@ #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/Attributes.h" #include "mozilla/CORSMode.h" +#include "mozilla/Components.h" #include "mozilla/dom/ClientInfo.h" #include "mozilla/dom/HTMLLinkElement.h" #include "mozilla/dom/ServiceWorkerDescriptor.h" @@ -18,7 +19,6 @@ #include "nsICategoryManager.h" #include "nsIObserverService.h" #include "nsIWebProgress.h" -#include "nsCURILoader.h" #include "nsICacheInfoChannel.h" #include "nsIHttpChannel.h" #include "nsIURL.h" @@ -481,16 +481,14 @@ void nsPrefetchService::DispatchEvent(nsPrefetchNode *node, bool aSuccess) { void nsPrefetchService::AddProgressListener() { // Register as an observer for the document loader - nsCOMPtr progress = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID); + nsCOMPtr progress = components::DocLoader::Service(); if (progress) progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT); } void nsPrefetchService::RemoveProgressListener() { // Register as an observer for the document loader - nsCOMPtr progress = - do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID); + nsCOMPtr progress = components::DocLoader::Service(); if (progress) progress->RemoveProgressListener(this); } diff --git a/uriloader/prefetch/nsPrefetchService.h b/uriloader/prefetch/nsPrefetchService.h index 11a1b4189989..b4ecea900a33 100644 --- a/uriloader/prefetch/nsPrefetchService.h +++ b/uriloader/prefetch/nsPrefetchService.h @@ -5,10 +5,10 @@ #ifndef nsPrefetchService_h__ #define nsPrefetchService_h__ -#include "nsCPrefetchService.h" #include "nsIObserver.h" #include "nsIInterfaceRequestor.h" #include "nsIChannelEventSink.h" +#include "nsIPrefetchService.h" #include "nsIRedirectResultListener.h" #include "nsIWebProgressListener.h" #include "nsIStreamListener.h" diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index c1dc52ca116a..b3911ed74b74 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -24,11 +24,10 @@ #include "nsISpeculativeConnect.h" #include "nsIURIFixup.h" #include "nsCategoryManagerUtils.h" -#include "nsCDefaultURIFixup.h" -#include "nsToolkitCompsCID.h" #include "nsGeoPosition.h" #include "mozilla/ArrayUtils.h" +#include "mozilla/Components.h" #include "mozilla/Telemetry.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" @@ -236,8 +235,7 @@ class GeckoThreadSupport final static int64_t RunUiThreadCallback() { return RunAndroidUiTasks(); } static void ForceQuit() { - nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); + nsCOMPtr appStartup = components::AppStartup::Service(); if (appStartup) { appStartup->Quit(nsIAppStartup::eForceQuit); @@ -568,8 +566,7 @@ nsAppShell::Observe(nsISupports* aSubject, const char* aTopic, // quit. Therefore, we should *not* exit Gecko when there is no // window or the last window is closed. nsIAppStartup::Quit will // still force Gecko to exit. - nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); + nsCOMPtr appStartup = components::AppStartup::Service(); if (appStartup) { appStartup->EnterLastWindowClosingSurvivalArea(); } @@ -606,8 +603,7 @@ nsAppShell::Observe(nsISupports* aSubject, const char* aTopic, // We are told explicitly to quit, perhaps due to // nsIAppStartup::Quit being called. We should release our hold on // nsIAppStartup and let it continue to quit. - nsCOMPtr appStartup = - do_GetService(NS_APPSTARTUP_CONTRACTID); + nsCOMPtr appStartup = components::AppStartup::Service(); if (appStartup) { appStartup->ExitLastWindowClosingSurvivalArea(); } @@ -743,7 +739,7 @@ already_AddRefed nsAppShell::ResolveURI(const nsCString& aUriStr) { return uri.forget(); } - nsCOMPtr fixup = do_GetService(NS_URIFIXUP_CONTRACTID); + nsCOMPtr fixup = components::URIFixup::Service(); if (fixup && NS_SUCCEEDED(fixup->CreateFixupURI(aUriStr, 0, nullptr, getter_AddRefs(uri)))) { return uri.forget(); diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm index e148f5264bf0..eedef6655df8 100644 --- a/widget/cocoa/nsMenuBarX.mm +++ b/widget/cocoa/nsMenuBarX.mm @@ -26,6 +26,7 @@ #include "nsIStringBundle.h" #include "nsToolkitCompsCID.h" +#include "mozilla/Components.h" #include "mozilla/dom/Element.h" NativeMenuItemTarget* nsMenuBarX::sNativeEventTarget = nil; @@ -883,7 +884,7 @@ static BOOL gMenuItemsExecuteCommands = YES; if (mostSpecificContent) { nsMenuUtilsX::DispatchCommandTo(mostSpecificContent); } else { - nsCOMPtr appStartup = do_GetService(NS_APPSTARTUP_CONTRACTID); + nsCOMPtr appStartup = mozilla::components::AppStartup::Service(); if (appStartup) { appStartup->Quit(nsIAppStartup::eAttemptQuit); } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index fe50b9986cff..2257e5aad1a8 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -132,7 +132,6 @@ #include "mozilla/dom/MouseEventBinding.h" #include "mozilla/dom/Touch.h" #include "mozilla/gfx/2D.h" -#include "nsToolkitCompsCID.h" #include "nsIAppStartup.h" #include "mozilla/WindowsVersion.h" #include "mozilla/TextEvents.h" // For WidgetKeyboardEvent diff --git a/xpcom/base/components.conf b/xpcom/base/components.conf new file mode 100644 index 000000000000..8cf04a50d8c3 --- /dev/null +++ b/xpcom/base/components.conf @@ -0,0 +1,28 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{cb6cdb94-e417-4601-b4a5-f991bf41453d}', + 'contract_ids': ['@mozilla.org/xpcom/debug;1'], + 'legacy_constructor': 'nsDebugImpl::Create', + 'headers': ['nsDebugImpl.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS, + }, + { + 'cid': '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/xpcom/memory-service;1'], + 'legacy_constructor': 'nsMemoryImpl::Create', + 'headers': ['/xpcom/base/nsMemoryImpl.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS, + }, + { + 'cid': '{67b3ac0c-d806-4d48-939e-6a819e6c248f}', + 'contract_ids': ['@mozilla.org/message-loop;1'], + 'legacy_constructor': 'nsMessageLoopConstructor', + 'headers': ['/xpcom/base/nsMessageLoop.h'], + }, +] diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index 13dcf3bcab28..f4c60d979579 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -45,6 +45,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': XPIDL_MODULE = 'xpcom_base' +XPCOM_MANIFESTS += [ + 'components.conf', +] + EXPORTS += [ '!ErrorList.h', '!ErrorNamesInternal.h', diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 2add751229ef..6d8c7526b15e 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -4,6 +4,8 @@ * 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/. */ +#include "XPCOMModule.h" + #include "base/basictypes.h" #include "mozilla/Atomics.h" @@ -27,22 +29,12 @@ #include "prlink.h" #include "nsCycleCollector.h" -#include "nsObserverList.h" #include "nsObserverService.h" -#include "nsScriptableInputStream.h" -#include "nsBinaryStream.h" -#include "nsStorageStream.h" -#include "nsPipe.h" -#include "nsScriptableBase64Encoder.h" -#include "nsMemoryImpl.h" #include "nsDebugImpl.h" -#include "nsTraceRefcnt.h" +#include "nsSystemInfo.h" -#include "nsArray.h" #include "nsINIParserImpl.h" -#include "nsSupportsPrimitives.h" -#include "nsConsoleService.h" #include "nsComponentManager.h" #include "nsCategoryManagerUtils.h" @@ -55,51 +47,21 @@ #include "TimerThread.h" #include "nsThread.h" -#include "nsProcess.h" -#include "nsEnvironment.h" #include "nsVersionComparatorImpl.h" #include "nsIFile.h" #include "nsLocalFile.h" -#if defined(XP_UNIX) -# include "nsNativeCharsetUtils.h" -#endif #include "nsDirectoryService.h" #include "nsDirectoryServiceDefs.h" #include "nsCategoryManager.h" #include "nsICategoryManager.h" #include "nsMultiplexInputStream.h" -#include "nsStringStream.h" -extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**); - #include "nsAtomTable.h" #include "nsISupportsImpl.h" -#include "nsHashPropertyBag.h" - -#include "nsUnicharInputStream.h" -#include "nsVariant.h" - -#include "nsUUIDGenerator.h" - -#include "nsIOUtil.h" - -#include "SpecialSystemDirectory.h" - -#if defined(XP_WIN) -# include "nsWindowsRegKey.h" -#endif - -#ifdef MOZ_WIDGET_COCOA -# include "nsMacUtilsImpl.h" -# include "nsMacPreferencesReader.h" -#endif - #include "nsSystemInfo.h" #include "nsMemoryReporterManager.h" -#include "nsMemoryInfoDumper.h" -#include "nsSecurityConsoleMessage.h" #include "nsMessageLoop.h" #include "nss.h" #include "ssl.h" @@ -112,8 +74,6 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**); #include "mozilla/Telemetry.h" #include "mozilla/BackgroundHangMonitor.h" -#include "nsChromeRegistry.h" -#include "nsChromeProtocolHandler.h" #include "mozilla/PoisonIOInterposer.h" #include "mozilla/LateWriteChecks.h" @@ -170,56 +130,8 @@ extern nsresult NS_CategoryManagerGetFactory(nsIFactory**); extern nsresult CreateAnonTempFileRemover(); #endif -NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsID) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsString) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCString) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRBool) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint8) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint16) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint32) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint64) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRTime) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsChar) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt16) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt32) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt64) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloat) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDouble) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointer) - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsConsoleService, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsVersionComparatorImpl) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableBase64Encoder) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariantCC) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHashPropertyBagCC) - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init) - -#ifdef MOZ_WIDGET_COCOA -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacPreferencesReader) -#endif - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init) - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMemoryInfoDumper) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsIOUtil) - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecurityConsoleMessage) - -static nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, - const nsIID& aIID, - void** aInstancePtr) { +nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, const nsIID& aIID, + void** aInstancePtr) { NS_ASSERTION(aInstancePtr, "null outptr"); if (NS_WARN_IF(aOuter)) { return NS_ERROR_NO_AGGREGATION; @@ -228,78 +140,31 @@ static nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, return nsThreadManager::get().QueryInterface(aIID, aInstancePtr); } +nsresult nsLocalFileConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aInstancePtr) { + return nsLocalFile::nsLocalFileConstructor(aOuter, aIID, aInstancePtr); +} + nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = nullptr; bool gXPCOMShuttingDown = false; bool gXPCOMThreadsShutDown = false; char16_t* gGREBinPath = nullptr; -static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID); -NS_DEFINE_NAMED_CID(NS_CHROMEREGISTRY_CID); -NS_DEFINE_NAMED_CID(NS_CHROMEPROTOCOLHANDLER_CID); - -NS_DEFINE_NAMED_CID(NS_SECURITY_CONSOLE_MESSAGE_CID); - -#ifdef MOZ_WIDGET_COCOA -NS_DEFINE_NAMED_CID(NS_MACPREFERENCESREADER_CID); -#endif - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry, - nsChromeRegistry::GetSingleton) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler) - static already_AddRefed CreateINIParserFactory( const mozilla::Module& aModule, const mozilla::Module::CIDEntry& aEntry) { nsCOMPtr f = new nsINIParserFactory(); return f.forget(); } -#define COMPONENT(NAME, Ctor) \ - static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID); -#define COMPONENT_M(NAME, Ctor, Selector) \ - static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID); -#include "XPCOMModule.inc" -#undef COMPONENT -#undef COMPONENT_M - -#define COMPONENT(NAME, Ctor) {&kNS_##NAME##_CID, false, nullptr, Ctor}, -#define COMPONENT_M(NAME, Ctor, Selector) \ - {&kNS_##NAME##_CID, false, nullptr, Ctor, Selector}, const mozilla::Module::CIDEntry kXPCOMCIDEntries[] = { - {&kComponentManagerCID, true, nullptr, nsComponentManagerImpl::Create, - Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}, {&kINIParserFactoryCID, false, CreateINIParserFactory}, -#include "XPCOMModule.inc" - {&kNS_CHROMEREGISTRY_CID, false, nullptr, nsChromeRegistryConstructor}, - {&kNS_CHROMEPROTOCOLHANDLER_CID, false, nullptr, - nsChromeProtocolHandlerConstructor}, - {&kNS_SECURITY_CONSOLE_MESSAGE_CID, false, nullptr, - nsSecurityConsoleMessageConstructor}, -#ifdef MOZ_WIDGET_COCOA - {&kNS_MACPREFERENCESREADER_CID, false, nullptr, - nsMacPreferencesReaderConstructor}, -#endif {nullptr}}; -#undef COMPONENT -#undef COMPONENT_M -#define COMPONENT(NAME, Ctor) {NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID}, -#define COMPONENT_M(NAME, Ctor, Selector) \ - {NS_##NAME##_CONTRACTID, &kNS_##NAME##_CID, Selector}, const mozilla::Module::ContractIDEntry kXPCOMContracts[] = { -#include "XPCOMModule.inc" - {NS_CHROMEREGISTRY_CONTRACTID, &kNS_CHROMEREGISTRY_CID}, - {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome", - &kNS_CHROMEPROTOCOLHANDLER_CID}, {NS_INIPARSERFACTORY_CONTRACTID, &kINIParserFactoryCID}, - {NS_SECURITY_CONSOLE_MESSAGE_CONTRACTID, &kNS_SECURITY_CONSOLE_MESSAGE_CID}, -#ifdef MOZ_WIDGET_COCOA - {NS_MACPREFERENCESREADER_CONTRACTID, &kNS_MACPREFERENCESREADER_CID}, -#endif {nullptr}}; -#undef COMPONENT -#undef COMPONENT_M const mozilla::Module kXPCOMModule = { mozilla::Module::kVersion, diff --git a/xpcom/build/XPCOMModule.h b/xpcom/build/XPCOMModule.h new file mode 100644 index 000000000000..2c05b7812fec --- /dev/null +++ b/xpcom/build/XPCOMModule.h @@ -0,0 +1,23 @@ +/* -*- 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 + * 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/. */ + +#ifndef XPCOMModule_h +#define XPCOMModule_h + +#include "nsID.h" + +class nsISupports; + +nsresult nsThreadManagerGetSingleton(nsISupports* aOuter, const nsIID& aIID, + void** aInstancePtr); + +nsresult nsLocalFileConstructor(nsISupports* aOuter, const nsIID& aIID, + void** aInstancePtr); + +extern nsresult nsStringInputStreamConstructor(nsISupports*, const nsID&, + void**); + +#endif // XPCOMModule_h diff --git a/xpcom/build/XPCOMModule.inc b/xpcom/build/XPCOMModule.inc index 96adff16284f..4f860fd08e8f 100644 --- a/xpcom/build/XPCOMModule.inc +++ b/xpcom/build/XPCOMModule.inc @@ -1,69 +1,3 @@ - COMPONENT_M(MEMORY, nsMemoryImpl::Create, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS) - COMPONENT_M(DEBUG, nsDebugImpl::Create, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS) - - COMPONENT_M(CATEGORYMANAGER, nsCategoryManager::Create, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS) - - COMPONENT(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create) - COMPONENT(BINARYINPUTSTREAM, nsBinaryInputStreamConstructor) - COMPONENT(BINARYOUTPUTSTREAM, nsBinaryOutputStreamConstructor) - COMPONENT(STORAGESTREAM, nsStorageStreamConstructor) - COMPONENT(VERSIONCOMPARATOR, nsVersionComparatorImplConstructor) - COMPONENT(SCRIPTABLEBASE64ENCODER, nsScriptableBase64EncoderConstructor) - COMPONENT(PIPE, nsPipeConstructor) - - COMPONENT(ARRAY, nsArrayBase::XPCOMConstructor) - COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor) - COMPONENT_M(OBSERVERSERVICE, nsObserverService::Create, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS) - - COMPONENT_M(TIMER, nsTimer::XPCOMConstructor, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS) - -#define COMPONENT_SUPPORTS(TYPE, Type) \ - COMPONENT(SUPPORTS_##TYPE, nsSupports##Type##Constructor) - - COMPONENT_SUPPORTS(ID, ID) - COMPONENT_SUPPORTS(STRING, String) - COMPONENT_SUPPORTS(CSTRING, CString) - COMPONENT_SUPPORTS(PRBOOL, PRBool) - COMPONENT_SUPPORTS(PRUINT8, PRUint8) - COMPONENT_SUPPORTS(PRUINT16, PRUint16) - COMPONENT_SUPPORTS(PRUINT32, PRUint32) - COMPONENT_SUPPORTS(PRUINT64, PRUint64) - COMPONENT_SUPPORTS(PRTIME, PRTime) - COMPONENT_SUPPORTS(CHAR, Char) - COMPONENT_SUPPORTS(PRINT16, PRInt16) - COMPONENT_SUPPORTS(PRINT32, PRInt32) - COMPONENT_SUPPORTS(PRINT64, PRInt64) - COMPONENT_SUPPORTS(FLOAT, Float) - COMPONENT_SUPPORTS(DOUBLE, Double) - COMPONENT_SUPPORTS(INTERFACE_POINTER, InterfacePointer) - -#undef COMPONENT_SUPPORTS - COMPONENT(LOCAL_FILE, nsLocalFile::nsLocalFileConstructor) - COMPONENT(DIRECTORY_SERVICE, nsDirectoryService::Create) - COMPONENT(PROCESS, nsProcessConstructor) - COMPONENT(ENVIRONMENT, nsEnvironment::Create) - - COMPONENT(THREADMANAGER, nsThreadManagerGetSingleton) - - COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor) - COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor) - - COMPONENT(VARIANT, nsVariantCCConstructor) - - COMPONENT(HASH_PROPERTY_BAG, nsHashPropertyBagCCConstructor) - - COMPONENT(UUID_GENERATOR, nsUUIDGeneratorConstructor) - #if defined(XP_WIN) COMPONENT(WINDOWSREGKEY, nsWindowsRegKeyConstructor) #endif - -#if defined(MOZ_WIDGET_COCOA) - COMPONENT(MACUTILSIMPL, nsMacUtilsImplConstructor) -#endif - - COMPONENT(SYSTEMINFO, nsSystemInfoConstructor) - COMPONENT_M(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor, Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS) - COMPONENT(MEMORY_INFO_DUMPER, nsMemoryInfoDumperConstructor) - COMPONENT(IOUTIL, nsIOUtilConstructor) - COMPONENT(MESSAGE_LOOP, nsMessageLoopConstructor) diff --git a/xpcom/build/components.conf b/xpcom/build/components.conf new file mode 100644 index 000000000000..9f2deda27ab5 --- /dev/null +++ b/xpcom/build/components.conf @@ -0,0 +1,250 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{c521a612-2aad-46db-b6ab-3b821fb150b1}', + 'contract_ids': ['@mozilla.org/binaryinputstream;1'], + 'type': 'nsBinaryInputStream', + 'headers': ['/xpcom/io/nsBinaryStream.h'], + }, + { + 'cid': '{86c37b9a-74e7-4672-844e-6e7dd83ba484}', + 'contract_ids': ['@mozilla.org/binaryoutputstream;1'], + 'type': 'nsBinaryOutputStream', + 'headers': ['/xpcom/io/nsBinaryStream.h'], + }, + { + 'cid': '{61ba33c0-3031-11d3-8cd0-0060b0fc14a3}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=chrome'], + 'type': 'nsChromeProtocolHandler', + 'headers': ['/chrome/nsChromeProtocolHandler.h'], + }, + { + 'cid': '{47049e42-1d87-482a-984d-56ae185e367a}', + 'contract_ids': ['@mozilla.org/chrome/chrome-registry;1'], + 'singleton': True, + 'type': 'nsChromeRegistry', + 'headers': ['/chrome/nsChromeRegistry.h'], + 'constructor': 'nsChromeRegistry::GetSingleton', + }, + { + 'cid': '{7e3ff85c-1dd2-11b2-8d4b-eb452cb0ff40}', + 'contract_ids': ['@mozilla.org/consoleservice;1'], + 'type': 'nsConsoleService', + 'headers': ['/xpcom/base/nsConsoleService.h'], + 'init_method': 'Init', + }, + { + 'cid': '{678c50b8-6bcb-4ad0-b9b8-c81175955199}', + 'contract_ids': ['@mozilla.org/hash-property-bag;1'], + 'type': 'nsHashPropertyBagCC', + 'headers': ['nsHashPropertyBag.h'], + }, + { + 'cid': '{eb833911-4f49-4623-845f-e58a8e6de4c2}', + 'contract_ids': ['@mozilla.org/io-util;1'], + 'type': 'nsIOUtil', + 'headers': ['/xpcom/io/nsIOUtil.h'], + }, + { + 'cid': '{2e23e220-60be-11d3-8c4a-000064657374}', + 'contract_ids': ['@mozilla.org/file/local;1'], + 'legacy_constructor': 'nsLocalFileConstructor', + }, + { + 'cid': '{00bd71fb-7f09-4ec3-96af-a0b522b77969}', + 'contract_ids': ['@mozilla.org/memory-info-dumper;1'], + 'type': 'nsMemoryInfoDumper', + 'headers': ['mozilla/nsMemoryInfoDumper.h'], + }, + { + 'cid': '{fb97e4f5-32dd-497a-baa2-7d1e55079910}', + 'contract_ids': ['@mozilla.org/memory-reporter-manager;1'], + 'type': 'nsMemoryReporterManager', + 'headers': ['/xpcom/base/nsMemoryReporterManager.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS, + }, + { + 'cid': '{7b4eeb20-d781-11d4-8a83-0010a4e0c9ca}', + 'contract_ids': ['@mozilla.org/process/util;1'], + 'type': 'nsProcess', + 'headers': ['nsProcess.h'], + }, + { + 'cid': '{aaf68860-f849-40ee-bb7a-b229bce036a3}', + 'contract_ids': ['@mozilla.org/scriptablebase64encoder;1'], + 'type': 'nsScriptableBase64Encoder', + 'headers': ['/xpcom/io/nsScriptableBase64Encoder.h'], + }, + { + 'cid': '{43ebf210-8a7b-4ddb-a83d-b87c51a058db}', + 'contract_ids': ['@mozilla.org/securityconsole/message;1'], + 'type': 'nsSecurityConsoleMessage', + 'headers': ['/xpcom/base/nsSecurityConsoleMessage.h'], + }, + { + 'cid': '{669a9795-6ff7-4ed4-9150-c34ce2971b63}', + 'contract_ids': ['@mozilla.org/storagestream;1'], + 'type': 'nsStorageStream', + 'headers': ['nsStorageStream.h'], + }, + { + 'cid': '{acf8dc41-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-cstring;1'], + 'type': 'nsSupportsCString', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc4a-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-char;1'], + 'type': 'nsSupportsChar', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{cbf86871-4ac0-11d3-baea-00805f8a5dd7}', + 'contract_ids': ['@mozilla.org/supports-double;1'], + 'type': 'nsSupportsDouble', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{cbf86870-4ac0-11d3-baea-00805f8a5dd7}', + 'contract_ids': ['@mozilla.org/supports-float;1'], + 'type': 'nsSupportsFloat', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc40-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-id;1'], + 'type': 'nsSupportsID', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{a99febba-1dd1-11b2-a943-b02334a6d083}', + 'contract_ids': ['@mozilla.org/supports-interface-pointer;1'], + 'type': 'nsSupportsInterfacePointer', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc43-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRBool;1'], + 'type': 'nsSupportsPRBool', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc4b-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRInt16;1'], + 'type': 'nsSupportsPRInt16', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc4c-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRInt32;1'], + 'type': 'nsSupportsPRInt32', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc4d-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRInt64;1'], + 'type': 'nsSupportsPRInt64', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc49-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRTime;1'], + 'type': 'nsSupportsPRTime', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc46-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRUint16;1'], + 'type': 'nsSupportsPRUint16', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc47-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRUint32;1'], + 'type': 'nsSupportsPRUint32', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc48-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRUint64;1'], + 'type': 'nsSupportsPRUint64', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc44-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-PRUint8;1'], + 'type': 'nsSupportsPRUint8', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{acf8dc42-4a25-11d3-9890-006008962422}', + 'contract_ids': ['@mozilla.org/supports-string;1'], + 'type': 'nsSupportsString', + 'headers': ['nsSupportsPrimitives.h'], + }, + { + 'cid': '{d962398a-99e5-49b2-857a-c159049c7f6c}', + 'contract_ids': ['@mozilla.org/system-info;1'], + 'type': 'nsSystemInfo', + 'headers': ['nsSystemInfo.h'], + 'init_method': 'Init', + }, + { + 'cid': '{7a4204c6-e45a-4c37-8ebb-6709a22c917c}', + 'contract_ids': ['@mozilla.org/thread-manager;1'], + 'legacy_constructor': 'nsThreadManagerGetSingleton', + 'headers': ['/xpcom/build/XPCOMModule.h'], + }, + { + 'cid': '{706d36bb-bf79-4293-81f2-8f6828c18f9d}', + 'contract_ids': ['@mozilla.org/uuid-generator;1'], + 'type': 'nsUUIDGenerator', + 'headers': ['/xpcom/base/nsUUIDGenerator.h'], + 'init_method': 'Init', + }, + { + 'cid': '{0d6ea1d0-879c-11d5-90ef-0010a4e73d9a}', + 'contract_ids': ['@mozilla.org/variant;1'], + 'type': 'nsVariantCC', + 'headers': ['nsVariant.h'], + }, + { + 'cid': '{c6e47036-ca94-4be3-963a-9abd8705f7a8}', + 'contract_ids': ['@mozilla.org/xpcom/version-comparator;1'], + 'type': 'nsVersionComparatorImpl', + 'headers': ['/xpcom/base/nsVersionComparatorImpl.h'], + }, +] + +if buildconfig.substs['OS_ARCH'] == 'WINNT': + Classes += [ + { + 'cid': '{a53bc624-d577-4839-b8ec-bb5040a52ff4}', + 'contract_ids': ['@mozilla.org/windows-registry-key;1'], + 'legacy_constructor': 'nsWindowsRegKeyConstructor', + 'headers': ['nsWindowsRegKey.h'], + }, + ] + +if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + Classes += [ + { + 'cid': '{b0f20595-88ce-4738-a1a4-24de78eb8051}', + 'contract_ids': ['@mozilla.org/mac-preferences-reader;1'], + 'type': 'nsMacPreferencesReader', + 'headers': ['mozilla/nsMacPreferencesReader.h'], + }, + { + 'cid': '{697bd3fd-43e5-41ce-ad5e-c339175c0818}', + 'contract_ids': ['@mozilla.org/xpcom/mac-utils;1'], + 'type': 'nsMacUtilsImpl', + 'headers': ['/xpcom/base/nsMacUtilsImpl.h'], + }, + ] diff --git a/xpcom/build/moz.build b/xpcom/build/moz.build index 10dd22636837..fcf3dd756c0c 100755 --- a/xpcom/build/moz.build +++ b/xpcom/build/moz.build @@ -50,6 +50,10 @@ else: include('../glue/objs.mozbuild') +XPCOM_MANIFESTS += [ + 'components.conf', +] + UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs UNIFIED_SOURCES += xpcom_glue_src_cppsrcs diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index bccdc7a51952..f3a11d6bda59 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -39,6 +39,8 @@ struct Module { * This selector allows CIDEntrys to be marked so that they're only loaded * into certain kinds of processes. Selectors can be combined. */ + // Note: This must be kept in sync with the selector matching in + // nsComponentManager.cpp. enum ProcessSelector { ANY_PROCESS = 0x0, MAIN_PROCESS_ONLY = 0x1, @@ -59,6 +61,9 @@ struct Module { ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS | ALLOW_IN_SOCKET_PROCESS }; + static constexpr size_t kMaxProcessSelector = + size_t(ProcessSelector::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS); + /** * The constructor callback is an implementation detail of the default binary * loader and may be null. diff --git a/xpcom/components/StaticComponents.cpp.in b/xpcom/components/StaticComponents.cpp.in new file mode 100644 index 000000000000..8f718a2564cd --- /dev/null +++ b/xpcom/components/StaticComponents.cpp.in @@ -0,0 +1,260 @@ +/* -*- 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 + * 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/. */ + +#include "StaticComponents.h" + +#include "mozilla/PerfectHash.h" +#include "mozilla/ResultExtensions.h" +#include "mozilla/StaticPtr.h" +#include "nsCOMPtr.h" +#include "nsComponentManager.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "nsString.h" + +// Cleanup pollution from zipstruct.h +#undef UNSUPPORTED + +// Public includes +//# @includes@ + +// Relative includes +//# @relative_includes@ + +//# @decls@ + +namespace mozilla { +namespace xpcom { + +static constexpr uint32_t kNoContractID = 0xffffffff; + +namespace { +// Template helpers for constructor function sanity checks. +template +struct RemoveAlreadyAddRefed { + using Type = T; +}; + +template +struct RemoveAlreadyAddRefed> { + using Type = T; +}; +} // anonymous namespace + + +uint8_t gInvalidContracts[kContractCount / 8 + 1]; + +static StaticRefPtr gServiceInstances[kStaticModuleCount]; + +uint8_t gInitCalled[kModuleInitCount / 8 + 1]; + +static const char gStrings[] = +//# @strings@ + ""; + +const StaticCategory gStaticCategories[kStaticCategoryCount] = { +//# @categories@ +}; +const StaticCategoryEntry gStaticCategoryEntries[] = { +//# @category_entries@ +}; + +/** + * Returns a nsCString corresponding to the given entry in the `gStrings` string + * table. The resulting nsCString points directly to static storage, and does + * not incur any memory allocation overhead. + */ +static inline nsCString GetString(const StringOffset& aOffset) { + const char* str = &gStrings[aOffset.mOffset]; + nsCString result; + result.AssignLiteral(str, strlen(str)); + return result; +} + +nsCString ContractEntry::ContractID() const { + return GetString(mContractID); +} + +bool ContractEntry::Matches(const nsACString& aContractID) const { + return aContractID == ContractID() && Module().Active(); +} + + +//# @module_cid_table@ + +//# @module_contract_id_table@ + +static inline bool CalledInit(size_t aIdx) { + return GetBit(gInitCalled, aIdx); +} + +static nsresult CallInitFunc(size_t aIdx) { + if (CalledInit(aIdx)) { + return NS_OK; + } + + nsresult rv = NS_OK; + switch (aIdx) { +//# @init_funcs@ + } + + SetBit(gInitCalled, aIdx); + + MOZ_ASSERT(NS_SUCCEEDED(rv)); + return rv; +} + +static void CallUnloadFuncs() { +//# @unload_funcs@ +} + +static nsresult CreateInstanceImpl(ModuleID aID, nsISupports* aOuter, + const nsIID& aIID, void** aResult) { + if (aOuter) { + return NS_ERROR_NO_AGGREGATION; + } + + // The full set of constructors for all static modules. + // This switch statement will be compiled to a relative address jump table + // with no runtime relocations and a single indirect jump. + switch (aID) { +//# @constructors@ + } + + MOZ_ASSERT_UNREACHABLE("Constructor didn't return"); + return NS_ERROR_FAILURE; +} + + +namespace { + +class StaticModuleFactory final : public nsIFactory { + NS_DECL_ISUPPORTS + NS_DECL_NSIFACTORY + + explicit StaticModuleFactory(ModuleID aID) : mID(aID) {} + +private: + ~StaticModuleFactory() = default; + + const ModuleID mID; +}; + +NS_IMPL_ISUPPORTS(StaticModuleFactory, nsIFactory) + +NS_IMETHODIMP StaticModuleFactory::CreateInstance(nsISupports* aOuter, + const nsIID& aIID, + void** aResult) { + return CreateInstanceImpl(mID, aOuter, aIID, aResult); +} + +NS_IMETHODIMP StaticModuleFactory::LockFactory(bool aLock) { + MOZ_CRASH("LockFactory is no longer a thing"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +} // anonymous namespace + + +already_AddRefed StaticModule::GetFactory() const { + return do_AddRef(new StaticModuleFactory(ID())); +} + +bool StaticModule::Active() const { + return FastProcessSelectorMatches(mProcessSelector); +} + +bool StaticModule::Overridable() const { + return mContractID.mOffset != kNoContractID; +} + +nsCString StaticModule::ContractID() const { + MOZ_ASSERT(Overridable()); + return GetString(mContractID); +} + +nsresult StaticModule::CreateInstance(nsISupports* aOuter, const nsIID& aIID, + void** aResult) const { + return CreateInstanceImpl(ID(), aOuter, aIID, aResult); +} + + +nsISupports* StaticModule::ServiceInstance() const { + return gServiceInstances[Idx()]; +} + +void StaticModule::SetServiceInstance( + already_AddRefed aInst) const { + gServiceInstances[Idx()] = aInst; +} + + +nsCString StaticCategoryEntry::Entry() const { + return GetString(mEntry); +} +nsCString StaticCategoryEntry::Value() const { + return GetString(mValue); +} +bool StaticCategoryEntry::Active() const { + return FastProcessSelectorMatches(mProcessSelector); +} + +nsCString StaticCategory::Name() const { + return GetString(mName); +} + + +/* static */ const StaticModule* StaticComponents::LookupByCID( + const nsID& aCID) { + return ModuleByCID(aCID); +} + +/* static */ const StaticModule* StaticComponents::LookupByContractID( + const nsACString& aContractID) { + if (const ContractEntry* entry = LookupContractID(aContractID)) { + if (!entry->Invalid()) { + return &entry->Module(); + } + } + return nullptr; +} + +/* static */ bool StaticComponents::InvalidateContractID( + const nsACString& aContractID, bool aInvalid) { + if (const ContractEntry* entry = LookupContractID(aContractID)) { + entry->SetInvalid(aInvalid); + return true; + } + return false; +} + +/* static */ void StaticComponents::Shutdown() { + CallUnloadFuncs(); +} + +/* static */ const nsID& Components::GetCID(ModuleID aID) { + return gStaticModules[size_t(aID)].CID(); +} + +nsresult GetServiceHelper::operator()(const nsIID& aIID, void** aResult) const { + nsresult rv = + nsComponentManagerImpl::gComponentManager->GetService(mId, aIID, aResult); + return SetResult(rv); +} + +nsresult CreateInstanceHelper::operator()(const nsIID& aIID, + void** aResult) const { + const auto& entry = gStaticModules[size_t(mId)]; + if (!entry.Active()) { + return SetResult(NS_ERROR_FACTORY_NOT_REGISTERED); + } + + nsresult rv = entry.CreateInstance(nullptr, aIID, aResult); + return SetResult(rv); +} + +} // namespace xpcom +} // namespace mozilla diff --git a/xpcom/components/StaticComponents.h b/xpcom/components/StaticComponents.h new file mode 100644 index 000000000000..c4fd339b11b3 --- /dev/null +++ b/xpcom/components/StaticComponents.h @@ -0,0 +1,220 @@ +/* -*- 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 + * 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/. */ + +#ifndef StaticComponents_h +#define StaticComponents_h + +#include "mozilla/AlreadyAddRefed.h" +#include "mozilla/Module.h" +#include "nsID.h" +#include "nsStringFwd.h" +#include "nscore.h" + +#include "mozilla/Components.h" +#include "StaticComponentData.h" + +class nsIFactory; +class nsISupports; + +namespace mozilla { +namespace xpcom { + +struct ContractEntry; +struct StaticModule; + +struct StaticCategoryEntry; +struct StaticCategory; + +extern const StaticModule gStaticModules[kStaticModuleCount]; + +extern const ContractEntry gContractEntries[kContractCount]; +extern uint8_t gInvalidContracts[kContractCount / 8 + 1]; + +extern const StaticCategory gStaticCategories[kStaticCategoryCount]; +extern const StaticCategoryEntry gStaticCategoryEntries[]; + +template +static inline bool GetBit(const uint8_t (&aBits)[N], size_t aBit) { + static constexpr size_t width = sizeof(aBits[0]) * 8; + + size_t idx = aBit / width; + MOZ_ASSERT(idx < N); + return aBits[idx] & (1 << (aBit % width)); +} + +template +static inline void SetBit(uint8_t (&aBits)[N], size_t aBit, + bool aValue = true) { + static constexpr size_t width = sizeof(aBits[0]) * 8; + + size_t idx = aBit / width; + MOZ_ASSERT(idx < N); + if (aValue) { + aBits[idx] |= 1 << (aBit % width); + } else { + aBits[idx] &= ~(1 << (aBit % width)); + } +} + +/** + * Represents a string entry in the static string table. Can be converted to a + * nsCString using GetString() in StaticComponents.cpp. + * + * This is a struct rather than a pure offset primarily for the purposes of type + * safety, but also so that it can easily be extended to include a static length + * in the future, if efficiency concerns warrant it. + */ +struct StringOffset final { + uint32_t mOffset; +}; + +/** + * Represents a static component entry defined in a `Classes` list in an XPCOM + * manifest. Handles creating instances of and caching service instances for + * that class. + */ +struct StaticModule { + nsID mCID; + StringOffset mContractID; + Module::ProcessSelector mProcessSelector; + + const nsID& CID() const { return mCID; } + + ModuleID ID() const { return ModuleID(this - gStaticModules); } + + /** + * Returns this entry's index in the gStaticModules array. + */ + size_t Idx() const { return size_t(ID()); } + + /** + * Returns true if this component's corresponding contract ID is expected to + * be overridden at runtime. If so, it should always be looked up by its + * ContractID() when retrieving its service instance. + */ + bool Overridable() const; + + /** + * If this entry is overridable, returns its associated contract ID string. + * The component should always be looked up by this contract ID when + * retrieving its service instance. + * + * Note: This may *only* be called if Overridable() returns true. + */ + nsCString ContractID() const; + + /** + * Returns true if this entry is active. Typically this will only return false + * if the entry's process selector does not match this process. + */ + bool Active() const; + + already_AddRefed GetFactory() const; + + nsresult CreateInstance(nsISupports* aOuter, const nsIID& aIID, + void** aResult) const; + + nsISupports* ServiceInstance() const; + void SetServiceInstance(already_AddRefed aInst) const; +}; + +/** + * Represents a static mapping between a contract ID string and a StaticModule + * entry. + */ +struct ContractEntry final { + StringOffset mContractID; + ModuleID mModuleID; + + size_t Idx() const { return this - gContractEntries; } + + nsCString ContractID() const; + + const StaticModule& Module() const { + return gStaticModules[size_t(mModuleID)]; + } + + /** + * Returns true if this entry's underlying module is active, and its contract + * ID matches the given contract ID string. This is used by the PerfectHash + * function to determine whether to return a result for this entry. + */ + bool Matches(const nsACString& aContractID) const; + + /** + * Returns true if this entry has been invalidated, and should be ignored. + * + * Contract IDs may be overwritten at runtime. When that happens for a static + * contract ID, we mark its entry invalid, and ignore it thereafter. + */ + bool Invalid() const { return GetBit(gInvalidContracts, Idx()); } + + /** + * Marks this entry invalid (or unsets the invalid bit if aInvalid is false), + * after which it will be ignored in contract ID lookup attempts. See + * `Invalid()` above. + */ + void SetInvalid(bool aInvalid = true) const { + return SetBit(gInvalidContracts, Idx(), aInvalid); + } +}; + +/** + * Represents a declared category manager entry declared in an XPCOM manifest. + * + * The entire set of static category entries is read at startup and loaded into + * the category manager's dynamic hash tables, so there is memory and + * initialization overhead for each entry in these tables. This may be further + * optimized in the future to reduce some of that overhead. + */ +struct StaticCategoryEntry final { + StringOffset mEntry; + StringOffset mValue; + Module::ProcessSelector mProcessSelector; + + nsCString Entry() const; + nsCString Value() const; + bool Active() const; +}; + +struct StaticCategory final { + StringOffset mName; + uint16_t mStart; + uint16_t mCount; + + nsCString Name() const; + + const StaticCategoryEntry* begin() const { + return &gStaticCategoryEntries[mStart]; + } + const StaticCategoryEntry* end() const { + return &gStaticCategoryEntries[mStart + mCount]; + } +}; + +class StaticComponents final { + public: + static const StaticModule* LookupByCID(const nsID& aCID); + + static const StaticModule* LookupByContractID(const nsACString& aContractID); + + /** + * Marks a static contract ID entry invalid (or unsets the invalid bit if + * aInvalid is false). See `CategoryEntry::Invalid()`. + */ + static bool InvalidateContractID(const nsACString& aContractID, + bool aInvalid = true); + + /** + * Calls any module unload from manifests whose components have been loaded. + */ + static void Shutdown(); +}; + +} // namespace xpcom +} // namespace mozilla + +#endif // defined StaticComponents_h diff --git a/xpcom/components/components.conf b/xpcom/components/components.conf new file mode 100644 index 000000000000..7ffaa75b1e6a --- /dev/null +++ b/xpcom/components/components.conf @@ -0,0 +1,21 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{16d222a6-1dd2-11b2-b693-f38b02c021b2}', + 'contract_ids': ['@mozilla.org/categorymanager;1'], + 'legacy_constructor': 'nsCategoryManager::Create', + 'headers': ['/xpcom/components/nsCategoryManager.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS, + }, + { + 'cid': '{91775d60-d5dc-11d2-92fb-00e09805570f}', + 'legacy_constructor': 'nsComponentManagerImpl::Create', + 'headers': ['/xpcom/components/nsComponentManager.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS, + }, +] diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py new file mode 100644 index 000000000000..04f09b26825a --- /dev/null +++ b/xpcom/components/gen_static_components.py @@ -0,0 +1,780 @@ +import json +import os +import re +import struct +from collections import defaultdict + +from uuid import UUID + +from mozbuild.util import FileAvoidWrite +from perfecthash import PerfectHash +import buildconfig + + +NO_CONTRACT_ID = 0xffffffff + +PHF_SIZE = 512 + +ENDIAN = '<' if buildconfig.substs['TARGET_ENDIANNESS'] == 'little' else '>' + + +# Represents a UUID in the format used internally by Gecko, and supports +# serializing it in that format to both C++ source and raw byte arrays. +class UUIDRepr(object): + + def __init__(self, uuid): + self.uuid = uuid + + fields = uuid.fields + + self.a = fields[0] + self.b = fields[1] + self.c = fields[2] + + d = list(fields[3:5]) + for i in range(0, 6): + d.append(fields[5] >> (8 * (5 - i)) & 0xff) + + self.d = tuple(d) + + def __str__(self): + return str(self.uuid) + + @property + def bytes(self): + return struct.pack(ENDIAN + 'IHHBBBBBBBB', + self.a, self.b, self.c, *self.d) + + def to_cxx(self): + rest = ', '.join('0x%02x' % b for b in self.d) + + return '{ 0x%x, 0x%x, 0x%x, { %s } }' % (self.a, self.b, self.c, + rest) + + +# Corresponds to the Module::ProcessSelector enum in Module.h. The actual +# values don't matter, since the code generator emits symbolic constants for +# these values, but we use the same values as the enum constants for clarity. +class ProcessSelector: + ANY_PROCESS = 0x0 + MAIN_PROCESS_ONLY = 0x1 + CONTENT_PROCESS_ONLY = 0x2 + ALLOW_IN_GPU_PROCESS = 0x4 + ALLOW_IN_VR_PROCESS = 0x8 + ALLOW_IN_SOCKET_PROCESS = 0x10 + ALLOW_IN_GPU_AND_SOCKET_PROCESS = (ALLOW_IN_GPU_PROCESS | + ALLOW_IN_SOCKET_PROCESS) + ALLOW_IN_GPU_AND_VR_PROCESS = ALLOW_IN_GPU_PROCESS | ALLOW_IN_VR_PROCESS + ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS = (ALLOW_IN_GPU_PROCESS | + ALLOW_IN_VR_PROCESS | + ALLOW_IN_SOCKET_PROCESS) + + +# Maps ProcessSelector constants to the name of the corresponding +# Module::ProcessSelector enum value. +PROCESSES = { + ProcessSelector.ANY_PROCESS: 'ANY_PROCESS', + ProcessSelector.MAIN_PROCESS_ONLY: 'MAIN_PROCESS_ONLY', + ProcessSelector.CONTENT_PROCESS_ONLY: 'CONTENT_PROCESS_ONLY', + ProcessSelector.ALLOW_IN_GPU_PROCESS: 'ALLOW_IN_GPU_PROCESS', + ProcessSelector.ALLOW_IN_VR_PROCESS: 'ALLOW_IN_VR_PROCESS', + ProcessSelector.ALLOW_IN_SOCKET_PROCESS: 'ALLOW_IN_SOCKET_PROCESS', + ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS: 'ALLOW_IN_GPU_AND_SOCKET_PROCESS', + ProcessSelector.ALLOW_IN_GPU_AND_VR_PROCESS: 'ALLOW_IN_GPU_AND_VR_PROCESS', + ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS: 'ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS', +} + + +# Emits the C++ symbolic constant corresponding to a ProcessSelector constant. +def lower_processes(processes): + return 'Module::ProcessSelector::%s' % PROCESSES[processes] + + +# Emits the C++ symbolic constant for a ModuleEntry's ModuleID enum entry. +def lower_module_id(module): + return 'ModuleID::%s' % module.name + + +# Represents a static string table, indexed by offset. This allows us to +# reference strings from static data structures without requiring runtime +# relocations. +class StringTable(object): + + def __init__(self): + self.entries = {} + self.entry_list = [] + self.size = 0 + + self._serialized = False + + # Returns the index of the given string in the `entry_list` array. If + # no entry for the string exists, it first creates one. + def get_idx(self, string): + idx = self.entries.get(string, None) + if idx is not None: + return idx + + assert not self._serialized + + assert len(string) == len(string.encode('utf-8')) + + idx = self.size + self.size += len(string) + 1 + + self.entries[string] = idx + self.entry_list.append(string) + return idx + + # Returns the C++ code representing string data of this string table, as a + # single string literal. This must only be called after the last call to + # `get_idx()` or `entry_to_cxx()` for this instance. + def to_cxx(self): + self._serialized = True + + lines = [] + + idx = 0 + for entry in self.entry_list: + str_ = entry.replace('\\', '\\\\').replace('"', r'\"') \ + .replace('\n', r'\n') + + lines.append(' /* 0x%x */ "%s\\0"\n' % (idx, str_)) + + idx += len(entry) + 1 + + return ''.join(lines) + + # Returns a `StringEntry` struct initializer for the string table entry + # corresponding to the given string. If no matching entry exists, it is + # first created. + def entry_to_cxx(self, string): + idx = self.get_idx(string) + return '{ 0x%x } /* %s */' % ( + idx, + pretty_string(string)) + + +strings = StringTable() + + +# Represents a C++ namespace, containing a set of classes and potentially +# sub-namespaces. This is used to generate pre-declarations for incomplete +# types referenced in XPCOM manifests. +class Namespace(object): + + def __init__(self, name=None): + self.name = name + self.classes = set() + self.namespaces = {} + + # Returns a Namespace object for the sub-namespace with the given name. + def sub(self, name): + assert name not in self.classes + + if name not in self.namespaces: + self.namespaces[name] = Namespace(name) + return self.namespaces[name] + + # Generates C++ code to pre-declare all classes in this namespace and all + # of its sub-namespaces. + def to_cxx(self): + res = "" + if self.name: + res += 'namespace %s {\n' % self.name + + for clas in sorted(self.classes): + res += 'class %s;\n' % clas + + for ns in sorted(self.namespaces.keys()): + res += self.namespaces[ns].to_cxx() + + if self.name: + res += '} // namespace %s\n' % self.name + + return res + + +# Represents a component defined in an XPCOM manifest's `Classes` array. +class ModuleEntry(object): + next_anon_id = 0 + + def __init__(self, data, init_idx): + self.cid = UUIDRepr(UUID(data['cid'])) + self.contract_ids = data.get('contract_ids', []) + self.type = data.get('type', 'nsISupports') + self.categories = data.get('categories', {}) + self.processes = data.get('processes', 0) + self.headers = data.get('headers', []) + + # If the manifest declares Init or Unload functions, this contains its + # index, as understood by the `CallInitFunc()` function. + # + # If it contains any value other than `None`, a corresponding + # `CallInitFunc(init_idx)` call will be genrated before calling this + # module's constructor. + self.init_idx = init_idx + + self.constructor = data.get('constructor', None) + self.legacy_constructor = data.get('legacy_constructor', None) + self.init_method = data.get('init_method', []) + + self.external = data.get('external', not (self.headers or + self.legacy_constructor)) + self.singleton = data.get('singleton', False) + self.overridable = data.get('overridable', False) + + if 'name' in data: + self.anonymous = False + self.name = data['name'] + else: + self.anonymous = True + self.name = 'Anonymous%03d' % ModuleEntry.next_anon_id + ModuleEntry.next_anon_id += 1 + + def error(str_): + raise Exception("Error defining component %s (%s): %s" % ( + str(self.cid), ', '.join(map(repr, self.contract_ids)), + str_)) + + if self.external: + if self.constructor or self.legacy_constructor: + error("Externally-constructed components may not specify " + "'constructor' or 'legacy_constructor' properties") + if self.init_method: + error("Externally-constructed components may not specify " + "'init_method' properties") + if self.type == 'nsISupports': + error("Externally-constructed components must specify a type " + "other than nsISupports") + + if self.constructor and self.legacy_constructor: + error("The 'constructor' and 'legacy_constructor' properties " + "are mutually exclusive") + + if self.overridable and not self.contract_ids: + error("Overridable components must specify at least one contract " + "ID") + + @property + def contract_id(self): + return self.contract_ids[0] + + # Generates the C++ code for a StaticModule struct initializer + # representing this component. + def to_cxx(self): + contract_id = (strings.entry_to_cxx(self.contract_id) + if self.overridable + else '{ 0x%x }' % NO_CONTRACT_ID) + + return """ + /* {name} */ {{ + /* {{{cid_string}}} */ + {cid}, + {contract_id}, + {processes}, + }}""".format(name=self.name, cid=self.cid.to_cxx(), + cid_string=str(self.cid), + contract_id=contract_id, + processes=lower_processes(self.processes)) + + # Generates the C++ code necessary to construct an instance of this + # component. + # + # This code lives in a function with the following arguments: + # + # - aIID: The `const nsIID&` interface ID that the resulting instance + # will be queried to. + # + # - aResult: The `void**` pointer in which to store the result. + # + # And which returns an `nsresult` indicating success or failure. + def lower_constructor(self): + res = '' + + if self.init_idx is not None: + res += ' MOZ_TRY(CallInitFunc(%d));\n' % self.init_idx + + if self.legacy_constructor: + res += (' return /* legacy */ %s(nullptr, aIID, aResult);\n' + % self.legacy_constructor) + return res + + if self.external: + res += (' nsCOMPtr inst = ' + 'mozCreateComponent<%s>();\n' % self.type) + else: + res += ' RefPtr<%s> inst = ' % self.type + + if not self.constructor: + res += 'new %s();\n' % self.type + else: + res += '%s();\n' % self.constructor + # The `new` operator is infallible, so we don't need to worry + # about it returning null, but custom constructors may, so + # check before calling any methods. + res += ' NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);\n' + + # Check that the constructor function returns an appropriate + # `already_AddRefed` value for our declared type. + res += """ + using T = + RemoveAlreadyAddRefed::Type; + static_assert( + mozilla::IsSame, decltype(%(constructor)s())>::value, + "Singleton constructor must return already_AddRefed"); + static_assert( + mozilla::IsBaseOf<%(type)s, T>::value, + "Singleton constructor must return correct already_AddRefed"); + +""" % {'type': self.type, 'constructor': self.constructor} + + if self.init_method: + res += ' MOZ_TRY(inst->%s());\n' % self.init_method + + res += ' return inst->QueryInterface(aIID, aResult);\n' + + return res + + # Generates the C++ code for the `mozilla::components::` entry + # corresponding to this component. This may not be called for modules + # without an explicit `name` (in which cases, `self.anonymous` will be + # true). + def lower_getters(self): + assert not self.anonymous + + substs = { + 'name': self.name, + 'id': '::mozilla::xpcom::ModuleID::%s' % self.name, + } + + res = """ +namespace %(name)s { +static inline const nsID& CID() { + return ::mozilla::xpcom::Components::GetCID(%(id)s); +} + +static inline ::mozilla::xpcom::GetServiceHelper Service(nsresult* aRv = nullptr) { + return {%(id)s, aRv}; +} +""" % substs + + if not self.singleton: + res += """ +static inline ::mozilla::xpcom::CreateInstanceHelper Create(nsresult* aRv = nullptr) { + return {%(id)s, aRv}; +} +""" % substs + + res += """\ +} // namespace %(name)s +""" % substs + + return res + + +# Returns a quoted string literal representing the given raw string, with +# certain special characters replaced so that it can be used in a C++-style +# (/* ... */) comment. +def pretty_string(string): + return (json.dumps(string).replace('*/', r'*\/') + .replace('/*', r'/\*')) + + +# Represents a static contract ID entry, corresponding to a C++ ContractEntry +# struct, mapping a contract ID to a static module entry. +class ContractEntry(object): + + def __init__(self, contract, module): + self.contract = contract + self.module = module + + def to_cxx(self): + return """ + {{ + {contract}, + {module_id}, + }}""".format(contract=strings.entry_to_cxx(self.contract), + module_id=lower_module_id(self.module)) + + +# Generates the C++ code for the StaticCategoryEntry and StaticCategory +# structs for all category entries declared in XPCOM manifests. +def gen_categories(substs, categories): + cats = [] + ents = [] + + count = 0 + for category, entries in sorted(categories.items()): + entries.sort() + + cats.append(' { %s,\n' + ' %d, %d },\n' + % (strings.entry_to_cxx(category), + count, len(entries))) + count += len(entries) + + ents.append(' /* %s */\n' % pretty_string(category)) + for entry, value, processes in entries: + ents.append(' { %s,\n' + ' %s,\n' + ' %s },\n' + % (strings.entry_to_cxx(entry), + strings.entry_to_cxx(value), + lower_processes(processes))) + ents.append('\n') + ents.pop() + + substs['category_count'] = len(cats) + substs['categories'] = ''.join(cats) + substs['category_entries'] = ''.join(ents) + + +# Generates the C++ code for all Init and Unload functions declared in XPCOM +# manifests. These form the bodies of the `CallInitFunc()` and `CallUnload` +# functions in StaticComponents.cpp. +def gen_module_funcs(substs, funcs): + inits = [] + unloads = [] + + template = """\ + case %d: + %s + break; +""" + + for i, (init, unload) in enumerate(funcs): + init_code = '%s();' % init if init else '/* empty */' + inits.append(template % (i, init_code)) + + if unload: + unloads.append("""\ + if (CalledInit(%d)) { + %s(); + } +""" % (i, unload)) + + substs['init_funcs'] = ''.join(inits) + substs['unload_funcs'] = ''.join(unloads) + substs['init_count'] = len(funcs) + + +# Generates class pre-declarations for any types referenced in `Classes` array +# entries which do not have corresponding `headers` entries to fully declare +# their types. +def gen_decls(types): + root_ns = Namespace() + + for type_ in sorted(types): + parts = type_.split('::') + + ns = root_ns + for part in parts[:-1]: + ns = ns.sub(part) + ns.classes.add(parts[-1]) + + return root_ns.to_cxx() + + +# Generates the `switch` body for the `CreateInstanceImpl()` function, with a +# `case` for each value in ModuleID to construct an instance of the +# corresponding component. +def gen_constructors(entries): + constructors = [] + for entry in entries: + constructors.append("""\ + case {id}: {{ +{constructor}\ + }} +""".format(id=lower_module_id(entry), + constructor=entry.lower_constructor())) + + return ''.join(constructors) + + +# Generates the getter code for each named component entry in the +# `mozilla::components::` namespace. +def gen_getters(entries): + entries = list(entries) + entries.sort(key=lambda e: e.name) + + return ''.join(entry.lower_getters() + for entry in entries + if not entry.anonymous) + + +def gen_includes(substs, all_headers): + headers = set() + absolute_headers = set() + + for header in all_headers: + if header.startswith('/'): + absolute_headers.add(header) + else: + headers.add(header) + + includes = ['#include "%s"' % header for header in sorted(headers)] + substs['includes'] = '\n'.join(includes) + '\n' + + relative_includes = ['#include "../..%s"' % header + for header in sorted(absolute_headers)] + substs['relative_includes'] = '\n'.join(relative_includes) + '\n' + + +def to_list(val): + if isinstance(val, (list, tuple)): + return val + return val, + + +def gen_substs(manifests): + module_funcs = [] + + headers = set() + + modules = [] + + for manifest in manifests: + headers |= set(manifest.get('Headers', [])) + + init_idx = None + init = manifest.get('InitFunc') + unload = manifest.get('UnloadFunc') + if init or unload: + init_idx = len(module_funcs) + module_funcs.append((init, unload)) + + for clas in manifest['Classes']: + modules.append(ModuleEntry(clas, init_idx)) + + contracts = [] + contract_map = {} + categories = defaultdict(list) + + types = set() + + for mod in modules: + headers |= set(mod.headers) + + for contract_id in mod.contract_ids: + if contract_id in contract_map: + raise Exception('Duplicate contract ID: %s' % contract_id) + + entry = ContractEntry(contract_id, mod) + contracts.append(entry) + contract_map[contract_id] = entry + + for category, entries in mod.categories.items(): + for entry in to_list(entries): + categories[category].append((entry, mod.contract_id, + mod.processes)) + + if mod.type and not mod.headers: + types.add(mod.type) + + cid_phf = PerfectHash(modules, PHF_SIZE, + key=lambda module: module.cid.bytes) + + contract_phf = PerfectHash(contracts, PHF_SIZE, + key=lambda entry: entry.contract) + + substs = {} + + gen_categories(substs, categories) + + substs['module_ids'] = ''.join(' %s,\n' % entry.name + for entry in cid_phf.entries) + + substs['module_count'] = len(modules) + substs['contract_count'] = len(contracts) + + gen_module_funcs(substs, module_funcs) + + gen_includes(substs, headers) + + substs['decls'] = gen_decls(types) + + substs['constructors'] = gen_constructors(cid_phf.entries) + + substs['component_getters'] = gen_getters(cid_phf.entries) + + substs['module_cid_table'] = cid_phf.cxx_codegen( + name='ModuleByCID', + entry_type='StaticModule', + entries_name='gStaticModules', + lower_entry=lambda entry: entry.to_cxx(), + + return_type='const StaticModule*', + return_entry=('return entry.CID().Equals(aKey) && entry.Active()' + ' ? &entry : nullptr;'), + + key_type='const nsID&', + key_bytes='reinterpret_cast(&aKey)', + key_length='sizeof(nsID)') + + substs['module_contract_id_table'] = contract_phf.cxx_codegen( + name='LookupContractID', + entry_type='ContractEntry', + entries_name='gContractEntries', + lower_entry=lambda entry: entry.to_cxx(), + + return_type='const ContractEntry*', + return_entry='return entry.Matches(aKey) ? &entry : nullptr;', + + key_type='const nsACString&', + key_bytes='aKey.BeginReading()', + key_length='aKey.Length()') + + # Do this only after everything else has been emitted so we're sure the + # string table is complete. + substs['strings'] = strings.to_cxx() + return substs + + +# Returns true if the given build config substitution is defined and truthy. +def defined(subst): + return bool(buildconfig.substs.get(subst)) + + +def read_manifest(filename): + glbl = {'buildconfig': buildconfig, + 'defined': defined, + 'ProcessSelector': ProcessSelector} + execfile(filename, glbl) + return glbl + + +def main(fd, conf_file, template_file): + def open_output(filename): + return FileAvoidWrite(os.path.join(os.path.dirname(fd.name), filename)) + + conf = json.load(open(conf_file, 'r')) + + deps = set() + + manifests = [] + for filename in conf['manifests']: + deps.add(filename) + manifest = read_manifest(filename) + manifests.append(manifest) + manifest.setdefault('Priority', 50) + manifest['__filename__'] = filename + + manifests.sort(key=lambda man: (man['Priority'], man['__filename__'])) + + substs = gen_substs(manifests) + + def replacer(match): + return substs[match.group(1)] + + with open_output('StaticComponents.cpp') as fh: + with open(template_file, 'r') as tfh: + template = tfh.read() + + fh.write(re.sub(r'//# @([a-zA-Z_]+)@\n', replacer, template)) + + with open_output('StaticComponentData.h') as fh: + fh.write("""\ +/* -*- 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 + * 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/. */ + +#ifndef StaticComponentData_h +#define StaticComponentData_h + +namespace mozilla { +namespace xpcom { + +static constexpr size_t kStaticModuleCount = %(module_count)d; + +static constexpr size_t kContractCount = %(contract_count)d; + +static constexpr size_t kStaticCategoryCount = %(category_count)d; + +static constexpr size_t kModuleInitCount = %(init_count)d; + +} // namespace xpcom +} // namespace mozilla + +#endif +""" % substs) + + fd.write("""\ +/* -*- 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 + * 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/. */ + +#ifndef mozilla_Components_h +#define mozilla_Components_h + +#include "nsCOMPtr.h" + +struct nsID; + +#define NS_IMPL_COMPONENT_FACTORY(iface) \\ + template <> \\ + already_AddRefed mozCreateComponent() + +template +already_AddRefed mozCreateComponent(); + +namespace mozilla { +namespace xpcom { + +enum class ModuleID : uint16_t { +%(module_ids)s +}; + +class MOZ_STACK_CLASS StaticModuleHelper : public nsCOMPtr_helper { + public: + StaticModuleHelper(ModuleID aId, nsresult* aErrorPtr) + : mId(aId), mErrorPtr(aErrorPtr) {} + + protected: + nsresult SetResult(nsresult aRv) const { + if (mErrorPtr) { + *mErrorPtr = aRv; + } + return aRv; + } + + ModuleID mId; + nsresult* mErrorPtr; +}; + +class MOZ_STACK_CLASS GetServiceHelper final : public StaticModuleHelper { + public: + using StaticModuleHelper::StaticModuleHelper; + + nsresult NS_FASTCALL operator()(const nsIID& aIID, + void** aResult) const override; +}; + +class MOZ_STACK_CLASS CreateInstanceHelper final : public StaticModuleHelper { + public: + using StaticModuleHelper::StaticModuleHelper; + + nsresult NS_FASTCALL operator()(const nsIID& aIID, + void** aResult) const override; +}; + +class Components final { + public: + static const nsID& GetCID(ModuleID aID); +}; + +} // namespace xpcom + +namespace components { +%(component_getters)s +} // namespace components + +} // namespace mozilla + +#endif +""" % substs) + + return deps diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build index 188794e18cee..4b76cc89fd26 100644 --- a/xpcom/components/moz.build +++ b/xpcom/components/moz.build @@ -29,6 +29,24 @@ EXPORTS.mozilla += [ 'ModuleUtils.h', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + +if CONFIG['COMPILE_ENVIRONMENT']: + EXPORTS.mozilla += [ + '!Components.h', + ] + + generated = ('Components.h', 'StaticComponentData.h', + 'StaticComponents.cpp') + + GENERATED_FILES += [generated] + + gen = GENERATED_FILES[generated] + gen.script = 'gen_static_components.py' + gen.inputs += ['!manifest-lists.json', 'StaticComponents.cpp.in'] + UNIFIED_SOURCES += [ 'GenericFactory.cpp', 'ManifestParser.cpp', @@ -38,6 +56,10 @@ UNIFIED_SOURCES += [ 'nsComponentManagerUtils.cpp', ] +SOURCES += [ + '!StaticComponents.cpp', +] + FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ @@ -53,3 +75,5 @@ LOCAL_INCLUDES += [ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: CXXFLAGS += CONFIG['TK_CFLAGS'] + +include('/ipc/chromium/chromium-config.mozbuild') diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index ed067e7c406e..005548562aa4 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -10,6 +10,8 @@ #include "nspr.h" #include "nsCRT.h" // for atoll +#include "StaticComponents.h" + #include "nsCategoryManager.h" #include "nsCOMPtr.h" #include "nsComponentManager.h" @@ -48,9 +50,12 @@ #include "nsIMutableArray.h" #include "nsArrayEnumerator.h" #include "nsStringEnumerator.h" +#include "mozilla/DebugOnly.h" #include "mozilla/FileUtils.h" +#include "mozilla/ScopeExit.h" #include "mozilla/URLPreloader.h" #include "mozilla/UniquePtr.h" +#include "mozilla/Variant.h" #include "nsDataHashtable.h" #include // for placement new @@ -65,6 +70,7 @@ #endif using namespace mozilla; +using namespace mozilla::xpcom; static LazyLogModule nsComponentManagerLog("nsComponentManager"); @@ -115,12 +121,141 @@ nsresult nsGetServiceFromCategory::operator()(const nsIID& aIID, return rv; } +namespace { + +class AutoIDString : public nsAutoCStringN { + public: + explicit AutoIDString(const nsID& aID) { + SetLength(NSID_LENGTH - 1); + aID.ToProvidedString(*reinterpret_cast(BeginWriting())); + } +}; + +} + +namespace mozilla { +namespace xpcom { + +using ProcessSelector = Module::ProcessSelector; + +// Note: These must be kept in sync with the ProcessSelector definition in +// Module.h. +bool ProcessSelectorMatches(ProcessSelector aSelector) { + GeckoProcessType type = XRE_GetProcessType(); + if (type == GeckoProcessType_GPU || type == GeckoProcessType_RDD) { + return !!(aSelector & Module::ALLOW_IN_GPU_PROCESS); + } + + if (type == GeckoProcessType_Socket) { + return !!(aSelector & (Module::ALLOW_IN_SOCKET_PROCESS)); + } + + if (type == GeckoProcessType_VR) { + return !!(aSelector & Module::ALLOW_IN_VR_PROCESS); + } + + if (aSelector & Module::MAIN_PROCESS_ONLY) { + return type == GeckoProcessType_Default; + } + if (aSelector & Module::CONTENT_PROCESS_ONLY) { + return type == GeckoProcessType_Content; + } + return true; +} + +static bool gProcessMatchTable[Module::kMaxProcessSelector + 1]; + +bool FastProcessSelectorMatches(ProcessSelector aSelector) { + return gProcessMatchTable[size_t(aSelector)]; +} + +} // namespace xpcom +} // namespace mozilla + +namespace { + +/** + * A wrapper simple wrapper class, which can hold either a dynamic + * nsFactoryEntry instance, or a static StaticModule entry, and transparently + * forwards method calls to the wrapped object. + * + * This allows the same code to work with either static or dynamic modules + * without caring about the difference. + */ +class MOZ_STACK_CLASS EntryWrapper final { + public: + explicit EntryWrapper(nsFactoryEntry* aEntry) : mEntry(aEntry) {} + + explicit EntryWrapper(const StaticModule* aEntry) : mEntry(aEntry) {} + +#define MATCH(type, ifFactory, ifStatic) \ + struct Matcher { \ + type match(nsFactoryEntry* entry) { ifFactory; } \ + type match(const StaticModule* entry) { ifStatic; } \ + }; \ + return mEntry.match((Matcher())) + + const nsID& CID() { + MATCH(const nsID&, return *entry->mCIDEntry->cid, return entry->CID()); + } + + already_AddRefed GetFactory() { + MATCH(already_AddRefed, return entry->GetFactory(), + return entry->GetFactory()); + } + + /** + * Creates an instance of the underlying component. This should be used in + * preference to GetFactory()->CreateInstance() where appropriate, since it + * side-steps the necessity of creating a nsIFactory instance for static + * modules. + */ + nsresult CreateInstance(nsISupports* aOuter, const nsIID& aIID, + void** aResult) { + if (mEntry.is()) { + return mEntry.as()->CreateInstance(aOuter, aIID, + aResult); + } + return mEntry.as()->CreateInstance(aOuter, aIID, + aResult); + } + + /** + * Returns the cached service instance for this entry, if any. This should + * only be accessed while mLock is held. + */ + nsISupports* ServiceInstance() { + MATCH(nsISupports*, return entry->mServiceObject, + return entry->ServiceInstance()); + } + void SetServiceInstance(already_AddRefed aInst) { + if (mEntry.is()) { + mEntry.as()->mServiceObject = aInst; + } else { + return mEntry.as()->SetServiceInstance( + std::move(aInst)); + } + } + + /** + * Returns the description string for the module this entry belongs to. For + * static entries, always returns "". + */ + nsCString ModuleDescription() { + MATCH(nsCString, + return entry->mModule ? entry->mModule->Description() + : NS_LITERAL_CSTRING(""), + return NS_LITERAL_CSTRING("")); + } + + private: + Variant mEntry; +}; + // GetService and a few other functions need to exit their mutex mid-function // without reentering it later in the block. This class supports that // style of early-exit that MutexAutoUnlock doesn't. -namespace { - class MOZ_STACK_CLASS MutexLock { public: explicit MutexLock(SafeMutex& aMutex) : mMutex(aMutex), mLocked(false) { @@ -202,7 +337,7 @@ nsresult nsComponentManagerImpl::Create(nsISupports* aOuter, REFNSIID aIID, return gComponentManager->QueryInterface(aIID, aResult); } -static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 1024; +static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 256; nsComponentManagerImpl::nsComponentManagerImpl() : mFactories(CONTRACTID_HASHTABLE_INITIAL_LENGTH), @@ -312,6 +447,27 @@ nsTArray* } nsresult nsComponentManagerImpl::Init() { + { + gProcessMatchTable[size_t(ProcessSelector::ANY_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ANY_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::MAIN_PROCESS_ONLY)] = + ProcessSelectorMatches(ProcessSelector::MAIN_PROCESS_ONLY); + gProcessMatchTable[size_t(ProcessSelector::CONTENT_PROCESS_ONLY)] = + ProcessSelectorMatches(ProcessSelector::CONTENT_PROCESS_ONLY); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GPU_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_VR_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_VR_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_SOCKET_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_SOCKET_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_AND_VR_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GPU_AND_VR_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_AND_SOCKET_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GPU_AND_SOCKET_PROCESS); + gProcessMatchTable[size_t(ProcessSelector::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS)] = + ProcessSelectorMatches(ProcessSelector::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS); + } + MOZ_ASSERT(NOT_INITIALIZED == mStatus); nsCOMPtr greDir = GetLocationFromDirectoryService(NS_GRE_DIR); @@ -335,6 +491,15 @@ nsresult nsComponentManagerImpl::Init() { RegisterModule((*sExtraStaticModules)[i]); } + auto* catMan = nsCategoryManager::GetSingleton(); + for (const auto& cat : gStaticCategories) { + for (const auto& entry : cat) { + if (entry.Active()) { + catMan->AddCategoryEntry(cat.Name(), entry.Entry(), entry.Value()); + } + } + } + bool loadChromeManifests; switch (XRE_GetProcessType()) { // We are going to assume that only a select few (see below) process types @@ -432,32 +597,13 @@ nsresult nsComponentManagerImpl::Init() { mStatus = NORMAL; + MOZ_ASSERT(!XRE_IsContentProcess() || + mFactories.Count() > CONTRACTID_HASHTABLE_INITIAL_LENGTH / 3, + "Initial component hashtable size is too large"); + return NS_OK; } -static bool ProcessSelectorMatches(Module::ProcessSelector aSelector) { - GeckoProcessType type = XRE_GetProcessType(); - if (type == GeckoProcessType_GPU || type == GeckoProcessType_RDD) { - return !!(aSelector & Module::ALLOW_IN_GPU_PROCESS); - } - - if (type == GeckoProcessType_Socket) { - return !!(aSelector & (Module::ALLOW_IN_SOCKET_PROCESS)); - } - - if (type == GeckoProcessType_VR) { - return !!(aSelector & Module::ALLOW_IN_VR_PROCESS); - } - - if (aSelector & Module::MAIN_PROCESS_ONLY) { - return type == GeckoProcessType_Default; - } - if (aSelector & Module::CONTENT_PROCESS_ONLY) { - return type == GeckoProcessType_Content; - } - return true; -} - static const int kModuleVersionWithSelector = 51; template @@ -562,9 +708,6 @@ void nsComponentManagerImpl::RegisterCIDEntryLocked( nsFactoryEntry* f = entry.Data(); NS_WARNING("Re-registering a CID?"); - char idstr[NSID_LENGTH]; - aEntry->cid->ToProvidedString(idstr); - nsCString existing; if (f->mModule) { existing = f->mModule->Description(); @@ -575,7 +718,8 @@ void nsComponentManagerImpl::RegisterCIDEntryLocked( LogMessage( "While registering XPCOM module %s, trying to re-register CID '%s' " "already registered by %s.", - aModule->Description().get(), idstr, existing.get()); + aModule->Description().get(), AutoIDString(*aEntry->cid).get(), + existing.get()); } else { entry.OrInsert( [aEntry, aModule]() { return new nsFactoryEntry(aEntry, aModule); }); @@ -594,14 +738,11 @@ void nsComponentManagerImpl::RegisterContractIDLocked( if (!f) { NS_WARNING("No CID found when attempting to map contract ID"); - char idstr[NSID_LENGTH]; - aEntry->cid->ToProvidedString(idstr); - SafeMutexAutoUnlock unlock(mLock); LogMessage( "Could not map contract ID '%s' to CID %s because no implementation of " "the CID is registered.", - aEntry->contractid, idstr); + aEntry->contractid, AutoIDString(*aEntry->cid).get()); return; } @@ -665,23 +806,15 @@ void nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& aCx, fl.GetURIString(hash); MutexLock lock(mLock); - nsFactoryEntry* f = mFactories.Get(&cid); - if (f) { - char idstr[NSID_LENGTH]; - cid.ToProvidedString(idstr); - - nsCString existing; - if (f->mModule) { - existing = f->mModule->Description(); - } else { - existing = ""; - } + if (Maybe f = LookupByCID(lock, cid)) { + nsCString existing(f->ModuleDescription()); lock.Unlock(); LogMessageWithContext( aCx.mFile, aLineNo, - "Trying to re-register CID '%s' already registered by %s.", idstr, + "Trying to re-register CID '%s' already registered by %s.", + AutoIDString(cid).get(), existing.get()); return; } @@ -729,7 +862,9 @@ void nsComponentManagerImpl::ManifestContract(ManifestProcessingContext& aCx, return; } - mContractIDs.Put(nsDependentCString(contract), f); + nsDependentCString contractString(contract); + StaticComponents::InvalidateContractID(nsDependentCString(contractString)); + mContractIDs.Put(contractString, f); } void nsComponentManagerImpl::ManifestCategory(ManifestProcessingContext& aCx, @@ -815,6 +950,8 @@ nsresult nsComponentManagerImpl::Shutdown(void) { mKnownModules.Clear(); mKnownStaticModules.Clear(); + StaticComponents::Shutdown(); + delete sExtraStaticModules; delete sModuleLocations; @@ -851,20 +988,46 @@ nsresult nsComponentManagerImpl::GetInterface(const nsIID& aUuid, return QueryInterface(aUuid, aResult); } -nsFactoryEntry* nsComponentManagerImpl::GetFactoryEntry( - const char* aContractID, uint32_t aContractIDLen) { - SafeMutexAutoLock lock(mLock); - return mContractIDs.Get(nsDependentCString(aContractID, aContractIDLen)); +Maybe nsComponentManagerImpl::LookupByCID(const nsID& aCID) { + return LookupByCID(MutexLock(mLock), aCID); } -nsFactoryEntry* nsComponentManagerImpl::GetFactoryEntry(const nsCID& aClass) { - SafeMutexAutoLock lock(mLock); - return mFactories.Get(&aClass); +Maybe nsComponentManagerImpl::LookupByCID(const MutexLock&, + const nsID& aCID) { + if (const StaticModule* module = StaticComponents::LookupByCID(aCID)) { + return Some(EntryWrapper(module)); + } + if (nsFactoryEntry* entry = mFactories.Get(&aCID)) { + return Some(EntryWrapper(entry)); + } + return Nothing(); +} + +Maybe nsComponentManagerImpl::LookupByContractID( + const nsACString& aContractID) { + return LookupByContractID(MutexLock(mLock), aContractID); +} + +Maybe nsComponentManagerImpl::LookupByContractID( + const MutexLock&, const nsACString& aContractID) { + if (const StaticModule* module = + StaticComponents::LookupByContractID(aContractID)) { + return Some(EntryWrapper(module)); + } + if (nsFactoryEntry* entry = mContractIDs.Get(aContractID)) { + // UnregisterFactory might have left a stale nsFactoryEntry in + // mContractIDs, so we should check to see whether this entry has + // anything useful. + if (entry->mModule || entry->mFactory || entry->mServiceObject) { + return Some(EntryWrapper(entry)); + } + } + return Nothing(); } already_AddRefed nsComponentManagerImpl::FindFactory( const nsCID& aClass) { - nsFactoryEntry* e = GetFactoryEntry(aClass); + Maybe e = LookupByCID(aClass); if (!e) { return nullptr; } @@ -874,7 +1037,8 @@ already_AddRefed nsComponentManagerImpl::FindFactory( already_AddRefed nsComponentManagerImpl::FindFactory( const char* aContractID, uint32_t aContractIDLen) { - nsFactoryEntry* entry = GetFactoryEntry(aContractID, aContractIDLen); + Maybe entry = + LookupByContractID(nsDependentCString(aContractID, aContractIDLen)); if (!entry) { return nullptr; } @@ -961,13 +1125,11 @@ nsComponentManagerImpl::CreateInstance(const nsCID& aClass, if (gXPCOMShuttingDown) { // When processing shutdown, don't process new GetService() requests #ifdef SHOW_DENIED_ON_SHUTDOWN - char cid[NSID_LENGTH], iid[NSID_LENGTH]; - aClass.ToProvidedString(cid); - aIID.ToProvidedString(iid); fprintf(stderr, "Creating new instance on shutdown. Denied.\n" " CID: %s\n IID: %s\n", - cid, iid); + AutoIDString(aClass).get(), + AutoIDString(aIID).get()); #endif /* SHOW_DENIED_ON_SHUTDOWN */ return NS_ERROR_UNEXPECTED; } @@ -977,20 +1139,18 @@ nsComponentManagerImpl::CreateInstance(const nsCID& aClass, } *aResult = nullptr; - nsFactoryEntry* entry = GetFactoryEntry(aClass); + Maybe entry = LookupByCID(aClass); if (!entry) { return NS_ERROR_FACTORY_NOT_REGISTERED; } #ifdef SHOW_CI_ON_EXISTING_SERVICE - if (entry->mServiceObject) { - char cid[NSID_LENGTH]; - aClass.ToProvidedString(cid); + if (entry->ServiceInstance()) { nsAutoCString message; message = NS_LITERAL_CSTRING("You are calling CreateInstance \"") + - nsDependentCString(cid) + + AutoIDString(aClass) + NS_LITERAL_CSTRING("\" when a service for this CID already exists!"); NS_ERROR(message.get()); } @@ -1047,12 +1207,10 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char* aContractID, if (gXPCOMShuttingDown) { // When processing shutdown, don't process new GetService() requests #ifdef SHOW_DENIED_ON_SHUTDOWN - char iid[NSID_LENGTH]; - aIID.ToProvidedString(iid); fprintf(stderr, "Creating new instance on shutdown. Denied.\n" " ContractID: %s\n IID: %s\n", - aContractID, iid); + aContractID, AutoIDString(aIID).get()); #endif /* SHOW_DENIED_ON_SHUTDOWN */ return NS_ERROR_UNEXPECTED; } @@ -1062,14 +1220,15 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char* aContractID, } *aResult = nullptr; - nsFactoryEntry* entry = GetFactoryEntry(aContractID, strlen(aContractID)); + Maybe entry = + LookupByContractID(nsDependentCString(aContractID)); if (!entry) { return NS_ERROR_FACTORY_NOT_REGISTERED; } #ifdef SHOW_CI_ON_EXISTING_SERVICE - if (entry->mServiceObject) { + if (entry->ServiceInstance()) { nsAutoCString message; message = NS_LITERAL_CSTRING("You are calling CreateInstance \"") + @@ -1115,6 +1274,10 @@ nsresult nsComponentManagerImpl::FreeServices() { entry->mServiceObject = nullptr; } + for (const auto& module : gStaticModules) { + module.SetServiceInstance(nullptr); + } + return NS_OK; } @@ -1155,39 +1318,13 @@ PRThread* nsComponentManagerImpl::GetPendingServiceThread( return nullptr; } -NS_IMETHODIMP -nsComponentManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, - void** aResult) { - // test this first, since there's no point in returning a service during - // shutdown -- whether it's available or not would depend on the order it - // occurs in the list - if (gXPCOMShuttingDown) { - // When processing shutdown, don't process new GetService() requests -#ifdef SHOW_DENIED_ON_SHUTDOWN - char cid[NSID_LENGTH], iid[NSID_LENGTH]; - aClass.ToProvidedString(cid); - aIID.ToProvidedString(iid); - fprintf(stderr, - "Getting service on shutdown. Denied.\n" - " CID: %s\n IID: %s\n", - cid, iid); -#endif /* SHOW_DENIED_ON_SHUTDOWN */ - return NS_ERROR_UNEXPECTED; - } - - // `service` must be released after the lock is released, so it must be - // declared before the lock in this C++ block. - nsCOMPtr service; - MutexLock lock(mLock); - - nsFactoryEntry* entry = mFactories.Get(&aClass); - if (!entry) { - return NS_ERROR_FACTORY_NOT_REGISTERED; - } - - if (entry->mServiceObject) { - lock.Unlock(); - return entry->mServiceObject->QueryInterface(aIID, aResult); +nsresult nsComponentManagerImpl::GetServiceLocked(MutexLock& aLock, + EntryWrapper& aEntry, + const nsIID& aIID, + void** aResult) { + if (auto* service = aEntry.ServiceInstance()) { + aLock.Unlock(); + return service->QueryInterface(aIID, aResult); } PRThread* currentPRThread = PR_GetCurrentThread(); @@ -1197,207 +1334,7 @@ nsComponentManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, nsIThread* currentThread = nullptr; PRThread* pendingPRThread; - while ((pendingPRThread = GetPendingServiceThread(aClass))) { - if (pendingPRThread == currentPRThread) { - NS_ERROR("Recursive GetService!"); - return NS_ERROR_NOT_AVAILABLE; - } - - SafeMutexAutoUnlock unlockPending(mLock); - - if (!currentThread) { - currentThread = NS_GetCurrentThread(); - MOZ_ASSERT(currentThread, "This should never be null!"); - } - - // This will process a single event or yield the thread if no event is - // pending. - if (!NS_ProcessNextEvent(currentThread, false)) { - PR_Sleep(PR_INTERVAL_NO_WAIT); - } - } - - // It's still possible that the other thread failed to create the - // service so we're not guaranteed to have an entry or service yet. - if (entry->mServiceObject) { - lock.Unlock(); - return entry->mServiceObject->QueryInterface(aIID, aResult); - } - -#ifdef DEBUG - PendingServiceInfo* newInfo = -#endif - AddPendingService(aClass, currentPRThread); - NS_ASSERTION(newInfo, "Failed to add info to the array!"); - - // We need to not be holding the service manager's lock while calling - // CreateInstance, because it invokes user code which could try to re-enter - // the service manager: - - nsresult rv; - { - SafeMutexAutoUnlock unlock(mLock); - rv = CreateInstance(aClass, nullptr, aIID, getter_AddRefs(service)); - } - if (NS_SUCCEEDED(rv) && !service) { - NS_ERROR("Factory did not return an object but returned success"); - return NS_ERROR_SERVICE_NOT_AVAILABLE; - } - -#ifdef DEBUG - pendingPRThread = GetPendingServiceThread(aClass); - MOZ_ASSERT(pendingPRThread == currentPRThread, - "Pending service array has been changed!"); -#endif - RemovePendingService(aClass); - - if (NS_FAILED(rv)) { - return rv; - } - - NS_ASSERTION(!entry->mServiceObject, "Created two instances of a service!"); - - entry->mServiceObject = service.forget(); - - lock.Unlock(); - nsISupports** sresult = reinterpret_cast(aResult); - *sresult = entry->mServiceObject; - (*sresult)->AddRef(); - - return NS_OK; -} - -NS_IMETHODIMP -nsComponentManagerImpl::IsServiceInstantiated(const nsCID& aClass, - const nsIID& aIID, - bool* aResult) { - // Now we want to get the service if we already got it. If not, we don't want - // to create an instance of it. mmh! - - // test this first, since there's no point in returning a service during - // shutdown -- whether it's available or not would depend on the order it - // occurs in the list - if (gXPCOMShuttingDown) { - // When processing shutdown, don't process new GetService() requests -#ifdef SHOW_DENIED_ON_SHUTDOWN - char cid[NSID_LENGTH], iid[NSID_LENGTH]; - aClass.ToProvidedString(cid); - aIID.ToProvidedString(iid); - fprintf(stderr, - "Checking for service on shutdown. Denied.\n" - " CID: %s\n IID: %s\n", - cid, iid); -#endif /* SHOW_DENIED_ON_SHUTDOWN */ - return NS_ERROR_UNEXPECTED; - } - - nsresult rv = NS_OK; - nsFactoryEntry* entry; - - { - SafeMutexAutoLock lock(mLock); - entry = mFactories.Get(&aClass); - } - - if (entry && entry->mServiceObject) { - nsCOMPtr service; - rv = entry->mServiceObject->QueryInterface(aIID, getter_AddRefs(service)); - *aResult = (service != nullptr); - } else { - *aResult = false; - } - - return rv; -} - -NS_IMETHODIMP -nsComponentManagerImpl::IsServiceInstantiatedByContractID( - const char* aContractID, const nsIID& aIID, bool* aResult) { - // Now we want to get the service if we already got it. If not, we don't want - // to create an instance of it. mmh! - - // test this first, since there's no point in returning a service during - // shutdown -- whether it's available or not would depend on the order it - // occurs in the list - if (gXPCOMShuttingDown) { - // When processing shutdown, don't process new GetService() requests -#ifdef SHOW_DENIED_ON_SHUTDOWN - char iid[NSID_LENGTH]; - aIID.ToProvidedString(iid); - fprintf(stderr, - "Checking for service on shutdown. Denied.\n" - " ContractID: %s\n IID: %s\n", - aContractID, iid); -#endif /* SHOW_DENIED_ON_SHUTDOWN */ - return NS_ERROR_UNEXPECTED; - } - - nsresult rv = NS_OK; - nsFactoryEntry* entry; - { - SafeMutexAutoLock lock(mLock); - entry = mContractIDs.Get(nsDependentCString(aContractID)); - } - - if (entry && entry->mServiceObject) { - nsCOMPtr service; - rv = entry->mServiceObject->QueryInterface(aIID, getter_AddRefs(service)); - *aResult = (service != nullptr); - } else { - *aResult = false; - } - return rv; -} - -NS_IMETHODIMP -nsComponentManagerImpl::GetServiceByContractID(const char* aContractID, - const nsIID& aIID, - void** aResult) { - // test this first, since there's no point in returning a service during - // shutdown -- whether it's available or not would depend on the order it - // occurs in the list - if (gXPCOMShuttingDown) { - // When processing shutdown, don't process new GetService() requests -#ifdef SHOW_DENIED_ON_SHUTDOWN - char iid[NSID_LENGTH]; - aIID.ToProvidedString(iid); - fprintf(stderr, - "Getting service on shutdown. Denied.\n" - " ContractID: %s\n IID: %s\n", - aContractID, iid); -#endif /* SHOW_DENIED_ON_SHUTDOWN */ - return NS_ERROR_UNEXPECTED; - } - - // `service` must be released after the lock is released, so it must be - // declared before the lock in this C++ block. - nsCOMPtr service; - MutexLock lock(mLock); - - nsFactoryEntry* entry = mContractIDs.Get(nsDependentCString(aContractID)); - if (!entry) { - return NS_ERROR_FACTORY_NOT_REGISTERED; - } - - if (entry->mServiceObject) { - // We need to not be holding the service manager's monitor while calling - // QueryInterface, because it invokes user code which could try to re-enter - // the service manager, or try to grab some other lock/monitor/condvar - // and deadlock, e.g. bug 282743. - // `entry` is valid until XPCOM shutdown, so we can safely use it after - // exiting the lock. - lock.Unlock(); - return entry->mServiceObject->QueryInterface(aIID, aResult); - } - - PRThread* currentPRThread = PR_GetCurrentThread(); - MOZ_ASSERT(currentPRThread, "This should never be null!"); - - // Needed to optimize the event loop below. - nsIThread* currentThread = nullptr; - - PRThread* pendingPRThread; - while ((pendingPRThread = GetPendingServiceThread(*entry->mCIDEntry->cid))) { + while ((pendingPRThread = GetPendingServiceThread(aEntry.CID()))) { if (pendingPRThread == currentPRThread) { NS_ERROR("Recursive GetService!"); return NS_ERROR_NOT_AVAILABLE; @@ -1425,28 +1362,35 @@ nsComponentManagerImpl::GetServiceByContractID(const char* aContractID, } } - if (currentThread && entry->mServiceObject) { - // If we have a currentThread then we must have waited on another thread - // to create the service. Grab it now if that succeeded. - lock.Unlock(); - return entry->mServiceObject->QueryInterface(aIID, aResult); + // It's still possible that the other thread failed to create the + // service so we're not guaranteed to have an entry or service yet. + if (auto* service = aEntry.ServiceInstance()) { + aLock.Unlock(); + return service->QueryInterface(aIID, aResult); } -#ifdef DEBUG - PendingServiceInfo* newInfo = -#endif - AddPendingService(*entry->mCIDEntry->cid, currentPRThread); + DebugOnly newInfo = + AddPendingService(aEntry.CID(), currentPRThread); NS_ASSERTION(newInfo, "Failed to add info to the array!"); // We need to not be holding the service manager's lock while calling // CreateInstance, because it invokes user code which could try to re-enter // the service manager: + nsCOMPtr service; + auto cleanup = MakeScopeExit([&]() { + // `service` must be released after the lock is released, so if we fail and + // still have a reference, release the lock before relasing it. + if (service) { + aLock.Unlock(); + service = nullptr; + } + }); + nsresult rv; { SafeMutexAutoUnlock unlock(mLock); - rv = CreateInstanceByContractID(aContractID, nullptr, aIID, - getter_AddRefs(service)); + rv = aEntry.CreateInstance(nullptr, aIID, getter_AddRefs(service)); } if (NS_SUCCEEDED(rv) && !service) { NS_ERROR("Factory did not return an object but returned success"); @@ -1454,29 +1398,194 @@ nsComponentManagerImpl::GetServiceByContractID(const char* aContractID, } #ifdef DEBUG - pendingPRThread = GetPendingServiceThread(*entry->mCIDEntry->cid); + pendingPRThread = GetPendingServiceThread(aEntry.CID()); MOZ_ASSERT(pendingPRThread == currentPRThread, "Pending service array has been changed!"); #endif - RemovePendingService(*entry->mCIDEntry->cid); + RemovePendingService(aEntry.CID()); if (NS_FAILED(rv)) { return rv; } - NS_ASSERTION(!entry->mServiceObject, "Created two instances of a service!"); + NS_ASSERTION(!aEntry.ServiceInstance(), + "Created two instances of a service!"); - entry->mServiceObject = service.forget(); - - lock.Unlock(); - - nsISupports** sresult = reinterpret_cast(aResult); - *sresult = entry->mServiceObject; - (*sresult)->AddRef(); + aEntry.SetServiceInstance(service.forget()); + aLock.Unlock(); + *aResult = do_AddRef(aEntry.ServiceInstance()).take(); return NS_OK; } +NS_IMETHODIMP +nsComponentManagerImpl::GetService(const nsCID& aClass, const nsIID& aIID, + void** aResult) { + // test this first, since there's no point in returning a service during + // shutdown -- whether it's available or not would depend on the order it + // occurs in the list + if (gXPCOMShuttingDown) { + // When processing shutdown, don't process new GetService() requests +#ifdef SHOW_DENIED_ON_SHUTDOWN + fprintf(stderr, + "Getting service on shutdown. Denied.\n" + " CID: %s\n IID: %s\n", + AutoIDString(aClass).get(), + AutoIDString(aIID).get()); +#endif /* SHOW_DENIED_ON_SHUTDOWN */ + return NS_ERROR_UNEXPECTED; + } + + MutexLock lock(mLock); + + Maybe entry = LookupByCID(lock, aClass); + if (!entry) { + return NS_ERROR_FACTORY_NOT_REGISTERED; + } + + return GetServiceLocked(lock, *entry, aIID, aResult); +} + +nsresult +nsComponentManagerImpl::GetService(ModuleID aId, const nsIID& aIID, + void** aResult) { + const auto& entry = gStaticModules[size_t(aId)]; + + // test this first, since there's no point in returning a service during + // shutdown -- whether it's available or not would depend on the order it + // occurs in the list + if (gXPCOMShuttingDown) { + // When processing shutdown, don't process new GetService() requests +#ifdef SHOW_DENIED_ON_SHUTDOWN + fprintf(stderr, + "Getting service on shutdown. Denied.\n" + " CID: %s\n IID: %s\n", + AutoIDString(entry.CID()).get(), + AutoIDString(aIID).get()); +#endif /* SHOW_DENIED_ON_SHUTDOWN */ + return NS_ERROR_UNEXPECTED; + } + + MutexLock lock(mLock); + + if (!entry.Active()) { + return NS_ERROR_FACTORY_NOT_REGISTERED; + } + + Maybe wrapper; + if (entry.Overridable()) { + // If we expect this service to be overridden by test code, we need to look + // it up by contract ID every time. + wrapper = LookupByContractID(lock, entry.ContractID()); + if (!wrapper) { + return NS_ERROR_FACTORY_NOT_REGISTERED; + } + } else { + wrapper.emplace(&entry); + } + return GetServiceLocked(lock, *wrapper, aIID, aResult); +} + +NS_IMETHODIMP +nsComponentManagerImpl::IsServiceInstantiated(const nsCID& aClass, + const nsIID& aIID, + bool* aResult) { + // Now we want to get the service if we already got it. If not, we don't want + // to create an instance of it. mmh! + + // test this first, since there's no point in returning a service during + // shutdown -- whether it's available or not would depend on the order it + // occurs in the list + if (gXPCOMShuttingDown) { + // When processing shutdown, don't process new GetService() requests +#ifdef SHOW_DENIED_ON_SHUTDOWN + fprintf(stderr, + "Checking for service on shutdown. Denied.\n" + " CID: %s\n IID: %s\n", + AutoIDString(aClass).get(), + AutoIDString(aIID).get()); +#endif /* SHOW_DENIED_ON_SHUTDOWN */ + return NS_ERROR_UNEXPECTED; + } + + if (Maybe entry = LookupByCID(aClass)) { + if (auto* service = entry->ServiceInstance()) { + nsCOMPtr instance; + nsresult rv = service->QueryInterface( + aIID, getter_AddRefs(instance)); + *aResult = (instance != nullptr); + return rv; + } + } + + *aResult = false; + return NS_OK; +} + +NS_IMETHODIMP +nsComponentManagerImpl::IsServiceInstantiatedByContractID( + const char* aContractID, const nsIID& aIID, bool* aResult) { + // Now we want to get the service if we already got it. If not, we don't want + // to create an instance of it. mmh! + + // test this first, since there's no point in returning a service during + // shutdown -- whether it's available or not would depend on the order it + // occurs in the list + if (gXPCOMShuttingDown) { + // When processing shutdown, don't process new GetService() requests +#ifdef SHOW_DENIED_ON_SHUTDOWN + fprintf(stderr, + "Checking for service on shutdown. Denied.\n" + " ContractID: %s\n IID: %s\n", + aContractID, AutoIDString(aIID).get()); +#endif /* SHOW_DENIED_ON_SHUTDOWN */ + return NS_ERROR_UNEXPECTED; + } + + if (Maybe entry = + LookupByContractID(nsDependentCString(aContractID))) { + if (auto* service = entry->ServiceInstance()) { + nsCOMPtr instance; + nsresult rv = service->QueryInterface( + aIID, getter_AddRefs(instance)); + *aResult = (instance != nullptr); + return rv; + } + } + + *aResult = false; + return NS_OK; +} + +NS_IMETHODIMP +nsComponentManagerImpl::GetServiceByContractID(const char* aContractID, + const nsIID& aIID, + void** aResult) { + // test this first, since there's no point in returning a service during + // shutdown -- whether it's available or not would depend on the order it + // occurs in the list + if (gXPCOMShuttingDown) { + // When processing shutdown, don't process new GetService() requests +#ifdef SHOW_DENIED_ON_SHUTDOWN + fprintf(stderr, + "Getting service on shutdown. Denied.\n" + " ContractID: %s\n IID: %s\n", + aContractID, AutoIDString(aIID).get()); +#endif /* SHOW_DENIED_ON_SHUTDOWN */ + return NS_ERROR_UNEXPECTED; + } + + MutexLock lock(mLock); + + Maybe entry = + LookupByContractID(lock, nsDependentCString(aContractID)); + if (!entry) { + return NS_ERROR_FACTORY_NOT_REGISTERED; + } + + return GetServiceLocked(lock, *entry, aIID, aResult); +} + NS_IMETHODIMP nsComponentManagerImpl::RegisterFactory(const nsCID& aClass, const char* aName, const char* aContractID, @@ -1490,12 +1599,22 @@ nsComponentManagerImpl::RegisterFactory(const nsCID& aClass, const char* aName, SafeMutexAutoLock lock(mLock); nsFactoryEntry* oldf = mFactories.Get(&aClass); - if (!oldf) { - return NS_ERROR_FACTORY_NOT_REGISTERED; + if (oldf) { + mContractIDs.Put(nsDependentCString(aContractID), oldf); + return NS_OK; } - mContractIDs.Put(nsDependentCString(aContractID), oldf); - return NS_OK; + if (StaticComponents::LookupByCID(aClass)) { + // If this is the CID of a static module, just reset the invalid bit of + // the static entry for this contract ID, and assume it points to the + // correct class. + nsDependentCString contractID(aContractID); + if (StaticComponents::InvalidateContractID(contractID, false)) { + mContractIDs.Remove(contractID); + return NS_OK; + } + } + return NS_ERROR_FACTORY_NOT_REGISTERED; } nsAutoPtr f(new nsFactoryEntry(aClass, aFactory)); @@ -1504,8 +1623,16 @@ nsComponentManagerImpl::RegisterFactory(const nsCID& aClass, const char* aName, if (auto entry = mFactories.LookupForAdd(f->mCIDEntry->cid)) { return NS_ERROR_FACTORY_EXISTS; } else { + if (StaticComponents::LookupByCID(*f->mCIDEntry->cid)) { + entry.OrRemove(); + return NS_ERROR_FACTORY_EXISTS; + } if (aContractID) { - mContractIDs.Put(nsDependentCString(aContractID), f); + nsDependentCString contractID(aContractID); + mContractIDs.Put(contractID, f); + // We allow dynamically-registered contract IDs to override static + // entries, so invalidate any static entry for this contract ID. + StaticComponents::InvalidateContractID(contractID); } entry.OrInsert([&f]() { return f.forget(); }); } @@ -1526,6 +1653,7 @@ nsComponentManagerImpl::UnregisterFactory(const nsCID& aClass, auto entry = mFactories.Lookup(&aClass); nsFactoryEntry* f = entry ? entry.Data() : nullptr; if (!f || f->mFactory != aFactory) { + // Note: We do not support unregistering static factories. return NS_ERROR_FACTORY_NOT_REGISTERED; } @@ -1570,7 +1698,7 @@ nsComponentManagerImpl::UnregisterFactoryLocation(const nsCID& aCID, NS_IMETHODIMP nsComponentManagerImpl::IsCIDRegistered(const nsCID& aClass, bool* aResult) { - *aResult = (nullptr != GetFactoryEntry(aClass)); + *aResult = LookupByCID(aClass).isSome(); return NS_OK; } @@ -1581,29 +1709,30 @@ nsComponentManagerImpl::IsContractIDRegistered(const char* aClass, return NS_ERROR_INVALID_ARG; } - nsFactoryEntry* entry = GetFactoryEntry(aClass, strlen(aClass)); + Maybe entry = LookupByContractID(nsDependentCString(aClass)); - if (entry) { - // UnregisterFactory might have left a stale nsFactoryEntry in - // mContractIDs, so we should check to see whether this entry has - // anything useful. - *aResult = (bool(entry->mModule) || bool(entry->mFactory) || - bool(entry->mServiceObject)); - } else { - *aResult = false; - } + *aResult = entry.isSome(); return NS_OK; } NS_IMETHODIMP nsComponentManagerImpl::EnumerateCIDs(nsISimpleEnumerator** aEnumerator) { nsCOMArray array; - for (auto iter = mFactories.Iter(); !iter.Done(); iter.Next()) { - const nsID* id = iter.Key(); + auto appendEntry = [&](const nsID& aCID) { nsCOMPtr wrapper = new nsSupportsID(); - wrapper->SetData(id); + wrapper->SetData(&aCID); array.AppendObject(wrapper); + }; + + for (auto iter = mFactories.Iter(); !iter.Done(); iter.Next()) { + appendEntry(*iter.Key()); } + for (const auto& module : gStaticModules) { + if (module.Active()) { + appendEntry(module.CID()); + } + } + return NS_NewArrayEnumerator(aEnumerator, array); } @@ -1616,6 +1745,12 @@ nsComponentManagerImpl::EnumerateContractIDs( array->AppendElement(contract); } + for (const auto& entry : gContractEntries) { + if (!entry.Invalid()) { + array->AppendElement(entry.ContractID()); + } + } + nsCOMPtr e; nsresult rv = NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(e), array); if (NS_FAILED(rv)) { @@ -1635,11 +1770,12 @@ NS_IMETHODIMP nsComponentManagerImpl::ContractIDToCID(const char* aContractID, nsCID** aResult) { { - SafeMutexAutoLock lock(mLock); - nsFactoryEntry* entry = mContractIDs.Get(nsDependentCString(aContractID)); + MutexLock lock(mLock); + Maybe entry = + LookupByContractID(lock, nsDependentCString(aContractID)); if (entry) { *aResult = (nsCID*)moz_xmalloc(sizeof(nsCID)); - **aResult = *entry->mCIDEntry->cid; + **aResult = entry->CID(); return NS_OK; } } @@ -1762,6 +1898,13 @@ already_AddRefed nsFactoryEntry::GetFactory() { return factory.forget(); } +nsresult nsFactoryEntry::CreateInstance(nsISupports* aOuter, const nsIID& aIID, + void** aResult) { + nsCOMPtr factory = GetFactory(); + NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE); + return factory->CreateInstance(aOuter, aIID, aResult); +} + size_t nsFactoryEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index b5f695bb0196..5e02a3c078ae 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -35,6 +35,8 @@ #include "nsClassHashtable.h" #include "nsTArray.h" +#include "mozilla/Components.h" +#include "mozilla/Maybe.h" #include "mozilla/Omnijar.h" #include "mozilla/Attributes.h" @@ -52,6 +54,20 @@ struct PRThread; extern const mozilla::Module kXPCOMModule; +namespace { +class EntryWrapper; +class MutexLock; +} // namespace + +namespace mozilla { +namespace xpcom { + +bool ProcessSelectorMatches(Module::ProcessSelector aSelector); +bool FastProcessSelectorMatches(Module::ProcessSelector aSelector); + +} // namespace xpcom +} // namespace mozilla + /** * This is a wrapper around mozilla::Mutex which provides runtime * checking for a deadlock where the same thread tries to lock a mutex while @@ -134,15 +150,21 @@ class nsComponentManagerImpl final : public nsIComponentManager, already_AddRefed LoadFactory(nsFactoryEntry* aEntry); - nsFactoryEntry* GetFactoryEntry(const char* aContractID, - uint32_t aContractIDLen); - nsFactoryEntry* GetFactoryEntry(const nsCID& aClass); - nsDataHashtable mFactories; nsDataHashtable mContractIDs; SafeMutex mLock; + mozilla::Maybe LookupByCID(const nsID& aCID); + mozilla::Maybe LookupByCID(const MutexLock&, const nsID& aCID); + + mozilla::Maybe LookupByContractID( + const nsACString& aContractID); + mozilla::Maybe LookupByContractID( + const MutexLock&, const nsACString& aContractID); + + nsresult GetService(mozilla::xpcom::ModuleID, const nsIID& aIID, void** aResult); + static void InitializeStaticModules(); static void InitializeModuleLocations(); @@ -262,6 +284,9 @@ class nsComponentManagerImpl final : public nsIComponentManager, private: ~nsComponentManagerImpl(); + + nsresult GetServiceLocked(MutexLock& aLock, EntryWrapper& aEntry, + const nsIID& aIID, void** aResult); }; #define NS_MAX_FILENAME_LEN 1024 @@ -279,6 +304,9 @@ struct nsFactoryEntry { already_AddRefed GetFactory(); + nsresult CreateInstance(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); const mozilla::Module::CIDEntry* mCIDEntry; diff --git a/xpcom/ds/components.conf b/xpcom/ds/components.conf new file mode 100644 index 000000000000..efc3197e77ea --- /dev/null +++ b/xpcom/ds/components.conf @@ -0,0 +1,21 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{35c66fd1-95e9-4e0a-80c5-c3bd2b375481}', + 'contract_ids': ['@mozilla.org/array;1'], + 'legacy_constructor': 'nsArrayBase::XPCOMConstructor', + 'headers': ['nsArray.h'], + }, + { + 'cid': '{d07f5195-e3d1-11d2-8acd-00105a1b8860}', + 'contract_ids': ['@mozilla.org/observer-service;1'], + 'legacy_constructor': 'nsObserverService::Create', + 'headers': ['/xpcom/ds/nsObserverService.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS, + }, +] diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index 01d25d317507..504569d200d9 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -38,6 +38,10 @@ if CONFIG['OS_ARCH'] == 'WINNT': XPIDL_MODULE = 'xpcom_ds' +XPCOM_MANIFESTS += [ + 'components.conf', +] + EXPORTS += [ '!nsGkAtomConsts.h', '!nsGkAtomList.h', diff --git a/xpcom/io/components.conf b/xpcom/io/components.conf new file mode 100644 index 000000000000..748d057ef94e --- /dev/null +++ b/xpcom/io/components.conf @@ -0,0 +1,38 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{f00152d0-b40b-11d3-8c9c-000064657374}', + 'contract_ids': ['@mozilla.org/file/directory_service;1'], + 'legacy_constructor': 'nsDirectoryService::Create', + 'headers': ['nsDirectoryService.h'], + }, + { + 'cid': '{565e3a2c-1dd2-11b2-8da1-b4cef17e568d}', + 'contract_ids': ['@mozilla.org/io/multiplex-input-stream;1'], + 'legacy_constructor': 'nsMultiplexInputStreamConstructor', + 'headers': ['nsMultiplexInputStream.h'], + }, + { + 'cid': '{e4a0ee4e-0775-457b-9118-b3ae97a7c758}', + 'contract_ids': ['@mozilla.org/pipe;1'], + 'legacy_constructor': 'nsPipeConstructor', + 'headers': ['/xpcom/io/nsPipe.h'], + }, + { + 'cid': '{7225c040-a9bf-11d3-a197-0050041caf44}', + 'contract_ids': ['@mozilla.org/scriptableinputstream;1'], + 'legacy_constructor': 'nsScriptableInputStream::Create', + 'headers': ['nsScriptableInputStream.h'], + }, + { + 'cid': '{0abb0835-5000-4790-af28-61b3ba17c295}', + 'contract_ids': ['@mozilla.org/io/string-input-stream;1'], + 'legacy_constructor': 'nsStringInputStreamConstructor', + 'headers': ['/xpcom/build/XPCOMModule.h'], + }, +] diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build index ca5c2b2582a5..8ecd7e08f4ea 100644 --- a/xpcom/io/moz.build +++ b/xpcom/io/moz.build @@ -61,6 +61,10 @@ else: XPIDL_MODULE = 'xpcom_io' +XPCOM_MANIFESTS += [ + 'components.conf', +] + EXPORTS += [ 'FileDescriptorFile.h', 'nsAnonymousTemporaryFile.h', diff --git a/xpcom/threads/components.conf b/xpcom/threads/components.conf new file mode 100644 index 000000000000..cdfaafe8007d --- /dev/null +++ b/xpcom/threads/components.conf @@ -0,0 +1,21 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +Classes = [ + { + 'cid': '{03d68f92-9513-4e25-9be9-7cb239874172}', + 'contract_ids': ['@mozilla.org/process/environment;1'], + 'legacy_constructor': 'nsEnvironment::Create', + 'headers': ['/xpcom/threads/nsEnvironment.h'], + }, + { + 'cid': '{5ff24248-1dd2-11b2-8427-fbab44f29bc8}', + 'contract_ids': ['@mozilla.org/timer;1'], + 'legacy_constructor': 'nsTimer::XPCOMConstructor', + 'headers': ['/xpcom/threads/nsTimerImpl.h'], + 'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS, + }, +] diff --git a/xpcom/threads/moz.build b/xpcom/threads/moz.build index ea8815d28bb1..fef859606b09 100644 --- a/xpcom/threads/moz.build +++ b/xpcom/threads/moz.build @@ -22,6 +22,10 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'xpcom_threads' +XPCOM_MANIFESTS += [ + 'components.conf', +] + EXPORTS += [ 'MainThreadUtils.h', 'nsICancelableRunnable.h', diff --git a/xpfe/appshell/nsContentTreeOwner.cpp b/xpfe/appshell/nsContentTreeOwner.cpp index cf1907cf0477..d2c8f21715a4 100644 --- a/xpfe/appshell/nsContentTreeOwner.cpp +++ b/xpfe/appshell/nsContentTreeOwner.cpp @@ -24,7 +24,6 @@ #include "nsIXULBrowserWindow.h" #include "nsIPrincipal.h" #include "nsIURIFixup.h" -#include "nsCDefaultURIFixup.h" #include "nsIWebNavigation.h" #include "nsDocShellCID.h" #include "nsIExternalURLHandlerService.h" @@ -32,6 +31,7 @@ #include "nsIWidget.h" #include "nsWindowWatcher.h" #include "mozilla/BrowserElementParent.h" +#include "mozilla/Components.h" #include "mozilla/NullPrincipal.h" #include "nsDocShell.h" #include "nsDocShellLoadState.h" @@ -660,7 +660,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle) { // // remove any user:pass information // - nsCOMPtr fixup(do_GetService(NS_URIFIXUP_CONTRACTID)); + nsCOMPtr fixup(components::URIFixup::Service()); if (fixup) { nsCOMPtr tmpuri; nsresult rv =