author | Lynn Tran <lynn_tran@outlook.com> |
Mon, 18 Aug 2014 21:13:14 -0400 | |
changeset 200233 | 33fcf51e6d13321ea7667fe2bbac4cf564acf3fb |
parent 200232 | 8f48ab6499cfa2f071d8bb3c550884e94dbc7803 |
child 200234 | 3998dcd6b14766d51f3364f5edfe742703ecf8a7 |
push id | 27337 |
push user | emorley@mozilla.com |
push date | Tue, 19 Aug 2014 12:40:34 +0000 |
treeherder | mozilla-central@a38daccaa557 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 1041335 |
milestone | 34.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -34,16 +34,17 @@ #include "nsIObserver.h" #include "nsIBaseWindow.h" #include "mozilla/css/Loader.h" #include "mozilla/css/ImageLoader.h" #include "nsDocShell.h" #include "nsIDocShellTreeItem.h" #include "nsCOMArray.h" #include "nsDOMClassInfo.h" +#include "mozilla/Services.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventListenerManager.h" #include "mozilla/EventStateManager.h" #include "nsIDOMNodeFilter.h" #include "nsIDOMStyleSheet.h" @@ -4489,17 +4490,17 @@ nsDocument::SetScriptGlobalObject(nsIScr channel->GetLoadFlags(&loadFlags); // If we are shift-reloaded, don't associate with a ServiceWorker. // FIXME(nsm): Bug 1041339. if (loadFlags & nsIRequest::LOAD_BYPASS_CACHE) { NS_WARNING("Page was shift reloaded, skipping ServiceWorker control"); return; } - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); if (swm) { swm->MaybeStartControlling(this); mMaybeServiceWorkerControlled = true; } } } nsIScriptGlobalObject* @@ -8521,17 +8522,17 @@ nsDocument::Destroy() // Shut down our external resource map. We might not need this for // leak-fixing if we fix nsDocumentViewer to do cycle-collection, but // tearing down all those frame trees right now is the right thing to do. mExternalResourceMap.Shutdown(); mRegistry = nullptr; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); if (swm) { swm->MaybeStopControlling(this); } // XXX We really should let cycle collection do this, but that currently still // leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684). ReleaseWrapper(static_cast<nsINode*>(this)); }
--- a/dom/workers/ServiceWorkerContainer.cpp +++ b/dom/workers/ServiceWorkerContainer.cpp @@ -4,16 +4,17 @@ * 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 "ServiceWorkerContainer.h" #include "nsIDocument.h" #include "nsIServiceWorkerManager.h" #include "nsPIDOMWindow.h" +#include "mozilla/Services.h" #include "nsCycleCollectionParticipant.h" #include "nsServiceManagerUtils.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/ServiceWorkerContainerBinding.h" #include "mozilla/dom/workers/bindings/ServiceWorker.h" @@ -55,20 +56,19 @@ ServiceWorkerContainer::WrapObject(JSCon already_AddRefed<Promise> ServiceWorkerContainer::Register(const nsAString& aScriptURL, const RegistrationOptionList& aOptions, ErrorResult& aRv) { nsCOMPtr<nsISupports> promise; - nsresult rv; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.Throw(rv); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); + if (!swm) { + aRv.Throw(NS_ERROR_FAILURE); return nullptr; } aRv = swm->Register(mWindow, aOptions.mScope, aScriptURL, getter_AddRefs(promise)); if (aRv.Failed()) { return nullptr; } @@ -78,20 +78,19 @@ ServiceWorkerContainer::Register(const n } already_AddRefed<Promise> ServiceWorkerContainer::Unregister(const nsAString& aScope, ErrorResult& aRv) { nsCOMPtr<nsISupports> promise; - nsresult rv; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.Throw(rv); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); + if (!swm) { + aRv.Throw(NS_ERROR_FAILURE); return nullptr; } aRv = swm->Unregister(mWindow, aScope, getter_AddRefs(promise)); if (aRv.Failed()) { return nullptr; } @@ -133,18 +132,18 @@ ServiceWorkerContainer::GetActive() return ret.forget(); } already_AddRefed<workers::ServiceWorker> ServiceWorkerContainer::GetController() { if (!mControllerWorker) { nsresult rv; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); + if (!swm) { return nullptr; } nsCOMPtr<nsISupports> serviceWorker; rv = swm->GetDocumentController(mWindow, getter_AddRefs(serviceWorker)); if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; } @@ -172,26 +171,26 @@ ServiceWorkerContainer::GetReady(ErrorRe return Promise::Create(global, aRv); } // XXXnsm, maybe this can be optimized to only add when a event handler is // registered. void ServiceWorkerContainer::StartListeningForEvents() { - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); if (swm) { swm->AddContainerEventListener(mWindow->GetDocumentURI(), this); } } void ServiceWorkerContainer::StopListeningForEvents() { - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); if (swm) { swm->RemoveContainerEventListener(mWindow->GetDocumentURI(), this); } } void ServiceWorkerContainer::InvalidateWorkerReference(WhichServiceWorker aWhichOnes) { @@ -207,18 +206,18 @@ ServiceWorkerContainer::InvalidateWorker mActiveWorker = nullptr; } } already_AddRefed<workers::ServiceWorker> ServiceWorkerContainer::GetWorkerReference(WhichServiceWorker aWhichOne) { nsresult rv; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); + if (!swm) { return nullptr; } nsCOMPtr<nsISupports> serviceWorker; switch(aWhichOne) { case WhichServiceWorker::INSTALLING_WORKER: rv = swm->GetInstalling(mWindow, getter_AddRefs(serviceWorker)); break; @@ -249,20 +248,19 @@ ServiceWorkerContainer::ClearAllServiceW } // Testing only. void ServiceWorkerContainer::GetScopeForUrl(const nsAString& aUrl, nsString& aScope, ErrorResult& aRv) { - nsresult rv; - nsCOMPtr<nsIServiceWorkerManager> swm = do_GetService(SERVICEWORKERMANAGER_CONTRACTID, &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - aRv.Throw(rv); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); + if (!swm) { + aRv.Throw(NS_ERROR_FAILURE); return; } aRv = swm->GetScopeForUrl(aUrl, aScope); } // Testing only. void
--- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -602,18 +602,17 @@ ServiceWorkerManager::Unregister(nsIDOMW return NS_ERROR_DOM_NOT_SUPPORTED_ERR; } /* static */ already_AddRefed<ServiceWorkerManager> ServiceWorkerManager::GetInstance() { - nsCOMPtr<nsIServiceWorkerManager> swm = - do_GetService(SERVICEWORKERMANAGER_CONTRACTID); + nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager(); nsRefPtr<ServiceWorkerManager> concrete = do_QueryObject(swm); return concrete.forget(); } void ServiceWorkerManager::ResolveRegisterPromises(ServiceWorkerRegistration* aRegistration, const nsACString& aWorkerScriptSpec) {
--- a/xpcom/build/ServiceList.h +++ b/xpcom/build/ServiceList.h @@ -22,16 +22,18 @@ MOZ_SERVICE(ObserverService, nsIObserver MOZ_SERVICE(StringBundleService, nsIStringBundleService, "@mozilla.org/intl/stringbundle;1") MOZ_SERVICE(XPConnect, nsIXPConnect, "@mozilla.org/js/xpc/XPConnect;1") MOZ_SERVICE(InDOMUtils, inIDOMUtils, "@mozilla.org/inspector/dom-utils;1") MOZ_SERVICE(PermissionManager, nsIPermissionManager, "@mozilla.org/permissionmanager;1"); +MOZ_SERVICE(ServiceWorkerManager, nsIServiceWorkerManager, + "@mozilla.org/serviceworkers/manager;1"); #ifdef MOZ_USE_NAMESPACE namespace mozilla { #endif MOZ_SERVICE(HistoryService, IHistory, "@mozilla.org/browser/history;1")
--- a/xpcom/build/Services.cpp +++ b/xpcom/build/Services.cpp @@ -18,16 +18,17 @@ #include "nsXPCOMPrivate.h" #include "nsIStringBundle.h" #include "nsIToolkitChromeRegistry.h" #include "nsIXULOverlayProvider.h" #include "IHistory.h" #include "nsIXPConnect.h" #include "inIDOMUtils.h" #include "nsIPermissionManager.h" +#include "nsIServiceWorkerManager.h" using namespace mozilla; using namespace mozilla::services; /* * Define a global variable and a getter for every service in ServiceList. * eg. gIOService and GetIOService() */