diff --git a/dom/interfaces/base/nsIServiceWorkerManager.idl b/dom/interfaces/base/nsIServiceWorkerManager.idl index acd45e9d5182..13f747699d25 100644 --- a/dom/interfaces/base/nsIServiceWorkerManager.idl +++ b/dom/interfaces/base/nsIServiceWorkerManager.idl @@ -6,7 +6,6 @@ #include "domstubs.idl" interface nsIDocument; -interface nsIPrincipal; interface nsIURI; [builtinclass, uuid(d4367ffe-e435-4195-95f8-0a51b1bbfdfb)] @@ -18,7 +17,7 @@ interface nsIServiceWorkerUnregisterCallback : nsISupports [noscript] void UnregisterFailed(); }; -[builtinclass, uuid(861b55e9-d6ac-47cf-a528-8590e9b44de6)] +[builtinclass, uuid(430f02bf-63d0-44ab-9a59-7bd49c608949)] interface nsIServiceWorkerManager : nsISupports { /** @@ -35,8 +34,7 @@ interface nsIServiceWorkerManager : nsISupports * Unregister an existing ServiceWorker registration for `aScope`. * It keeps aCallback alive until the operation is concluded. */ - void unregister(in nsIPrincipal aPrincipal, - in nsIServiceWorkerUnregisterCallback aCallback, + void unregister(in nsIServiceWorkerUnregisterCallback aCallback, in DOMString aScope); // Returns a Promise diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index bf57793c1fb7..4721f7db6571 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -19,7 +19,6 @@ include DOMTypes; include JavaScriptTypes; include URIParams; include PContentPermission; -include ServiceWorkerRegistrarTypes; using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; @@ -66,11 +65,6 @@ struct NativeKeyBinding CommandInt[] richTextCommands; }; -struct BrowserConfiguration -{ - ServiceWorkerRegistrationData[] serviceWorkerRegistrations; -}; - union MaybeNativeKeyBinding { NativeKeyBinding; @@ -477,7 +471,7 @@ child: nullable PRenderFrame renderFrame, bool parentIsActive); - LoadURL(nsCString uri, BrowserConfiguration config); + LoadURL(nsCString uri); CacheFileDescriptor(nsString path, FileDescriptor fd); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 1cd1074a82c3..b74ce4bffeb6 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -15,7 +15,6 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/EventListenerManager.h" #include "mozilla/IntentionalCrash.h" -#include "mozilla/dom/workers/ServiceWorkerManager.h" #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h" #include "mozilla/plugins/PluginWidgetChild.h" #include "mozilla/ipc/DocumentRendererChild.h" @@ -100,7 +99,6 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::ipc; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; using namespace mozilla::layers; using namespace mozilla::layout; @@ -1568,7 +1566,7 @@ TabChild::ProvideWindowCommon(nsIDOMWindow* aOpener, } if (!urlToLoad.IsEmpty()) { - newChild->RecvLoadURL(urlToLoad, BrowserConfiguration()); + newChild->RecvLoadURL(urlToLoad); } nsCOMPtr win = do_GetInterface(newChild->WebNavigation()); @@ -1719,12 +1717,11 @@ TabChild::IsRootContentDocument() } bool -TabChild::RecvLoadURL(const nsCString& aURI, - const BrowserConfiguration& aConfiguration) +TabChild::RecvLoadURL(const nsCString& uri) { SetProcessNameToAppName(); - nsresult rv = WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(), + nsresult rv = WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(uri).get(), nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP | nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_OWNER, nullptr, nullptr, nullptr); @@ -1733,13 +1730,9 @@ TabChild::RecvLoadURL(const nsCString& aURI, } #ifdef MOZ_CRASHREPORTER - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI); + CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), uri); #endif - nsRefPtr swm = ServiceWorkerManager::GetInstance(); - MOZ_ASSERT(swm); - swm->LoadRegistrations(aConfiguration.serviceWorkerRegistrations()); - return true; } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index d1562cedaca8..9bf664cea6f3 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -312,8 +312,7 @@ public: const ViewID& aViewId, const bool& aIsRoot, const ZoomConstraints& aConstraints) MOZ_OVERRIDE; - virtual bool RecvLoadURL(const nsCString& aURI, - const BrowserConfiguration& aConfiguration) MOZ_OVERRIDE; + virtual bool RecvLoadURL(const nsCString& uri) MOZ_OVERRIDE; virtual bool RecvCacheFileDescriptor(const nsString& aPath, const FileDescriptor& aFileDescriptor) MOZ_OVERRIDE; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 520850669205..062aa8744e11 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -13,7 +13,6 @@ #include "mozilla/BrowserElementParent.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/PContentPermissionRequestParent.h" -#include "mozilla/dom/ServiceWorkerRegistrar.h" #include "mozilla/dom/indexedDB/ActorsParent.h" #include "mozilla/plugins/PluginWidgetParent.h" #include "mozilla/EventStateManager.h" @@ -46,7 +45,6 @@ #include "nsIDOMWindowUtils.h" #include "nsIInterfaceRequestorUtils.h" #include "nsILoadInfo.h" -#include "nsPrincipal.h" #include "nsIPromptFactory.h" #include "nsIURI.h" #include "nsIWebBrowserChrome.h" @@ -695,19 +693,6 @@ TabParent::SendLoadRemoteScript(const nsString& aURL, return PBrowserParent::SendLoadRemoteScript(aURL, aRunInGlobalScope); } -bool -TabParent::InitBrowserConfiguration(nsIURI* aURI, - BrowserConfiguration& aConfiguration) -{ - // Get the list of ServiceWorkerRegistation for this origin. - nsRefPtr swr = ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(swr); - - swr->GetRegistrations(aConfiguration.serviceWorkerRegistrations()); - - return true; -} - void TabParent::LoadURL(nsIURI* aURI) { @@ -742,13 +727,7 @@ TabParent::LoadURL(nsIURI* aURI) } mSendOfflineStatus = false; - // This object contains the configuration for this new app. - BrowserConfiguration configuration; - if (NS_WARN_IF(!InitBrowserConfiguration(aURI, configuration))) { - return; - } - - unused << SendLoadURL(spec, configuration); + unused << SendLoadURL(spec); // If this app is a packaged app then we can speed startup by sending over // the file descriptor for the "application.zip" file that it will diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 94b30f1cb08c..55b69835ad51 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -403,9 +403,6 @@ protected: bool SendCompositionChangeEvent(mozilla::WidgetCompositionEvent& event); - bool InitBrowserConfiguration(nsIURI* aURI, - BrowserConfiguration& aConfiguration); - // IME static TabParent *mIMETabParent; nsString mIMECacheText; diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index 473fb9f4910b..15ccd291fbef 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -112,7 +112,6 @@ include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' LOCAL_INCLUDES += [ - '/caps', '/chrome', '/docshell/base', '/dom/base', diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index a5bc4ad8aa4f..32e2494d35fa 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -4,7 +4,6 @@ #include "ServiceWorkerManager.h" -#include "nsIAppsService.h" #include "nsIDOMEventTarget.h" #include "nsIDocument.h" #include "nsIScriptSecurityManager.h" @@ -22,9 +21,6 @@ #include "mozilla/dom/InstallEventBinding.h" #include "mozilla/dom/Navigator.h" #include "mozilla/dom/PromiseNativeHandler.h" -#include "mozilla/ipc/BackgroundChild.h" -#include "mozilla/ipc/PBackgroundChild.h" -#include "mozilla/ipc/PBackgroundSharedTypes.h" #include "nsContentUtils.h" #include "nsGlobalWindow.h" @@ -49,58 +45,9 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::ipc; BEGIN_WORKERS_NAMESPACE -struct ServiceWorkerManager::PendingOperation -{ - nsCOMPtr mRunnable; - - ServiceWorkerJobQueue* mQueue; - nsRefPtr mJob; - - ServiceWorkerRegistrationData mRegistration; -}; - -namespace { - -nsresult -PopulateRegistrationData(nsIPrincipal* aPrincipal, - const ServiceWorkerRegistrationInfo* aRegistration, - ServiceWorkerRegistrationData& aData) -{ - MOZ_ASSERT(aPrincipal); - MOZ_ASSERT(aRegistration); - - bool isNullPrincipal = true; - nsresult rv = aPrincipal->GetIsNullPrincipal(&isNullPrincipal); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - // No null principals. - if (NS_WARN_IF(isNullPrincipal)) { - return NS_ERROR_FAILURE; - } - - rv = PrincipalToPrincipalInfo(aPrincipal, &aData.principal()); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - aData.scope() = aRegistration->mScope; - aData.scriptSpec() = aRegistration->mScriptSpec; - - if (aRegistration->mActiveWorker) { - aData.currentWorkerURL() = aRegistration->mActiveWorker->ScriptSpec(); - } - - return NS_OK; -} - -} // Anonymous namespace - NS_IMPL_ISUPPORTS0(ServiceWorkerJob) NS_IMPL_ISUPPORTS0(ServiceWorkerRegistrationInfo) @@ -146,12 +93,10 @@ ServiceWorkerRegistrationInfo::Clear() WhichServiceWorker::ACTIVE_WORKER); } -ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(const nsACString& aScope, - nsIPrincipal* aPrincipal) - : mControlledDocumentsCounter(0) - , mScope(aScope) - , mPrincipal(aPrincipal) - , mPendingUninstall(false) +ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(const nsACString& aScope) + : mControlledDocumentsCounter(0), + mScope(aScope), + mPendingUninstall(false) { } ServiceWorkerRegistrationInfo::~ServiceWorkerRegistrationInfo() @@ -170,7 +115,6 @@ NS_IMPL_RELEASE(ServiceWorkerManager) NS_INTERFACE_MAP_BEGIN(ServiceWorkerManager) NS_INTERFACE_MAP_ENTRY(nsIServiceWorkerManager) - NS_INTERFACE_MAP_ENTRY(nsIIPCBackgroundChildCreateCallback) if (aIID.Equals(NS_GET_IID(ServiceWorkerManager))) foundInterface = static_cast(this); else @@ -178,19 +122,7 @@ NS_INTERFACE_MAP_BEGIN(ServiceWorkerManager) NS_INTERFACE_MAP_END ServiceWorkerManager::ServiceWorkerManager() - : mActor(nullptr) { - // Register this component to PBackground. - MOZ_ALWAYS_TRUE(BackgroundChild::GetOrCreateForCurrentThread(this)); - - if (XRE_GetProcessType() == GeckoProcessType_Default) { - nsRefPtr swr = ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(swr); - - nsTArray data; - swr->GetRegistrations(data); - LoadRegistrations(data); - } } ServiceWorkerManager::~ServiceWorkerManager() @@ -448,7 +380,6 @@ class ServiceWorkerRegisterJob MOZ_FINAL : public ServiceWorkerJob, nsCString mScriptSpec; nsRefPtr mRegistration; nsRefPtr mCallback; - nsCOMPtr mPrincipal; ~ServiceWorkerRegisterJob() { } @@ -466,13 +397,11 @@ public: ServiceWorkerRegisterJob(ServiceWorkerJobQueue* aQueue, const nsCString& aScope, const nsCString& aScriptSpec, - ServiceWorkerUpdateFinishCallback* aCallback, - nsIPrincipal* aPrincipal) + ServiceWorkerUpdateFinishCallback* aCallback) : ServiceWorkerJob(aQueue) , mScope(aScope) , mScriptSpec(aScriptSpec) , mCallback(aCallback) - , mPrincipal(aPrincipal) , mJobType(REGISTER_JOB) { } @@ -489,17 +418,8 @@ public: void Start() MOZ_OVERRIDE { - MOZ_ASSERT(NS_IsMainThread()); - - nsRefPtr swm = ServiceWorkerManager::GetInstance(); - if (!swm->HasBackgroundActor()) { - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegisterJob::Start); - swm->AppendPendingOperation(runnable); - return; - } - if (mJobType == REGISTER_JOB) { + nsRefPtr swm = ServiceWorkerManager::GetInstance(); mRegistration = swm->GetRegistration(mScope); if (mRegistration) { @@ -512,11 +432,10 @@ public: return; } } else { - mRegistration = swm->CreateNewRegistration(mScope, mPrincipal); + mRegistration = swm->CreateNewRegistration(mScope); } mRegistration->mScriptSpec = mScriptSpec; - swm->StoreRegistration(mPrincipal, mRegistration); } else { MOZ_ASSERT(mJobType == UPDATE_JOB); } @@ -947,36 +866,13 @@ ServiceWorkerManager::Register(nsIDOMWindow* aWindow, new ServiceWorkerResolveWindowPromiseOnUpdateCallback(window, promise); nsRefPtr job = - new ServiceWorkerRegisterJob(queue, cleanedScope, spec, cb, documentPrincipal); + new ServiceWorkerRegisterJob(queue, cleanedScope, spec, cb); queue->Append(job); promise.forget(aPromise); return NS_OK; } -void -ServiceWorkerManager::AppendPendingOperation(ServiceWorkerJobQueue* aQueue, - ServiceWorkerJob* aJob) -{ - MOZ_ASSERT(!mActor); - MOZ_ASSERT(aQueue); - MOZ_ASSERT(aJob); - - PendingOperation* opt = mPendingOperations.AppendElement(); - opt->mQueue = aQueue; - opt->mJob = aJob; -} - -void -ServiceWorkerManager::AppendPendingOperation(nsIRunnable* aRunnable) -{ - MOZ_ASSERT(!mActor); - MOZ_ASSERT(aRunnable); - - PendingOperation* opt = mPendingOperations.AppendElement(); - opt->mRunnable = aRunnable; -} - /* * Used to handle ExtendableEvent::waitUntil() and proceed with * installation/activation. @@ -1131,7 +1027,6 @@ ServiceWorkerRegistrationInfo::Activate() mActiveWorker->UpdateState(ServiceWorkerState::Activating); swm->CheckPendingReadyPromises(); - swm->StoreRegistration(mPrincipal, this); // "Queue a task to fire a simple event named controllerchange..." nsCOMPtr controllerChangeRunnable = @@ -1487,7 +1382,6 @@ class ServiceWorkerUnregisterJob MOZ_FINAL : public ServiceWorkerJob nsRefPtr mRegistration; const nsCString mScope; nsCOMPtr mCallback; - PrincipalInfo mPrincipalInfo; ~ServiceWorkerUnregisterJob() { } @@ -1495,12 +1389,10 @@ class ServiceWorkerUnregisterJob MOZ_FINAL : public ServiceWorkerJob public: ServiceWorkerUnregisterJob(ServiceWorkerJobQueue* aQueue, const nsACString& aScope, - nsIServiceWorkerUnregisterCallback* aCallback, - PrincipalInfo& aPrincipalInfo) + nsIServiceWorkerUnregisterCallback* aCallback) : ServiceWorkerJob(aQueue) , mScope(aScope) , mCallback(aCallback) - , mPrincipalInfo(aPrincipalInfo) { AssertIsOnMainThread(); } @@ -1553,9 +1445,6 @@ private: swm->RemoveRegistration(registration); } - MOZ_ASSERT(swm->mActor); - swm->mActor->SendUnregisterServiceWorker(mPrincipalInfo, - NS_ConvertUTF8toUTF16(mScope)); return NS_OK; } @@ -1568,12 +1457,10 @@ private: }; NS_IMETHODIMP -ServiceWorkerManager::Unregister(nsIPrincipal* aPrincipal, - nsIServiceWorkerUnregisterCallback* aCallback, +ServiceWorkerManager::Unregister(nsIServiceWorkerUnregisterCallback* aCallback, const nsAString& aScope) { AssertIsOnMainThread(); - MOZ_ASSERT(aPrincipal); MOZ_ASSERT(aCallback); // This is not accessible by content, and callers should always ensure scope is @@ -1590,21 +1477,9 @@ ServiceWorkerManager::Unregister(nsIPrincipal* aPrincipal, ServiceWorkerJobQueue* queue = GetOrCreateJobQueue(scope); MOZ_ASSERT(queue); - PrincipalInfo principalInfo; - if (NS_WARN_IF(NS_FAILED(PrincipalToPrincipalInfo(aPrincipal, - &principalInfo)))) { - return NS_ERROR_DOM_SECURITY_ERR; - } - nsRefPtr job = - new ServiceWorkerUnregisterJob(queue, scope, aCallback, principalInfo); - - if (mActor) { - queue->Append(job); - return NS_OK; - } - - AppendPendingOperation(queue, job); + new ServiceWorkerUnregisterJob(queue, scope, aCallback); + queue->Append(job); return NS_OK; } @@ -1738,85 +1613,6 @@ ServiceWorkerManager::CreateServiceWorkerForWindow(nsPIDOMWindow* aWindow, return rv; } -void -ServiceWorkerManager::LoadRegistrations( - const nsTArray& aRegistrations) -{ - AssertIsOnMainThread(); - - for (uint32_t i = 0, len = aRegistrations.Length(); i < len; ++i) { - nsCOMPtr principal = - PrincipalInfoToPrincipal(aRegistrations[i].principal()); - if (!principal) { - continue; - } - - ServiceWorkerRegistrationInfo* registration = - CreateNewRegistration(aRegistrations[i].scope(), principal); - - registration->mScriptSpec = aRegistrations[i].scriptSpec(); - - registration->mActiveWorker = - new ServiceWorkerInfo(registration, aRegistrations[i].currentWorkerURL()); - } -} - -void -ServiceWorkerManager::ActorFailed() -{ - MOZ_CRASH("Failed to create a PBackgroundChild actor!"); -} - -void -ServiceWorkerManager::ActorCreated(mozilla::ipc::PBackgroundChild* aActor) -{ - MOZ_ASSERT(aActor); - MOZ_ASSERT(!mActor); - mActor = aActor; - - // Flush the pending requests. - for (uint32_t i = 0, len = mPendingOperations.Length(); i < len; ++i) { - MOZ_ASSERT(mPendingOperations[i].mRunnable || - (mPendingOperations[i].mJob && mPendingOperations[i].mQueue)); - - if (mPendingOperations[i].mRunnable) { - nsresult rv = NS_DispatchToCurrentThread(mPendingOperations[i].mRunnable); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch a runnable."); - return; - } - } else { - mPendingOperations[i].mQueue->Append(mPendingOperations[i].mJob); - } - } - - mPendingOperations.Clear(); -} - -void -ServiceWorkerManager::StoreRegistration( - nsIPrincipal* aPrincipal, - ServiceWorkerRegistrationInfo* aRegistration) -{ - MOZ_ASSERT(mActor); - MOZ_ASSERT(aPrincipal); - MOZ_ASSERT(aRegistration); - - ServiceWorkerRegistrationData data; - nsresult rv = PopulateRegistrationData(aPrincipal, aRegistration, data); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - PrincipalInfo principalInfo; - if (NS_WARN_IF(NS_FAILED(PrincipalToPrincipalInfo(aPrincipal, - &principalInfo)))) { - return; - } - - mActor->SendRegisterServiceWorker(data); -} - already_AddRefed ServiceWorkerManager::GetServiceWorkerRegistrationInfo(nsPIDOMWindow* aWindow) { @@ -2370,8 +2166,7 @@ ServiceWorkerManager::FireControllerChange(ServiceWorkerRegistrationInfo* aRegis } ServiceWorkerRegistrationInfo* -ServiceWorkerManager::CreateNewRegistration(const nsCString& aScope, - nsIPrincipal* aPrincipal) +ServiceWorkerManager::CreateNewRegistration(const nsCString& aScope) { #ifdef DEBUG AssertIsOnMainThread(); @@ -2379,7 +2174,7 @@ ServiceWorkerManager::CreateNewRegistration(const nsCString& aScope, nsresult rv = NS_NewURI(getter_AddRefs(scopeURI), aScope, nullptr, nullptr); MOZ_ASSERT(NS_SUCCEEDED(rv)); #endif - ServiceWorkerRegistrationInfo* registration = new ServiceWorkerRegistrationInfo(aScope, aPrincipal); + ServiceWorkerRegistrationInfo* registration = new ServiceWorkerRegistrationInfo(aScope); // From now on ownership of registration is with // mServiceWorkerRegistrationInfos. mServiceWorkerRegistrationInfos.Put(aScope, registration); diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h index 00fbd1799787..b16177f597f0 100644 --- a/dom/workers/ServiceWorkerManager.h +++ b/dom/workers/ServiceWorkerManager.h @@ -8,7 +8,6 @@ #include "nsIServiceWorkerManager.h" #include "nsCOMPtr.h" -#include "ipc/IPCMessageUtils.h" #include "mozilla/Attributes.h" #include "mozilla/LinkedList.h" #include "mozilla/Preferences.h" @@ -18,10 +17,6 @@ #include "mozilla/dom/Promise.h" #include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState #include "mozilla/dom/ServiceWorkerCommon.h" -#include "mozilla/dom/ServiceWorkerRegistrar.h" -#include "mozilla/dom/ServiceWorkerRegistrarTypes.h" -#include "mozilla/ipc/BackgroundUtils.h" -#include "nsIIPCBackgroundChildCreateCallback.h" #include "nsClassHashtable.h" #include "nsDataHashtable.h" #include "nsRefPtrHashtable.h" @@ -31,11 +26,6 @@ class nsIScriptError; namespace mozilla { - -namespace ipc { -class BackgroundChild; -} - namespace dom { class ServiceWorkerRegistration; @@ -141,8 +131,6 @@ public: // the URLs of the following three workers. nsCString mScriptSpec; - nsCOMPtr mPrincipal; - nsRefPtr mActiveWorker; nsRefPtr mWaitingWorker; nsRefPtr mInstallingWorker; @@ -153,8 +141,7 @@ public: bool mPendingUninstall; bool mWaitingToActivate; - explicit ServiceWorkerRegistrationInfo(const nsACString& aScope, - nsIPrincipal* aPrincipal); + explicit ServiceWorkerRegistrationInfo(const nsACString& aScope); already_AddRefed Newest() @@ -231,12 +218,6 @@ public: return mScriptSpec; } - void SetScriptSpec(const nsCString& aSpec) - { - MOZ_ASSERT(!aSpec.IsEmpty()); - mScriptSpec = aSpec; - } - explicit ServiceWorkerInfo(ServiceWorkerRegistrationInfo* aReg, const nsACString& aScriptSpec) : mRegistration(aReg) @@ -285,9 +266,7 @@ public: * installation, querying and event dispatch of ServiceWorkers for all the * origins in the process. */ -class ServiceWorkerManager MOZ_FINAL - : public nsIServiceWorkerManager - , public nsIIPCBackgroundChildCreateCallback +class ServiceWorkerManager MOZ_FINAL : public nsIServiceWorkerManager { friend class ActivationRunnable; friend class ServiceWorkerRegistrationInfo; @@ -301,12 +280,14 @@ class ServiceWorkerManager MOZ_FINAL public: NS_DECL_ISUPPORTS NS_DECL_NSISERVICEWORKERMANAGER - NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK NS_DECLARE_STATIC_IID_ACCESSOR(NS_SERVICEWORKERMANAGER_IMPL_IID) static ServiceWorkerManager* FactoryCreate() { AssertIsOnMainThread(); + if (!Preferences::GetBool("dom.serviceWorkers.enabled")) { + return nullptr; + } ServiceWorkerManager* res = new ServiceWorkerManager; NS_ADDREF(res); @@ -344,7 +325,7 @@ public: } ServiceWorkerRegistrationInfo* - CreateNewRegistration(const nsCString& aScope, nsIPrincipal* aPrincipal); + CreateNewRegistration(const nsCString& aScope); void RemoveRegistration(ServiceWorkerRegistrationInfo* aRegistration) @@ -360,9 +341,6 @@ public: return mJobQueues.LookupOrAdd(aScope); } - void StoreRegistration(nsIPrincipal* aPrincipal, - ServiceWorkerRegistrationInfo* aRegistration); - void FinishFetch(ServiceWorkerRegistrationInfo* aRegistration); @@ -386,9 +364,6 @@ public: static already_AddRefed GetInstance(); - void LoadRegistrations( - const nsTArray& aRegistrations); - private: ServiceWorkerManager(); ~ServiceWorkerManager(); @@ -475,26 +450,12 @@ private: nsRefPtr mPromise; }; - void AppendPendingOperation(nsIRunnable* aRunnable); - void AppendPendingOperation(ServiceWorkerJobQueue* aQueue, - ServiceWorkerJob* aJob); - - bool HasBackgroundActor() const - { - return !!mActor; - } - static PLDHashOperator CheckPendingReadyPromisesEnumerator(nsISupports* aSupports, nsAutoPtr& aData, void* aUnused); nsClassHashtable mPendingReadyPromises; - - mozilla::ipc::PBackgroundChild* mActor; - - struct PendingOperation; - nsTArray mPendingOperations; }; NS_DEFINE_STATIC_IID_ACCESSOR(ServiceWorkerManager, diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp deleted file mode 100644 index fad6788e4246..000000000000 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ /dev/null @@ -1,665 +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/. */ - -#include "ServiceWorkerRegistrar.h" -#include "mozilla/dom/ServiceWorkerRegistrarTypes.h" - -#include "nsIEventTarget.h" -#include "nsIInputStream.h" -#include "nsILineInputStream.h" -#include "nsIObserverService.h" - -#include "MainThreadUtils.h" -#include "mozilla/ClearOnShutdown.h" -#include "mozilla/ipc/BackgroundChild.h" -#include "mozilla/ipc/BackgroundParent.h" -#include "mozilla/ipc/PBackgroundChild.h" -#include "mozilla/ModuleUtils.h" -#include "mozilla/Services.h" -#include "mozilla/StaticPtr.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsAutoPtr.h" -#include "nsDirectoryServiceUtils.h" -#include "nsNetCID.h" -#include "nsNetUtil.h" -#include "nsServiceManagerUtils.h" -#include "nsThreadUtils.h" -#include "nsXULAppAPI.h" - -using namespace mozilla::ipc; - -namespace mozilla { -namespace dom { - -namespace { - -StaticRefPtr gServiceWorkerRegistrar; - -} // anonymous namespace - -NS_IMPL_ISUPPORTS(ServiceWorkerRegistrar, - nsIObserver) - -void -ServiceWorkerRegistrar::Initialize() -{ - MOZ_ASSERT(!gServiceWorkerRegistrar); - - if (XRE_GetProcessType() != GeckoProcessType_Default) { - return; - } - - gServiceWorkerRegistrar = new ServiceWorkerRegistrar(); - ClearOnShutdown(&gServiceWorkerRegistrar); - - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (obs) { - DebugOnly rv = obs->AddObserver(gServiceWorkerRegistrar, - "profile-after-change", false); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - - rv = obs->AddObserver(gServiceWorkerRegistrar, "profile-before-change", - false); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - } -} - -/* static */ already_AddRefed -ServiceWorkerRegistrar::Get() -{ - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); - - MOZ_ASSERT(gServiceWorkerRegistrar); - nsRefPtr service = gServiceWorkerRegistrar.get(); - return service.forget(); -} - -ServiceWorkerRegistrar::ServiceWorkerRegistrar() - : mMonitor("ServiceWorkerRegistrar.mMonitor") - , mDataLoaded(false) - , mShuttingDown(false) - , mShutdownCompleteFlag(nullptr) - , mRunnableCounter(0) -{ - MOZ_ASSERT(NS_IsMainThread()); -} - -ServiceWorkerRegistrar::~ServiceWorkerRegistrar() -{ - MOZ_ASSERT(!mRunnableCounter); -} - -void -ServiceWorkerRegistrar::GetRegistrations( - nsTArray& aValues) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(aValues.IsEmpty()); - - // We care just about the first execution because this can be blocked by - // loading data from disk. - static bool firstTime = true; - TimeStamp startTime; - - if (firstTime) { - startTime = TimeStamp::NowLoRes(); - } - - { - MonitorAutoLock lock(mMonitor); - - // Waiting for data loaded. - mMonitor.AssertCurrentThreadOwns(); - while (!mDataLoaded) { - mMonitor.Wait(); - } - - aValues.AppendElements(mData); - } - - if (firstTime) { - firstTime = false; - Telemetry::AccumulateTimeDelta( - Telemetry::SERVICE_WORKER_REGISTRATION_LOADING, - startTime); - } -} - -void -ServiceWorkerRegistrar::RegisterServiceWorker( - const ServiceWorkerRegistrationData& aData) -{ - AssertIsOnBackgroundThread(); - - if (mShuttingDown) { - NS_WARNING("Failed to register a serviceWorker during shutting down."); - return; - } - - { - MonitorAutoLock lock(mMonitor); - MOZ_ASSERT(mDataLoaded); - - bool found = false; - for (uint32_t i = 0, len = mData.Length(); i < len; ++i) { - if (mData[i].scope() == aData.scope()) { - mData[i] = aData; - found = true; - break; - } - } - - if (!found) { - mData.AppendElement(aData); - } - } - - ScheduleSaveData(); -} - -void -ServiceWorkerRegistrar::UnregisterServiceWorker(const nsACString& aScope) -{ - AssertIsOnBackgroundThread(); - - if (mShuttingDown) { - NS_WARNING("Failed to unregister a serviceWorker during shutting down."); - return; - } - - bool deleted = false; - - { - MonitorAutoLock lock(mMonitor); - MOZ_ASSERT(mDataLoaded); - - for (uint32_t i = 0; i < mData.Length(); ++i) { - if (mData[i].scope() == aScope) { - mData.RemoveElementAt(i); - deleted = true; - break; - } - } - } - - if (deleted) { - ScheduleSaveData(); - } -} - -void -ServiceWorkerRegistrar::LoadData() -{ - MOZ_ASSERT(!NS_IsMainThread()); - MOZ_ASSERT(!mDataLoaded); - - nsresult rv = ReadData(); - - if (NS_WARN_IF(NS_FAILED(rv))) { - DeleteData(); - // Also if the reading failed we have to notify what is waiting for data. - } - - MonitorAutoLock lock(mMonitor); - MOZ_ASSERT(!mDataLoaded); - mDataLoaded = true; - mMonitor.Notify(); -} - -nsresult -ServiceWorkerRegistrar::ReadData() -{ - // We cannot assert about the correct thread because normally this method - // runs on a IO thread, but in gTests we call it from the main-thread. - - MOZ_ASSERT(mProfileDir); - - nsCOMPtr file; - nsresult rv = mProfileDir->Clone(getter_AddRefs(file)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - bool exists; - rv = file->Exists(&exists); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - if (!exists) { - return NS_OK; - } - - nsCOMPtr stream; - rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - nsCOMPtr lineInputStream = do_QueryInterface(stream); - MOZ_ASSERT(lineInputStream); - - nsAutoCString line; - bool hasMoreLines; - rv = lineInputStream->ReadLine(line, &hasMoreLines); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - // The file is corrupted ? - // FIXME: in case we implement a version 2, we should inform the user using - // the console about this issue. - if (!line.EqualsLiteral(SERVICEWORKERREGISTRAR_VERSION)) { - return NS_ERROR_FAILURE; - } - - while (hasMoreLines) { - ServiceWorkerRegistrationData* entry = mData.AppendElement(); - -#define GET_LINE(x) \ - rv = lineInputStream->ReadLine(x, &hasMoreLines); \ - if (NS_WARN_IF(NS_FAILED(rv))) { \ - return rv; \ - } \ - if (NS_WARN_IF(!hasMoreLines)) { \ - return NS_ERROR_FAILURE; \ - } - - GET_LINE(line); - - if (line.EqualsLiteral(SERVICEWORKERREGISTRAR_SYSTEM_PRINCIPAL)) { - entry->principal() = mozilla::ipc::SystemPrincipalInfo(); - } else { - if (!line.EqualsLiteral(SERVICEWORKERREGISTRAR_CONTENT_PRINCIPAL)) { - return NS_ERROR_FAILURE; - } - - GET_LINE(line); - - uint32_t appId = line.ToInteger(&rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - GET_LINE(line); - - if (!line.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE) && - !line.EqualsLiteral(SERVICEWORKERREGISTRAR_FALSE)) { - return NS_ERROR_FAILURE; - } - - bool isInBrowserElement = line.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE); - - GET_LINE(line); - entry->principal() = - mozilla::ipc::ContentPrincipalInfo(appId, isInBrowserElement, - line); - } - - GET_LINE(entry->scope()); - GET_LINE(entry->scriptSpec()); - GET_LINE(entry->currentWorkerURL()); - -#undef GET_LINE - - rv = lineInputStream->ReadLine(line, &hasMoreLines); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - if (!line.EqualsLiteral(SERVICEWORKERREGISTRAR_TERMINATOR)) { - return NS_ERROR_FAILURE; - } - } - - return NS_OK; -} - -void -ServiceWorkerRegistrar::DeleteData() -{ - // We cannot assert about the correct thread because normally this method - // runs on a IO thread, but in gTests we call it from the main-thread. - - MOZ_ASSERT(mProfileDir); - - { - MonitorAutoLock lock(mMonitor); - mData.Clear(); - } - - nsCOMPtr file; - nsresult rv = mProfileDir->Clone(getter_AddRefs(file)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - rv = file->Remove(false); - if (rv == NS_ERROR_FILE_NOT_FOUND) { - return; - } - - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } -} - -class ServiceWorkerRegistrarSaveDataRunnable MOZ_FINAL : public nsRunnable -{ -public: - ServiceWorkerRegistrarSaveDataRunnable() - : mThread(do_GetCurrentThread()) - { - AssertIsOnBackgroundThread(); - } - - NS_IMETHODIMP - Run() - { - nsRefPtr service = ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(service); - - service->SaveData(); - - nsRefPtr runnable = - NS_NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); - nsresult rv = mThread->Dispatch(runnable, NS_DISPATCH_NORMAL); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - return NS_OK; - } - -private: - nsCOMPtr mThread; -}; - -void -ServiceWorkerRegistrar::ScheduleSaveData() -{ - AssertIsOnBackgroundThread(); - MOZ_ASSERT(!mShuttingDown); - - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); - MOZ_ASSERT(target, "Must have stream transport service"); - - nsRefPtr runnable = - new ServiceWorkerRegistrarSaveDataRunnable(); - nsresult rv = target->Dispatch(runnable, NS_DISPATCH_NORMAL); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - ++mRunnableCounter; -} - -void -ServiceWorkerRegistrar::ShutdownCompleted() -{ - MOZ_ASSERT(NS_IsMainThread()); - - MOZ_ASSERT(mShutdownCompleteFlag && !*mShutdownCompleteFlag); - *mShutdownCompleteFlag = true; -} - -void -ServiceWorkerRegistrar::SaveData() -{ - MOZ_ASSERT(!NS_IsMainThread()); - - nsresult rv = WriteData(); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to write data for the ServiceWorker Registations."); - DeleteData(); - } -} - -void -ServiceWorkerRegistrar::DataSaved() -{ - AssertIsOnBackgroundThread(); - MOZ_ASSERT(mRunnableCounter); - - --mRunnableCounter; - MaybeScheduleShutdownCompleted(); -} - -void -ServiceWorkerRegistrar::MaybeScheduleShutdownCompleted() -{ - AssertIsOnBackgroundThread(); - - if (mRunnableCounter || !mShuttingDown) { - return; - } - - nsRefPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); - nsresult rv = NS_DispatchToMainThread(runnable); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } -} - -nsresult -ServiceWorkerRegistrar::WriteData() -{ - // We cannot assert about the correct thread because normally this method - // runs on a IO thread, but in gTests we call it from the main-thread. - - MOZ_ASSERT(mProfileDir); - - nsCOMPtr file; - nsresult rv = mProfileDir->Clone(getter_AddRefs(file)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - // We need a lock to take a snapshot of the data. - nsTArray data; - { - MonitorAutoLock lock(mMonitor); - data = mData; - } - - nsCOMPtr stream; - rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(stream), file); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - nsAutoCString buffer; - buffer.AppendLiteral(SERVICEWORKERREGISTRAR_VERSION); - buffer.Append('\n'); - - uint32_t count; - rv = stream->Write(buffer.Data(), buffer.Length(), &count); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - if (count != buffer.Length()) { - return NS_ERROR_UNEXPECTED; - } - - for (uint32_t i = 0, len = data.Length(); i < len; ++i) { - const mozilla::ipc::PrincipalInfo& info = data[i].principal(); - - if (info.type() == mozilla::ipc::PrincipalInfo::TSystemPrincipalInfo) { - buffer.AssignLiteral(SERVICEWORKERREGISTRAR_SYSTEM_PRINCIPAL); - } else { - MOZ_ASSERT(info.type() == mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); - - const mozilla::ipc::ContentPrincipalInfo& cInfo = - info.get_ContentPrincipalInfo(); - - buffer.AssignLiteral(SERVICEWORKERREGISTRAR_CONTENT_PRINCIPAL); - buffer.Append('\n'); - - buffer.AppendInt(cInfo.appId()); - buffer.Append('\n'); - - if (cInfo.isInBrowserElement()) { - buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TRUE); - } else { - buffer.AppendLiteral(SERVICEWORKERREGISTRAR_FALSE); - } - - buffer.Append('\n'); - buffer.Append(cInfo.spec()); - } - - buffer.Append('\n'); - - buffer.Append(data[i].scope()); - buffer.Append('\n'); - - buffer.Append(data[i].scriptSpec()); - buffer.Append('\n'); - - buffer.Append(data[i].currentWorkerURL()); - buffer.Append('\n'); - - buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR); - buffer.Append('\n'); - - rv = stream->Write(buffer.Data(), buffer.Length(), &count); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - if (count != buffer.Length()) { - return NS_ERROR_UNEXPECTED; - } - } - - nsCOMPtr safeStream = do_QueryInterface(stream); - MOZ_ASSERT(safeStream); - - rv = safeStream->Finish(); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - - return NS_OK; -} - -void -ServiceWorkerRegistrar::ProfileStarted() -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(!mProfileDir); - - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, - getter_AddRefs(mProfileDir)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); - MOZ_ASSERT(target, "Must have stream transport service"); - - nsCOMPtr runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); - rv = target->Dispatch(runnable, NS_DISPATCH_NORMAL); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch the LoadDataRunnable."); - } -} - -void -ServiceWorkerRegistrar::ProfileStopped() -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!mProfileDir) { - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, - getter_AddRefs(mProfileDir)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - } - - PBackgroundChild* child = BackgroundChild::GetForCurrentThread(); - if (!child) { - return; - } - - bool completed = false; - mShutdownCompleteFlag = &completed; - - child->SendShutdownServiceWorkerRegistrar(); - - nsCOMPtr thread(do_GetCurrentThread()); - while (true) { - MOZ_ALWAYS_TRUE(NS_ProcessNextEvent(thread)); - if (completed) { - break; - } - } -} - -void -ServiceWorkerRegistrar::Shutdown() -{ - AssertIsOnBackgroundThread(); - MOZ_ASSERT(!mShuttingDown); - - mShuttingDown = true; - MaybeScheduleShutdownCompleted(); -} - -NS_IMETHODIMP -ServiceWorkerRegistrar::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!strcmp(aTopic, "profile-after-change")) { - nsCOMPtr observerService = - services::GetObserverService(); - observerService->RemoveObserver(this, "profile-after-change"); - - // The profile is fully loaded, now we can proceed with the loading of data - // from disk. - ProfileStarted(); - - return NS_OK; - } - - if (!strcmp(aTopic, "profile-before-change")) { - nsCOMPtr observerService = - services::GetObserverService(); - observerService->RemoveObserver(this, "profile-before-change"); - - // Shutting down, let's sync the data. - ProfileStopped(); - - return NS_OK; - } - - MOZ_ASSERT(false, "ServiceWorkerRegistrar got unexpected topic!"); - return NS_ERROR_UNEXPECTED; -} - -} // dom namespace -} // mozilla namespace diff --git a/dom/workers/ServiceWorkerRegistrar.h b/dom/workers/ServiceWorkerRegistrar.h deleted file mode 100644 index 5c99d3a3fae0..000000000000 --- a/dom/workers/ServiceWorkerRegistrar.h +++ /dev/null @@ -1,92 +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 mozilla_dom_workers_ServiceWorkerRegistrar_h -#define mozilla_dom_workers_ServiceWorkerRegistrar_h - -#include "mozilla/Monitor.h" -#include "mozilla/Telemetry.h" -#include "nsClassHashtable.h" -#include "nsIObserver.h" -#include "nsCOMPtr.h" -#include "nsString.h" -#include "nsTArray.h" - -#define SERVICEWORKERREGISTRAR_FILE "serviceworker.txt" -#define SERVICEWORKERREGISTRAR_VERSION "1" -#define SERVICEWORKERREGISTRAR_TERMINATOR "#" -#define SERVICEWORKERREGISTRAR_TRUE "true" -#define SERVICEWORKERREGISTRAR_FALSE "false" -#define SERVICEWORKERREGISTRAR_SYSTEM_PRINCIPAL "system" -#define SERVICEWORKERREGISTRAR_CONTENT_PRINCIPAL "content" - - -class nsIFile; -class nsRunnable; - -namespace mozilla { -namespace dom { - -class ServiceWorkerRegistrationData; - -class ServiceWorkerRegistrar : public nsIObserver -{ - friend class ServiceWorkerRegistrarSaveDataRunnable; - -public: - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_NSIOBSERVER - - static void Initialize(); - - void Shutdown(); - - void DataSaved(); - - static already_AddRefed Get(); - - void GetRegistrations(nsTArray& aValues); - - void RegisterServiceWorker(const ServiceWorkerRegistrationData& aData); - void UnregisterServiceWorker(const nsACString& aScope); - -protected: - // These methods are protected because we test this class using gTest - // subclassing it. - void LoadData(); - void SaveData(); - - nsresult ReadData(); - nsresult WriteData(); - void DeleteData(); - - ServiceWorkerRegistrar(); - virtual ~ServiceWorkerRegistrar(); - -private: - void ProfileStarted(); - void ProfileStopped(); - - void ScheduleSaveData(); - void ShutdownCompleted(); - void MaybeScheduleShutdownCompleted(); - - mozilla::Monitor mMonitor; - -protected: - // mData and mDataLoaded are protected by mMonitor. - nsTArray mData; - bool mDataLoaded; - - bool mShuttingDown; - bool* mShutdownCompleteFlag; - uint32_t mRunnableCounter; - - nsCOMPtr mProfileDir; -}; - -} // dom namespace -} // mozilla namespace - -#endif // mozilla_dom_workers_ServiceWorkerRegistrar_h diff --git a/dom/workers/ServiceWorkerRegistrarTypes.ipdlh b/dom/workers/ServiceWorkerRegistrarTypes.ipdlh deleted file mode 100644 index d9fb9ed4155e..000000000000 --- a/dom/workers/ServiceWorkerRegistrarTypes.ipdlh +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */ -/* 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 PBackgroundSharedTypes; - -namespace mozilla { -namespace dom { - -struct ServiceWorkerRegistrationData -{ - nsCString scope; - nsCString scriptSpec; - nsCString currentWorkerURL; - PrincipalInfo principal; -}; - -} // namespace dom -} // namespace mozilla diff --git a/dom/workers/ServiceWorkerRegistration.cpp b/dom/workers/ServiceWorkerRegistration.cpp index 9b2dbe54c4e6..c2d24d9e7151 100644 --- a/dom/workers/ServiceWorkerRegistration.cpp +++ b/dom/workers/ServiceWorkerRegistration.cpp @@ -200,7 +200,7 @@ ServiceWorkerRegistration::Unregister(ErrorResult& aRv) nsRefPtr cb = new UnregisterCallback(promise); NS_ConvertUTF8toUTF16 scope(uriSpec); - aRv = swm->Unregister(documentPrincipal, cb, scope); + aRv = swm->Unregister(cb, scope); if (aRv.Failed()) { return nullptr; } diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index b5684d36ac86..d59a2938d91b 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -590,7 +590,7 @@ public: // We don't need to check if the principal can load this mScope because a // ServiceWorkerGlobalScope can always unregister itself. - rv = swm->Unregister(mWorkerPrivate->GetPrincipal(), this, mScope); + rv = swm->Unregister(this, mScope); if (NS_WARN_IF(NS_FAILED(rv))) { UnregisterFailed(); return NS_OK; diff --git a/dom/workers/moz.build b/dom/workers/moz.build index 28d2d89e417c..dc06dedfcf3b 100644 --- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -9,7 +9,6 @@ EXPORTS.mozilla.dom += [ 'ServiceWorkerCommon.h', 'ServiceWorkerContainer.h', 'ServiceWorkerEvents.h', - 'ServiceWorkerRegistrar.h', 'ServiceWorkerRegistration.h', 'WorkerPrivate.h', 'WorkerRunnable.h', @@ -67,7 +66,6 @@ UNIFIED_SOURCES += [ 'ServiceWorkerContainer.cpp', 'ServiceWorkerEvents.cpp', 'ServiceWorkerManager.cpp', - 'ServiceWorkerRegistrar.cpp', 'ServiceWorkerRegistration.cpp', 'SharedWorker.cpp', 'URL.cpp', @@ -80,10 +78,6 @@ UNIFIED_SOURCES += [ 'XMLHttpRequestUpload.cpp', ] -IPDL_SOURCES += [ - 'ServiceWorkerRegistrarTypes.ipdlh', -] - FAIL_ON_WARNINGS = True MSVC_ENABLE_PGO = True @@ -114,5 +108,3 @@ MOCHITEST_MANIFESTS += [ MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini'] XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini'] - -TEST_DIRS += ['test/gtest'] diff --git a/dom/workers/test/gtest/TestReadWrite.cpp b/dom/workers/test/gtest/TestReadWrite.cpp deleted file mode 100644 index 73f1a60ac9c8..000000000000 --- a/dom/workers/test/gtest/TestReadWrite.cpp +++ /dev/null @@ -1,282 +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/. */ - -#include "gtest/gtest.h" -#include "mozilla/dom/ServiceWorkerRegistrar.h" -#include "mozilla/dom/ServiceWorkerRegistrarTypes.h" -#include "mozilla/ipc/PBackgroundSharedTypes.h" - -#include "nsAppDirectoryServiceDefs.h" -#include "nsIFile.h" -#include "nsIOutputStream.h" -#include "nsNetUtil.h" - -using namespace mozilla::dom; -using namespace mozilla::ipc; - -class ServiceWorkerRegistrarTest : public ServiceWorkerRegistrar -{ -public: - ServiceWorkerRegistrarTest() - { - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, - getter_AddRefs(mProfileDir)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - } - - nsresult TestReadData() { return ReadData(); } - nsresult TestWriteData() { return WriteData(); } - void TestDeleteData() { DeleteData(); } - - nsTArray& TestGetData() { return mData; } -}; - -already_AddRefed -GetFile() -{ - nsCOMPtr file; - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, - getter_AddRefs(file)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return nullptr; - } - - file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE)); - return file.forget(); -} - -bool -CreateFile(const nsACString& aData) -{ - nsCOMPtr file = GetFile(); - - nsCOMPtr stream; - nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(stream), file); - if (NS_WARN_IF(NS_FAILED(rv))) { - return false; - } - - uint32_t count; - rv = stream->Write(aData.Data(), aData.Length(), &count); - if (NS_WARN_IF(NS_FAILED(rv))) { - return false; - } - - if (count != aData.Length()) { - return false; - } - - return true; -} - -TEST(ServiceWorkerRegistrar, TestNoFile) -{ - nsCOMPtr file = GetFile(); - ASSERT_TRUE(file) << "GetFile must return a nsIFIle"; - - bool exists; - nsresult rv = file->Exists(&exists); - ASSERT_EQ(NS_OK, rv) << "nsIFile::Exists cannot fail"; - - if (exists) { - rv = file->Remove(false); - ASSERT_EQ(NS_OK, rv) << "nsIFile::Remove cannot fail"; - } - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - rv = swr->TestReadData(); - ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)0, data.Length()) << "No data should be found in an empty file"; -} - -TEST(ServiceWorkerRegistrar, TestEmptyFile) -{ - ASSERT_TRUE(CreateFile(EmptyCString())) << "CreateFile should not fail"; - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsresult rv = swr->TestReadData(); - ASSERT_NE(NS_OK, rv) << "ReadData() should fail if the file is empty"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)0, data.Length()) << "No data should be found in an empty file"; -} - -TEST(ServiceWorkerRegistrar, TestRightVersionFile) -{ - ASSERT_TRUE(CreateFile(nsAutoCString(SERVICEWORKERREGISTRAR_VERSION "\n"))) << "CreateFile should not fail"; - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsresult rv = swr->TestReadData(); - ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail when the version is correct"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)0, data.Length()) << "No data should be found in an empty file"; -} - -TEST(ServiceWorkerRegistrar, TestWrongVersionFile) -{ - ASSERT_TRUE(CreateFile(nsAutoCString(SERVICEWORKERREGISTRAR_VERSION "bla\n"))) << "CreateFile should not fail"; - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsresult rv = swr->TestReadData(); - ASSERT_NE(NS_OK, rv) << "ReadData() should fail when the version is not correct"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)0, data.Length()) << "No data should be found in an empty file"; -} - -TEST(ServiceWorkerRegistrar, TestReadData) -{ - nsAutoCString buffer(SERVICEWORKERREGISTRAR_VERSION "\n"); - - buffer.Append(SERVICEWORKERREGISTRAR_SYSTEM_PRINCIPAL "\n"); - buffer.Append("scope 0\nscriptSpec 0\ncurrentWorkerURL 0\n"); - buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - - buffer.Append(SERVICEWORKERREGISTRAR_CONTENT_PRINCIPAL "\n"); - buffer.Append("123\n" SERVICEWORKERREGISTRAR_TRUE "\n"); - buffer.Append("spec 1\nscope 1\nscriptSpec 1\ncurrentWorkerURL 1\n"); - buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - - buffer.Append(SERVICEWORKERREGISTRAR_CONTENT_PRINCIPAL "\n"); - buffer.Append("0\n" SERVICEWORKERREGISTRAR_FALSE "\n"); - buffer.Append("spec 2\nscope 2\nscriptSpec 2\ncurrentWorkerURL 2\n"); - buffer.Append(SERVICEWORKERREGISTRAR_TERMINATOR "\n"); - - ASSERT_TRUE(CreateFile(buffer)) << "CreateFile should not fail"; - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsresult rv = swr->TestReadData(); - ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)3, data.Length()) << "4 entries should be found"; - - const mozilla::ipc::PrincipalInfo& info0 = data[0].principal(); - ASSERT_EQ(info0.type(), mozilla::ipc::PrincipalInfo::TSystemPrincipalInfo) << "First principal must be system"; - - ASSERT_STREQ("scope 0", data[0].scope().get()); - ASSERT_STREQ("scriptSpec 0", data[0].scriptSpec().get()); - ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); - - const mozilla::ipc::PrincipalInfo& info1 = data[1].principal(); - ASSERT_EQ(info1.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content"; - const mozilla::ipc::ContentPrincipalInfo& cInfo1 = data[1].principal(); - - ASSERT_EQ((uint32_t)123, cInfo1.appId()); - ASSERT_EQ((uint32_t)true, cInfo1.isInBrowserElement()); - ASSERT_STREQ("spec 1", cInfo1.spec().get()); - ASSERT_STREQ("scope 1", data[1].scope().get()); - ASSERT_STREQ("scriptSpec 1", data[1].scriptSpec().get()); - ASSERT_STREQ("currentWorkerURL 1", data[1].currentWorkerURL().get()); - - const mozilla::ipc::PrincipalInfo& info2 = data[2].principal(); - ASSERT_EQ(info2.type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) << "First principal must be content"; - const mozilla::ipc::ContentPrincipalInfo& cInfo2 = data[2].principal(); - - ASSERT_EQ((uint32_t)0, cInfo2.appId()); - ASSERT_EQ((uint32_t)false, cInfo2.isInBrowserElement()); - ASSERT_STREQ("spec 2", cInfo2.spec().get()); - ASSERT_STREQ("scope 2", data[2].scope().get()); - ASSERT_STREQ("scriptSpec 2", data[2].scriptSpec().get()); - ASSERT_STREQ("currentWorkerURL 2", data[2].currentWorkerURL().get()); -} - -TEST(ServiceWorkerRegistrar, TestDeleteData) -{ - ASSERT_TRUE(CreateFile(nsAutoCString("Foobar"))) << "CreateFile should not fail"; - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - swr->TestDeleteData(); - - nsCOMPtr file = GetFile(); - - bool exists; - nsresult rv = file->Exists(&exists); - ASSERT_EQ(NS_OK, rv) << "nsIFile::Exists cannot fail"; - - ASSERT_FALSE(exists) << "The file should not exist after a DeleteData()."; -} - -TEST(ServiceWorkerRegistrar, TestWriteData) -{ - { - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsTArray& data = swr->TestGetData(); - - for (int i = 0; i < 10; ++i) { - ServiceWorkerRegistrationData* d = data.AppendElement(); - - if ((i % 2) == 0) { - d->principal() = mozilla::ipc::SystemPrincipalInfo(); - } else if ((i % 2) == 1) { - nsAutoCString spec; - spec.AppendPrintf("spec write %d", i); - d->principal() = mozilla::ipc::ContentPrincipalInfo(i, i % 2, spec); - } - - d->scope().AppendPrintf("scope write %d", i); - d->scriptSpec().AppendPrintf("scriptSpec write %d", i); - d->currentWorkerURL().AppendPrintf("currentWorkerURL write %d", i); - } - - nsresult rv = swr->TestWriteData(); - ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail"; - } - - nsRefPtr swr = new ServiceWorkerRegistrarTest; - - nsresult rv = swr->TestReadData(); - ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail"; - - const nsTArray& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)10, data.Length()) << "10 entries should be found"; - - for (int i = 0; i < 10; ++i) { - nsAutoCString test; - - if ((i % 2) == 0) { - ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TSystemPrincipalInfo); - } else if ((i % 2) == 1) { - ASSERT_EQ(data[i].principal().type(), mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); - const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal(); - - ASSERT_EQ((uint32_t)i, cInfo.appId()); - ASSERT_EQ((uint32_t)(i %2), cInfo.isInBrowserElement()); - - test.AppendPrintf("spec write %d", i); - ASSERT_STREQ(test.get(), cInfo.spec().get()); - } - - test.Truncate(); - test.AppendPrintf("scope write %d", i); - ASSERT_STREQ(test.get(), data[i].scope().get()); - - test.Truncate(); - test.AppendPrintf("scriptSpec write %d", i); - ASSERT_STREQ(test.get(), data[i].scriptSpec().get()); - - test.Truncate(); - test.AppendPrintf("currentWorkerURL write %d", i); - ASSERT_STREQ(test.get(), data[i].currentWorkerURL().get()); - } -} - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - - int rv = RUN_ALL_TESTS(); - return rv; -} diff --git a/dom/workers/test/gtest/moz.build b/dom/workers/test/gtest/moz.build deleted file mode 100644 index 6be8377e9f29..000000000000 --- a/dom/workers/test/gtest/moz.build +++ /dev/null @@ -1,13 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; 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/. - -UNIFIED_SOURCES = [ - 'TestReadWrite.cpp', -] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul-gtest' diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index b13e614c7bef..ca8fdf752ace 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -10,12 +10,10 @@ #include "mozilla/Assertions.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/PBlobParent.h" -#include "mozilla/dom/ServiceWorkerRegistrar.h" #include "mozilla/dom/indexedDB/ActorsParent.h" #include "mozilla/dom/ipc/BlobParent.h" #include "mozilla/ipc/BackgroundParent.h" #include "mozilla/ipc/BackgroundUtils.h" -#include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/ipc/PBackgroundTestParent.h" #include "mozilla/layout/VsyncParent.h" #include "nsNetUtil.h" @@ -73,7 +71,6 @@ namespace ipc { using mozilla::dom::ContentParent; using mozilla::dom::BroadcastChannelParent; -using mozilla::dom::ServiceWorkerRegistrationData; BackgroundParentImpl::BackgroundParentImpl() { @@ -356,197 +353,6 @@ BackgroundParentImpl::DeallocPBroadcastChannelParent( return true; } -namespace { - -class RegisterServiceWorkerCallback MOZ_FINAL : public nsRunnable -{ -public: - explicit RegisterServiceWorkerCallback( - const ServiceWorkerRegistrationData& aData) - : mData(aData) - { - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - } - - NS_IMETHODIMP - Run() - { - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - nsRefPtr service = - dom::ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(service); - - service->RegisterServiceWorker(mData); - return NS_OK; - } - -private: - ServiceWorkerRegistrationData mData; -}; - -class UnregisterServiceWorkerCallback MOZ_FINAL : public nsRunnable -{ -public: - explicit UnregisterServiceWorkerCallback(const nsString& aScope) - : mScope(aScope) - { - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - } - - NS_IMETHODIMP - Run() - { - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - nsRefPtr service = - dom::ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(service); - - service->UnregisterServiceWorker(NS_ConvertUTF16toUTF8(mScope)); - return NS_OK; - } - -private: - nsString mScope; -}; - -class CheckPrincipalWithCallbackRunnable MOZ_FINAL : public nsRunnable -{ -public: - CheckPrincipalWithCallbackRunnable(already_AddRefed aParent, - const PrincipalInfo& aPrincipalInfo, - nsRunnable* aCallback) - : mContentParent(aParent) - , mPrincipalInfo(aPrincipalInfo) - , mCallback(aCallback) - , mBackgroundThread(NS_GetCurrentThread()) - { - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - MOZ_ASSERT(mContentParent); - MOZ_ASSERT(mCallback); - MOZ_ASSERT(mBackgroundThread); - } - - NS_IMETHODIMP Run() - { - if (NS_IsMainThread()) { - nsCOMPtr principal = PrincipalInfoToPrincipal(mPrincipalInfo); - AssertAppPrincipal(mContentParent, principal); - mContentParent = nullptr; - - mBackgroundThread->Dispatch(this, NS_DISPATCH_NORMAL); - return NS_OK; - } - - AssertIsOnBackgroundThread(); - mCallback->Run(); - mCallback = nullptr; - - return NS_OK; - } - -private: - nsRefPtr mContentParent; - PrincipalInfo mPrincipalInfo; - nsRefPtr mCallback; - nsCOMPtr mBackgroundThread; -}; - -} // anonymous namespace - -bool -BackgroundParentImpl::RecvRegisterServiceWorker( - const ServiceWorkerRegistrationData& aData) -{ - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - // Basic validation. - if (aData.scope().IsEmpty() || - aData.scriptSpec().IsEmpty() || - aData.principal().type() == PrincipalInfo::TNullPrincipalInfo) { - return false; - } - - nsRefPtr callback = - new RegisterServiceWorkerCallback(aData); - - nsRefPtr parent = BackgroundParent::GetContentParent(this); - - // If the ContentParent is null we are dealing with a same-process actor. - if (!parent) { - callback->Run(); - return true; - } - - nsRefPtr runnable = - new CheckPrincipalWithCallbackRunnable(parent.forget(), aData.principal(), - callback); - nsresult rv = NS_DispatchToMainThread(runnable); - MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv)); - - return true; -} - -bool -BackgroundParentImpl::RecvUnregisterServiceWorker( - const PrincipalInfo& aPrincipalInfo, - const nsString& aScope) -{ - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - // Basic validation. - if (aScope.IsEmpty() || - aPrincipalInfo.type() == PrincipalInfo::TNullPrincipalInfo) { - return false; - } - - nsRefPtr callback = - new UnregisterServiceWorkerCallback(aScope); - - nsRefPtr parent = BackgroundParent::GetContentParent(this); - - // If the ContentParent is null we are dealing with a same-process actor. - if (!parent) { - callback->Run(); - return true; - } - - nsRefPtr runnable = - new CheckPrincipalWithCallbackRunnable(parent.forget(), aPrincipalInfo, - callback); - nsresult rv = NS_DispatchToMainThread(runnable); - MOZ_ALWAYS_TRUE(NS_SUCCEEDED(rv)); - - return true; -} - -bool -BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() -{ - AssertIsInMainProcess(); - AssertIsOnBackgroundThread(); - - if (BackgroundParent::IsOtherProcessActor(this)) { - return false; - } - - nsRefPtr service = - dom::ServiceWorkerRegistrar::Get(); - MOZ_ASSERT(service); - - service->Shutdown(); - return true; -} - } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/BackgroundParentImpl.h b/ipc/glue/BackgroundParentImpl.h index 7f5ead1a71df..ab4bb2ed28a8 100644 --- a/ipc/glue/BackgroundParentImpl.h +++ b/ipc/glue/BackgroundParentImpl.h @@ -83,17 +83,6 @@ protected: virtual bool DeallocPBroadcastChannelParent(PBroadcastChannelParent* aActor) MOZ_OVERRIDE; - - virtual bool - RecvRegisterServiceWorker(const ServiceWorkerRegistrationData& aData) - MOZ_OVERRIDE; - - virtual bool - RecvUnregisterServiceWorker(const PrincipalInfo& aPrincipalInfo, - const nsString& aScope) MOZ_OVERRIDE; - - virtual bool - RecvShutdownServiceWorkerRegistrar() MOZ_OVERRIDE; }; } // namespace ipc diff --git a/ipc/glue/PBackground.ipdl b/ipc/glue/PBackground.ipdl index cecce42ec08d..9af3c7971ea4 100644 --- a/ipc/glue/PBackground.ipdl +++ b/ipc/glue/PBackground.ipdl @@ -12,7 +12,6 @@ include protocol PVsync; include DOMTypes; include PBackgroundSharedTypes; include PBackgroundIDBSharedTypes; -include ServiceWorkerRegistrarTypes; namespace mozilla { namespace ipc { @@ -36,11 +35,6 @@ parent: PBroadcastChannel(PrincipalInfo pInfo, nsString origin, nsString channel); - RegisterServiceWorker(ServiceWorkerRegistrationData data); - UnregisterServiceWorker(PrincipalInfo principalInfo, - nsString scope); - ShutdownServiceWorkerRegistrar(); - both: PBlob(BlobConstructorParams params); diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index 509f5a0c8c85..941683532459 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -301,8 +301,6 @@ nsLayoutStatics::Initialize() IMEStateManager::Init(); - ServiceWorkerRegistrar::Initialize(); - #ifdef MOZ_B2G RequestSyncWifiService::Init(); #endif diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 5bc145c956e8..0899137d4348 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7039,13 +7039,6 @@ "n_values": 3, "description": "Doorhanger shown = 0, Disable = 1, Enable = 2" }, - "SERVICE_WORKER_REGISTRATION_LOADING": { - "expires_in_version": "never", - "kind": "exponential", - "high": "5000", - "n_buckets": 20, - "description": "Tracking how ServiceWorkerRegistrar loads data before the first content is shown" - }, "LOOP_CLIENT_CALL_URL_REQUESTS_SUCCESS": { "expires_in_version": "never", "kind": "boolean",