Bug 1363541 - Modernize the PermissionManager - part 4 - mozilla namespace, r=timhuang
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 11 Apr 2020 13:42:12 +0000
changeset 523492 8b4dd0da0d5a05570ffeaa9733b2ea680b80a9f8
parent 523491 1d7b14496648653222e010e2568cf24d6051cc11
child 523493 273f709e526ebe172b5364a7680397113e068852
push id37303
push userbtara@mozilla.com
push dateSat, 11 Apr 2020 21:48:10 +0000
treeherdermozilla-central@50bf3ff60730 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimhuang
bugs1363541
milestone77.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
Bug 1363541 - Modernize the PermissionManager - part 4 - mozilla namespace, r=timhuang Differential Revision: https://phabricator.services.mozilla.com/D70040
browser/app/permissions
dom/base/Document.cpp
dom/base/moz.build
dom/base/nsIContentPolicy.idl
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/moz.build
dom/permission/moz.build
dom/serviceworkers/ServiceWorkerManager.cpp
dom/serviceworkers/moz.build
dom/workers/remoteworkers/RemoteWorkerChild.cpp
dom/workers/remoteworkers/moz.build
extensions/permissions/PermissionDelegateHandler.cpp
extensions/permissions/PermissionManager.cpp
extensions/permissions/PermissionManager.h
extensions/permissions/components.conf
extensions/permissions/moz.build
extensions/permissions/nsPermissionManager.cpp
extensions/permissions/nsPermissionManager.h
extensions/permissions/test/browser.ini
extensions/permissions/test/gtest/PermissionManagerTest.cpp
extensions/permissions/test/gtest/moz.build
extensions/permissions/test/unit/test_permmanager_migrate_10-11.js
extensions/permissions/test/unit/test_permmanager_migrate_4-7.js
extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js
extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js
extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js
extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js
extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js
extensions/permissions/test/unit/test_permmanager_migrate_7-8.js
extensions/permissions/test/unit/test_permmanager_migrate_9-10.js
extensions/permissions/test/unit/test_permmanager_oa_strip.js
extensions/permissions/test/unit/test_permmanager_removebytypesince.js
extensions/permissions/test/unit/test_permmanager_removesince.js
layout/build/moz.build
layout/build/nsLayoutStatics.cpp
layout/tools/reftest/selftest/files/leaks.log
netwerk/base/moz.build
netwerk/cookie/CookieJarSettings.cpp
netwerk/cookie/CookiePermission.cpp
netwerk/cookie/CookiePermission.h
netwerk/cookie/moz.build
testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPermissions.html
testing/mozbase/mozprofile/mozprofile/permissions.py
toolkit/components/antitracking/AntiTrackingUtils.cpp
toolkit/components/antitracking/ContentBlocking.cpp
toolkit/components/antitracking/ContentBlockingAllowList.cpp
toolkit/components/antitracking/ContentBlockingUserInteraction.cpp
toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp
toolkit/components/antitracking/TemporaryAccessGrantObserver.h
toolkit/components/antitracking/moz.build
--- a/browser/app/permissions
+++ b/browser/app/permissions
@@ -1,15 +1,15 @@
 # This file has default permissions for the permission manager.
 # The file-format is strict:
 # * matchtype \t type \t permission \t host
 # * "origin" should be used for matchtype, "host" is supported for legacy reasons
 # * type is a string that identifies the type of permission (e.g. "cookie")
 # * permission is an integer between 1 and 15
-# See nsPermissionManager.cpp for more...
+# See PermissionManager.cpp for more...
 
 # UITour
 # Bug 1557153: www.mozilla.org gets a special workaround in UITourChild.jsm
 origin	uitour	1	https://www.mozilla.org
 origin	uitour	1	https://monitor.firefox.com
 origin	uitour	1	https://screenshots.firefox.com
 origin	uitour	1	https://support.mozilla.org
 origin	uitour	1	about:home
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -169,19 +169,19 @@
 #include "nsIRequestContext.h"
 #include "nsStyleSheetService.h"
 
 #include "nsNetUtil.h"  // for NS_NewURI
 #include "nsIInputStreamChannel.h"
 #include "nsIAuthPrompt.h"
 #include "nsIAuthPrompt2.h"
 
+#include "mozilla/PermissionManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIPermission.h"
-#include "nsPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIPrivateBrowsingChannel.h"
 #include "ExpandedPrincipal.h"
 #include "mozilla/NullPrincipal.h"
 
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 #include "nsICookieService.h"
@@ -15894,17 +15894,17 @@ Document::AutomaticStorageAccessCanBeGra
 
   return AutomaticStorageAccessGrantPromise::CreateAndReject(false, __func__);
 }
 
 bool Document::AutomaticStorageAccessCanBeGranted(nsIPrincipal* aPrincipal) {
   nsAutoCString prefix;
   AntiTrackingUtils::CreateStoragePermissionKey(aPrincipal, prefix);
 
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  PermissionManager* permManager = PermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     return false;
   }
 
   typedef nsTArray<RefPtr<nsIPermission>> Permissions;
   Permissions perms;
   nsresult rv = permManager->GetAllWithTypePrefix(prefix, perms);
   if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -505,17 +505,16 @@ LOCAL_INCLUDES += [
     '/dom/html',
     '/dom/ipc',
     '/dom/storage',
     '/dom/svg',
     '/dom/u2f',
     '/dom/xml',
     '/dom/xslt/xpath',
     '/dom/xul',
-    '/extensions/permissions',
     '/gfx/2d',
     '/image',
     '/js/xpconnect/loader',
     '/js/xpconnect/src',
     '/js/xpconnect/wrappers',
     '/layout/base',
     '/layout/forms',
     '/layout/generic',
--- a/dom/base/nsIContentPolicy.idl
+++ b/dom/base/nsIContentPolicy.idl
@@ -393,17 +393,17 @@ interface nsIContentPolicy : nsISupports
    * implementations.
    */
   const nsContentPolicyType TYPE_INTERNAL_PAINTWORKLET = 50;
 
   /* When adding new content types, please update
    * NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
    * DoContentSecurityChecks, all nsIContentPolicy implementations, the
    * static_assert in dom/cache/DBSchema.cpp, ChannelWrapper.webidl,
-   * ChannelWrapper.cpp, nsPermissionManager.cpp, and other things that are not
+   * ChannelWrapper.cpp, PermissionManager.cpp, and other things that are not
    * listed here that are related to nsIContentPolicy. */
 
   //////////////////////////////////////////////////////////////////////
 
   /**
    * Returned from shouldLoad or shouldProcess if the load or process request
    * is rejected based on details of the request.
    */
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -205,17 +205,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "mozilla/dom/BlobURLProtocolHandler.h"
 
 #ifdef MOZ_WEBRTC
 #  include "signaling/src/peerconnection/WebrtcGlobalChild.h"
 #endif
 
 #include "mozilla/Permission.h"
-#include "nsPermissionManager.h"
+#include "mozilla/PermissionManager.h"
 
 #include "PermissionMessageUtils.h"
 
 #if defined(MOZ_WIDGET_ANDROID)
 #  include "APKOpen.h"
 #endif
 
 #ifdef XP_WIN
@@ -2464,18 +2464,18 @@ mozilla::ipc::IPCResult ContentChild::Re
   LocaleService::GetInstance()->AssignRequestedLocales(aRequestedLocales);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvAddPermission(
     const IPC::Permission& permission) {
   nsCOMPtr<nsIPermissionManager> permissionManagerIface =
       services::GetPermissionManager();
-  nsPermissionManager* permissionManager =
-      static_cast<nsPermissionManager*>(permissionManagerIface.get());
+  PermissionManager* permissionManager =
+      static_cast<PermissionManager*>(permissionManagerIface.get());
   MOZ_ASSERT(permissionManager,
              "We have no permissionManager in the Content process !");
 
   // note we do not need to force mUserContextId to the default here because
   // the permission manager does that internally.
   nsAutoCString originNoSuffix;
   OriginAttributes attrs;
   bool success = attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
@@ -2489,26 +2489,26 @@ mozilla::ipc::IPCResult ContentChild::Re
       mozilla::BasePrincipal::CreateContentPrincipal(uri, attrs);
 
   // child processes don't care about modification time.
   int64_t modificationTime = 0;
 
   permissionManager->AddInternal(
       principal, nsCString(permission.type), permission.capability, 0,
       permission.expireType, permission.expireTime, modificationTime,
-      nsPermissionManager::eNotify, nsPermissionManager::eNoDBOperation);
+      PermissionManager::eNotify, PermissionManager::eNoDBOperation);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvRemoveAllPermissions() {
   nsCOMPtr<nsIPermissionManager> permissionManagerIface =
       services::GetPermissionManager();
-  nsPermissionManager* permissionManager =
-      static_cast<nsPermissionManager*>(permissionManagerIface.get());
+  PermissionManager* permissionManager =
+      static_cast<PermissionManager*>(permissionManagerIface.get());
   MOZ_ASSERT(permissionManager,
              "We have no permissionManager in the Content process !");
 
   permissionManager->RemoveAllFromIPC();
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvFlushMemory(const nsString& reason) {
@@ -3341,17 +3341,17 @@ nsresult ContentChild::AsyncOpenAnonymou
   // Remember the association with the callback.
   MOZ_ASSERT(!mPendingAnonymousTemporaryFiles.Get(newID));
   mPendingAnonymousTemporaryFiles.LookupOrAdd(newID, aCallback);
   return NS_OK;
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvSetPermissionsWithKey(
     const nsCString& aPermissionKey, nsTArray<IPC::Permission>&& aPerms) {
-  RefPtr<nsPermissionManager> permManager = nsPermissionManager::GetInstance();
+  RefPtr<PermissionManager> permManager = PermissionManager::GetInstance();
   if (permManager) {
     permManager->SetPermissionsWithKey(aPermissionKey, aPerms);
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvRefreshScreens(
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -246,17 +246,17 @@
 #if defined(XP_LINUX)
 #  include "mozilla/Hal.h"
 #endif
 
 #ifdef ANDROID
 #  include "gfxAndroidPlatform.h"
 #endif
 
-#include "nsPermissionManager.h"
+#include "mozilla/PermissionManager.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #  include "AndroidBridge.h"
 #endif
 
 #ifdef MOZ_WIDGET_GTK
 #  include <gdk/gdk.h>
 #endif
@@ -5451,17 +5451,17 @@ nsresult ContentParent::AboutToLoadHttpF
 
   return NS_OK;
 }
 
 nsresult ContentParent::TransmitPermissionsForPrincipal(
     nsIPrincipal* aPrincipal) {
   // Create the key, and send it down to the content process.
   nsTArray<std::pair<nsCString, nsCString>> pairs =
-      nsPermissionManager::GetAllKeysForPrincipal(aPrincipal);
+      PermissionManager::GetAllKeysForPrincipal(aPrincipal);
   MOZ_ASSERT(pairs.Length() >= 1);
   for (auto& pair : pairs) {
     EnsurePermissionsByKey(pair.first, pair.second);
   }
 
   return NS_OK;
 }
 
@@ -5501,17 +5501,17 @@ void ContentParent::TransmitBlobURLsForP
 
 void ContentParent::EnsurePermissionsByKey(const nsCString& aKey,
                                            const nsCString& aOrigin) {
   // NOTE: Make sure to initialize the permission manager before updating the
   // mActivePermissionKeys list. If the permission manager is being initialized
   // by this call to GetPermissionManager, and we've added the key to
   // mActivePermissionKeys, then the permission manager will send down a
   // SendAddPermission before receiving the SendSetPermissionsWithKey message.
-  RefPtr<nsPermissionManager> permManager = nsPermissionManager::GetInstance();
+  RefPtr<PermissionManager> permManager = PermissionManager::GetInstance();
   if (!permManager) {
     return;
   }
 
   if (mActivePermissionKeys.Contains(aKey)) {
     return;
   }
   mActivePermissionKeys.PutEntry(aKey);
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -184,17 +184,16 @@ LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/bindings',
     '/dom/events',
     '/dom/filesystem',
     '/dom/geolocation',
     '/dom/media/webspeech/synth/ipc',
     '/dom/security',
     '/dom/storage',
-    '/extensions/permissions',
     '/extensions/spellcheck/src',
     '/gfx/2d',
     '/hal/sandbox',
     '/js/xpconnect/loader',
     '/js/xpconnect/src',
     '/layout/base',
     '/media/webrtc',
     '/netwerk/base',
--- a/dom/permission/moz.build
+++ b/dom/permission/moz.build
@@ -14,17 +14,13 @@ EXPORTS.mozilla.dom += [
 
 UNIFIED_SOURCES += [
     'PermissionObserver.cpp',
     'Permissions.cpp',
     'PermissionStatus.cpp',
     'PermissionUtils.cpp',
 ]
 
-LOCAL_INCLUDES += [
-    '/extensions/permissions',
-]
-
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
 
 FINAL_LIBRARY = 'xul'
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/dom/serviceworkers/ServiceWorkerManager.cpp
+++ b/dom/serviceworkers/ServiceWorkerManager.cpp
@@ -48,22 +48,22 @@
 #include "mozilla/dom/SharedWorker.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerRunnable.h"
 #include "mozilla/dom/WorkerScope.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "mozilla/dom/ScriptLoader.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/Unused.h"
 #include "mozilla/EnumSet.h"
 
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
-#include "nsPermissionManager.h"
 #include "nsProxyRelease.h"
 #include "nsQueryObject.h"
 #include "nsTArray.h"
 
 #include "ServiceWorker.h"
 #include "ServiceWorkerContainer.h"
 #include "ServiceWorkerInfo.h"
 #include "ServiceWorkerJobQueue.h"
@@ -2282,18 +2282,17 @@ void ServiceWorkerManager::DispatchFetch
       new ContinueDispatchFetchEventRunnable(serviceWorker->WorkerPrivate(),
                                              aChannel, loadGroup);
 
   // When this service worker was registered, we also sent down the permissions
   // for the runnable. They should have arrived by now, but we still need to
   // wait for them if they have not.
   nsCOMPtr<nsIRunnable> permissionsRunnable = NS_NewRunnableFunction(
       "dom::ServiceWorkerManager::DispatchFetchEvent", [=]() {
-        RefPtr<nsPermissionManager> permMgr =
-            nsPermissionManager::GetInstance();
+        RefPtr<PermissionManager> permMgr = PermissionManager::GetInstance();
         if (permMgr) {
           permMgr->WhenPermissionsAvailable(serviceWorker->Principal(),
                                             continueRunnable);
         } else {
           continueRunnable->HandleError();
         }
       });
 
--- a/dom/serviceworkers/moz.build
+++ b/dom/serviceworkers/moz.build
@@ -102,17 +102,16 @@ IPDL_SOURCES += [
     'ServiceWorkerRegistrarTypes.ipdlh',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
-    '/extensions/permissions',
     '/js/xpconnect/loader',
 ]
 
 MOCHITEST_MANIFESTS += [
     'test/mochitest.ini',
 ]
 
 MOCHITEST_CHROME_MANIFESTS += [
--- a/dom/workers/remoteworkers/RemoteWorkerChild.cpp
+++ b/dom/workers/remoteworkers/RemoteWorkerChild.cpp
@@ -10,17 +10,16 @@
 
 #include "MainThreadUtils.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsIConsoleReportCollector.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIPrincipal.h"
 #include "nsNetUtil.h"
-#include "nsPermissionManager.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 
 #include "RemoteWorkerService.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BasePrincipal.h"
@@ -42,16 +41,17 @@
 #include "mozilla/dom/workerinternals/ScriptLoader.h"
 #include "mozilla/dom/WorkerError.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerRef.h"
 #include "mozilla/dom/WorkerRunnable.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/net/CookieJarSettings.h"
+#include "mozilla/PermissionManager.h"
 
 namespace mozilla {
 
 using namespace ipc;
 
 namespace dom {
 
 using workerinternals::ChannelFromScriptURLMainThread;
@@ -460,18 +460,18 @@ nsresult RemoteWorkerChild::ExecWorkerOn
             isPending = lock->is<Pending>();
           }
           if (NS_WARN_IF(!isPending || !initializeWorkerRunnable->Dispatch())) {
             self->TransitionStateToTerminated();
             self->CreationFailedOnAnyThread();
           }
         });
 
-    RefPtr<nsPermissionManager> permissionManager =
-        nsPermissionManager::GetInstance();
+    RefPtr<PermissionManager> permissionManager =
+        PermissionManager::GetInstance();
     if (!permissionManager) {
       return NS_ERROR_FAILURE;
     }
     permissionManager->WhenPermissionsAvailable(principal, r);
   } else {
     if (NS_WARN_IF(!runnable->Dispatch())) {
       rv = NS_ERROR_FAILURE;
       return rv;
--- a/dom/workers/remoteworkers/moz.build
+++ b/dom/workers/remoteworkers/moz.build
@@ -24,17 +24,16 @@ UNIFIED_SOURCES += [
     'RemoteWorkerParent.cpp',
     'RemoteWorkerService.cpp',
     'RemoteWorkerServiceChild.cpp',
     'RemoteWorkerServiceParent.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/serviceworkers',
-    '/extensions/permissions',
     '/xpcom/build',
 ]
 
 IPDL_SOURCES += [
     'PRemoteWorker.ipdl',
     'PRemoteWorkerController.ipdl',
     'PRemoteWorkerService.ipdl',
     'RemoteWorkerTypes.ipdlh',
--- a/extensions/permissions/PermissionDelegateHandler.cpp
+++ b/extensions/permissions/PermissionDelegateHandler.cpp
@@ -3,24 +3,24 @@
 /* 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 "mozilla/PermissionDelegateHandler.h"
 
 #include "nsGlobalWindowInner.h"
 #include "nsPIDOMWindow.h"
-#include "nsPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsContentPermissionHelper.h"
 
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/StaticPrefs_permissions.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/FeaturePolicyUtils.h"
+#include "mozilla/PermissionManager.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 typedef PermissionDelegateHandler::PermissionDelegatePolicy DelegatePolicy;
 typedef PermissionDelegateHandler::PermissionDelegateInfo DelegateInfo;
 
@@ -130,17 +130,17 @@ nsresult PermissionDelegateHandler::GetD
   }
 
   return aRequest->GetPrincipal(aResult);
 }
 
 bool PermissionDelegateHandler::Initialize() {
   MOZ_ASSERT(mDocument);
 
-  mPermissionManager = nsPermissionManager::GetInstance();
+  mPermissionManager = PermissionManager::GetInstance();
   if (!mPermissionManager) {
     return false;
   }
 
   mPrincipal = mDocument->NodePrincipal();
   nsPIDOMWindowInner* window = mDocument->GetInnerWindow();
   nsGlobalWindowInner* innerWindow = nsGlobalWindowInner::Cast(window);
   if (innerWindow) {
rename from extensions/permissions/nsPermissionManager.cpp
rename to extensions/permissions/PermissionManager.cpp
--- a/extensions/permissions/nsPermissionManager.cpp
+++ b/extensions/permissions/PermissionManager.cpp
@@ -6,18 +6,18 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/ContentPrincipal.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Permission.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/Services.h"
-#include "nsPermissionManager.h"
 #include "nsCRT.h"
 #include "nsNetUtil.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "mozIStorageCompletionCallback.h"
 #include "mozIStorageService.h"
@@ -41,21 +41,22 @@
 #include "nsToolkitCompsCID.h"
 #include "nsIObserverService.h"
 #include "nsPrintfCString.h"
 #include "mozilla/AbstractThread.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "nsEffectiveTLDService.h"
 
-static mozilla::StaticRefPtr<nsPermissionManager> gPermissionManager;
-
-using namespace mozilla;
 using namespace mozilla::dom;
 
+namespace mozilla {
+
+static StaticRefPtr<PermissionManager> gPermissionManager;
+
 static bool IsChildProcess() { return XRE_IsContentProcess(); }
 
 static void LogToConsole(const nsAString& aMsg) {
   nsCOMPtr<nsIConsoleService> console(
       do_GetService("@mozilla.org/consoleservice;1"));
   if (!console) {
     NS_WARNING("Failed to log message to console.");
     return;
@@ -188,17 +189,17 @@ nsresult GetOriginFromPrincipal(nsIPrinc
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   nsAutoCString suffix;
   rv = aPrincipal->GetOriginSuffix(suffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mozilla::OriginAttributes attrs;
+  OriginAttributes attrs;
   if (!attrs.PopulateFromSuffix(suffix)) {
     return NS_ERROR_FAILURE;
   }
 
   OriginAppendOASuffix(attrs, aForceStripOA, aOrigin);
 
   return NS_OK;
 }
@@ -215,48 +216,48 @@ nsresult GetOriginFromURIAndOA(nsIURI* a
   aOrigin = origin;
 
   return NS_OK;
 }
 
 nsresult GetPrincipalFromOrigin(const nsACString& aOrigin, bool aForceStripOA,
                                 nsIPrincipal** aPrincipal) {
   nsAutoCString originNoSuffix;
-  mozilla::OriginAttributes attrs;
+  OriginAttributes attrs;
   if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) {
     return NS_ERROR_FAILURE;
   }
 
   MaybeStripOAs(aForceStripOA, attrs);
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrincipal> principal =
-      mozilla::BasePrincipal::CreateContentPrincipal(uri, attrs);
+      BasePrincipal::CreateContentPrincipal(uri, attrs);
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsresult GetPrincipal(nsIURI* aURI, bool aIsInIsolatedMozBrowserElement,
                       nsIPrincipal** aPrincipal) {
-  mozilla::OriginAttributes attrs(aIsInIsolatedMozBrowserElement);
+  OriginAttributes attrs(aIsInIsolatedMozBrowserElement);
   nsCOMPtr<nsIPrincipal> principal =
-      mozilla::BasePrincipal::CreateContentPrincipal(aURI, attrs);
+      BasePrincipal::CreateContentPrincipal(aURI, attrs);
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsresult GetPrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) {
-  mozilla::OriginAttributes attrs;
+  OriginAttributes attrs;
   nsCOMPtr<nsIPrincipal> principal =
-      mozilla::BasePrincipal::CreateContentPrincipal(aURI, attrs);
+      BasePrincipal::CreateContentPrincipal(aURI, attrs);
   NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
 
   principal.forget(aPrincipal);
   return NS_OK;
 }
 
 nsCString GetNextSubDomainForHost(const nsACString& aHost) {
   nsCString subDomain;
@@ -309,25 +310,25 @@ already_AddRefed<nsIPrincipal> GetNextSu
   // Create a new principal which is identical to the current one, but with the
   // new host
   nsCOMPtr<nsIURI> newURI = GetNextSubDomainURI(uri);
   if (!newURI) {
     return nullptr;
   }
 
   // Copy the attributes over
-  mozilla::OriginAttributes attrs = aPrincipal->OriginAttributesRef();
+  OriginAttributes attrs = aPrincipal->OriginAttributesRef();
 
   if (!StaticPrefs::permissions_isolateBy_userContext()) {
     // Disable userContext for permissions.
-    attrs.StripAttributes(mozilla::OriginAttributes::STRIP_USER_CONTEXT_ID);
+    attrs.StripAttributes(OriginAttributes::STRIP_USER_CONTEXT_ID);
   }
 
   nsCOMPtr<nsIPrincipal> principal =
-      mozilla::BasePrincipal::CreateContentPrincipal(newURI, attrs);
+      BasePrincipal::CreateContentPrincipal(newURI, attrs);
 
   return principal.forget();
 }
 
 nsresult UpgradeHostToOriginAndInsert(
     const nsACString& aHost, const nsCString& aType, uint32_t aPermission,
     uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
     bool aIsInIsolatedMozBrowserElement,
@@ -570,82 +571,83 @@ static bool IsPersistentExpire(uint32_t 
 #endif
   return res;
 }
 
 }  // namespace
 
 ////////////////////////////////////////////////////////////////////////////////
 
-nsPermissionManager::PermissionKey*
-nsPermissionManager::PermissionKey::CreateFromPrincipal(
-    nsIPrincipal* aPrincipal, bool aForceStripOA, nsresult& aResult) {
+PermissionManager::PermissionKey*
+PermissionManager::PermissionKey::CreateFromPrincipal(nsIPrincipal* aPrincipal,
+                                                      bool aForceStripOA,
+                                                      nsresult& aResult) {
   nsAutoCString origin;
   aResult = GetOriginFromPrincipal(aPrincipal, aForceStripOA, origin);
   if (NS_WARN_IF(NS_FAILED(aResult))) {
     return nullptr;
   }
 
   return new PermissionKey(origin);
 }
 
-nsPermissionManager::PermissionKey*
-nsPermissionManager::PermissionKey::CreateFromURIAndOriginAttributes(
+PermissionManager::PermissionKey*
+PermissionManager::PermissionKey::CreateFromURIAndOriginAttributes(
     nsIURI* aURI, const OriginAttributes* aOriginAttributes, bool aForceStripOA,
     nsresult& aResult) {
   nsAutoCString origin;
   aResult =
       GetOriginFromURIAndOA(aURI, aOriginAttributes, aForceStripOA, origin);
   if (NS_WARN_IF(NS_FAILED(aResult))) {
     return nullptr;
   }
 
   return new PermissionKey(origin);
 }
 
-nsPermissionManager::PermissionKey*
-nsPermissionManager::PermissionKey::CreateFromURI(nsIURI* aURI,
-                                                  nsresult& aResult) {
+PermissionManager::PermissionKey*
+PermissionManager::PermissionKey::CreateFromURI(nsIURI* aURI,
+                                                nsresult& aResult) {
   nsAutoCString origin;
   aResult = ContentPrincipal::GenerateOriginNoSuffixFromURI(aURI, origin);
   if (NS_WARN_IF(NS_FAILED(aResult))) {
     return nullptr;
   }
 
   return new PermissionKey(origin);
 }
 
 /* static */
-void nsPermissionManager::Startup() {
+void PermissionManager::Startup() {
   nsCOMPtr<nsIPermissionManager> permManager =
       do_GetService("@mozilla.org/permissionmanager;1");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsPermissionManager Implementation
+// PermissionManager Implementation
 
 #define PERMISSIONS_FILE_NAME "permissions.sqlite"
 #define HOSTS_SCHEMA_VERSION 11
 
 // Default permissions are read from a URL - this is the preference we read
 // to find that URL. If not set, don't use any default permissions.
 static const char kDefaultsUrlPrefName[] = "permissions.manager.defaultsUrl";
 
 static const char kPermissionChangeNotification[] = PERM_CHANGE_NOTIFICATION;
 
-NS_IMPL_ISUPPORTS(nsPermissionManager, nsIPermissionManager, nsIObserver,
+NS_IMPL_ISUPPORTS(PermissionManager, nsIPermissionManager, nsIObserver,
                   nsISupportsWeakReference)
 
-nsPermissionManager::nsPermissionManager()
-    : mMonitor("nsPermissionManager::mMonitor"),
+PermissionManager::PermissionManager()
+    : mMonitor("PermissionManager::mMonitor"),
       mState(eInitializing),
       mMemoryOnlyDB(false),
       mLargestID(0) {}
 
-nsPermissionManager::~nsPermissionManager() {
+PermissionManager::~PermissionManager() {
   // NOTE: Make sure to reject each of the promises in mPermissionKeyPromiseMap
   // before destroying.
   for (auto iter = mPermissionKeyPromiseMap.Iter(); !iter.Done(); iter.Next()) {
     if (iter.Data()) {
       iter.Data()->Reject(NS_ERROR_FAILURE, __func__);
     }
   }
   mPermissionKeyPromiseMap.Clear();
@@ -658,54 +660,52 @@ nsPermissionManager::~nsPermissionManage
 
   if (mThread) {
     mThread->Shutdown();
     mThread = nullptr;
   }
 }
 
 // static
-already_AddRefed<nsIPermissionManager>
-nsPermissionManager::GetXPCOMSingleton() {
+already_AddRefed<nsIPermissionManager> PermissionManager::GetXPCOMSingleton() {
   if (gPermissionManager) {
     return do_AddRef(gPermissionManager);
   }
 
-  // Create a new singleton nsPermissionManager.
+  // Create a new singleton PermissionManager.
   // We AddRef only once since XPCOM has rules about the ordering of module
   // teardowns - by the time our module destructor is called, it's too late to
   // Release our members, since GC cycles have already been completed and
   // would result in serious leaks.
   // See bug 209571.
-  auto permManager = MakeRefPtr<nsPermissionManager>();
+  auto permManager = MakeRefPtr<PermissionManager>();
   if (NS_SUCCEEDED(permManager->Init())) {
-    // Note: This is cleared in the nsPermissionManager destructor.
+    // Note: This is cleared in the PermissionManager destructor.
     gPermissionManager = permManager.get();
     ClearOnShutdown(&gPermissionManager);
     return permManager.forget();
   }
 
   return nullptr;
 }
 
 // static
-nsPermissionManager* nsPermissionManager::GetInstance() {
+PermissionManager* PermissionManager::GetInstance() {
   if (!gPermissionManager) {
     // Hand off the creation of the permission manager to GetXPCOMSingleton.
     nsCOMPtr<nsIPermissionManager> permManager = GetXPCOMSingleton();
   }
 
   return gPermissionManager;
 }
 
-nsresult nsPermissionManager::Init() {
+nsresult PermissionManager::Init() {
   // If the 'permissions.memory_only' pref is set to true, then don't write any
   // permission settings to disk, but keep them in a memory-only database.
-  mMemoryOnlyDB =
-      mozilla::Preferences::GetBool("permissions.memory_only", false);
+  mMemoryOnlyDB = Preferences::GetBool("permissions.memory_only", false);
 
   nsresult rv;
   nsCOMPtr<nsIPrefService> prefService =
       do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = prefService->GetBranch("permissions.default.",
                               getter_AddRefs(mDefaultPrefBranch));
@@ -713,18 +713,17 @@ nsresult nsPermissionManager::Init() {
 
   if (IsChildProcess()) {
     // Stop here; we don't need the DB in the child process. Instead we will be
     // sent permissions as we need them by our parent process.
     mState = eReady;
     return NS_OK;
   }
 
-  nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, "profile-before-change", true);
     observerService->AddObserver(this, "profile-do-change", true);
     observerService->AddObserver(this, "testonly-reload-permissions-from-disk",
                                  true);
   }
 
   AddIdleDailyMaintenanceJob();
@@ -739,17 +738,17 @@ nsresult nsPermissionManager::Init() {
 
   mThreadBoundData.Transfer(prThread);
 
   InitDB(false);
 
   return NS_OK;
 }
 
-nsresult nsPermissionManager::OpenDatabase(nsIFile* aPermissionsFile) {
+nsresult PermissionManager::OpenDatabase(nsIFile* aPermissionsFile) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ACCESS_THREAD_BOUND(mThreadBoundData, data);
 
   nsresult rv;
   nsCOMPtr<mozIStorageService> storage =
       do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID);
   if (!storage) {
     return NS_ERROR_UNEXPECTED;
@@ -758,17 +757,17 @@ nsresult nsPermissionManager::OpenDataba
   if (mMemoryOnlyDB) {
     rv = storage->OpenSpecialDatabase("memory", getter_AddRefs(data->mDBConn));
   } else {
     rv = storage->OpenDatabase(aPermissionsFile, getter_AddRefs(data->mDBConn));
   }
   return rv;
 }
 
-void nsPermissionManager::InitDB(bool aRemoveFile) {
+void PermissionManager::InitDB(bool aRemoveFile) {
   mState = eInitializing;
 
   {
     MonitorAutoLock lock(mMonitor);
     mReadEntries.Clear();
   }
 
   auto readyIfFailed = MakeScopeExit([&]() {
@@ -791,37 +790,37 @@ void nsPermissionManager::InitDB(bool aR
 
     rv = mPermissionsFile->AppendNative(
         NS_LITERAL_CSTRING(PERMISSIONS_FILE_NAME));
     NS_ENSURE_SUCCESS_VOID(rv);
   }
 
   nsCOMPtr<nsIInputStream> defaultsInputStream = GetDefaultsInputStream();
 
-  RefPtr<nsPermissionManager> self = this;
+  RefPtr<PermissionManager> self = this;
   mThread->Dispatch(NS_NewRunnableFunction(
-      "nsPermissionManager::InitDB", [self, aRemoveFile, defaultsInputStream] {
+      "PermissionManager::InitDB", [self, aRemoveFile, defaultsInputStream] {
         nsresult rv = self->TryInitDB(aRemoveFile, defaultsInputStream);
         Unused << NS_WARN_IF(NS_FAILED(rv));
 
         // This extra runnable calls EnsureReadCompleted to finialize the
         // initialization. If there is something blocked by the monitor, it will
         // be NOP.
         NS_DispatchToMainThread(
-            NS_NewRunnableFunction("nsPermissionManager::InitDB-MainThread",
+            NS_NewRunnableFunction("PermissionManager::InitDB-MainThread",
                                    [self] { self->EnsureReadCompleted(); }));
 
         self->mMonitor.Notify();
       }));
 
   readyIfFailed.release();
 }
 
-nsresult nsPermissionManager::TryInitDB(bool aRemoveFile,
-                                        nsIInputStream* aDefaultsInputStream) {
+nsresult PermissionManager::TryInitDB(bool aRemoveFile,
+                                      nsIInputStream* aDefaultsInputStream) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   MonitorAutoLock lock(mMonitor);
 
   auto raii = MakeScopeExit([&]() {
     if (aDefaultsInputStream) {
       aDefaultsInputStream->Close();
     }
@@ -842,18 +841,17 @@ nsresult nsPermissionManager::TryInitDB(
   }
 
   rv = OpenDatabase(mPermissionsFile);
   if (rv == NS_ERROR_FILE_CORRUPTED) {
     LogToConsole(
         NS_LITERAL_STRING("permissions.sqlite is corrupted! Try again!"));
 
     // Add telemetry probe
-    mozilla::Telemetry::Accumulate(
-        mozilla::Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
+    Telemetry::Accumulate(Telemetry::PERMISSIONS_SQL_CORRUPTED, 1);
 
     // delete corrupted permissions.sqlite and try again
     rv = mPermissionsFile->Remove(false);
     NS_ENSURE_SUCCESS(rv, rv);
     LogToConsole(
         NS_LITERAL_STRING("Corrupted permissions.sqlite has been removed."));
 
     rv = OpenDatabase(mPermissionsFile);
@@ -876,18 +874,17 @@ nsresult nsPermissionManager::TryInitDB(
 
     // delete and try again
     rv = mPermissionsFile->Remove(false);
     NS_ENSURE_SUCCESS(rv, rv);
     LogToConsole(
         NS_LITERAL_STRING("Defective permissions.sqlite has been removed."));
 
     // Add telemetry probe
-    mozilla::Telemetry::Accumulate(
-        mozilla::Telemetry::DEFECTIVE_PERMISSIONS_SQL_REMOVED, 1);
+    Telemetry::Accumulate(Telemetry::DEFECTIVE_PERMISSIONS_SQL_REMOVED, 1);
 
     rv = OpenDatabase(mPermissionsFile);
     NS_ENSURE_SUCCESS(rv, rv);
     LogToConsole(
         NS_LITERAL_STRING("OpenDatabase to permissions.sqlite is successful!"));
 
     data->mDBConn->GetConnectionReady(&ready);
     if (!ready) return NS_ERROR_UNEXPECTED;
@@ -1435,46 +1432,44 @@ nsresult nsPermissionManager::TryInitDB(
   if (tableExists) {
     rv = Read(lock);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
-void nsPermissionManager::AddIdleDailyMaintenanceJob() {
+void PermissionManager::AddIdleDailyMaintenanceJob() {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(observerService);
 
   nsresult rv =
       observerService->AddObserver(this, OBSERVER_TOPIC_IDLE_DAILY, false);
   NS_ENSURE_SUCCESS_VOID(rv);
 }
 
-void nsPermissionManager::RemoveIdleDailyMaintenanceJob() {
+void PermissionManager::RemoveIdleDailyMaintenanceJob() {
   MOZ_ASSERT(NS_IsMainThread());
 
-  nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
   NS_ENSURE_TRUE_VOID(observerService);
 
   nsresult rv =
       observerService->RemoveObserver(this, OBSERVER_TOPIC_IDLE_DAILY);
   NS_ENSURE_SUCCESS_VOID(rv);
 }
 
-void nsPermissionManager::PerformIdleDailyMaintenance() {
+void PermissionManager::PerformIdleDailyMaintenance() {
   MOZ_ASSERT(NS_IsMainThread());
 
-  RefPtr<nsPermissionManager> self = this;
+  RefPtr<PermissionManager> self = this;
   mThread->Dispatch(NS_NewRunnableFunction(
-      "nsPermissionManager::PerformIdleDailyMaintenance", [self] {
+      "PermissionManager::PerformIdleDailyMaintenance", [self] {
         MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
 
         if (self->mState == eClosed || !data->mDBConn) {
           return;
         }
 
         nsCOMPtr<mozIStorageStatement> stmtDeleteExpired;
         nsresult rv = data->mDBConn->CreateStatement(
@@ -1491,17 +1486,17 @@ void nsPermissionManager::PerformIdleDai
         NS_ENSURE_SUCCESS_VOID(rv);
 
         rv = stmtDeleteExpired->Execute();
         NS_ENSURE_SUCCESS_VOID(rv);
       }));
 }
 
 // sets the schema version and creates the moz_perms table.
-nsresult nsPermissionManager::CreateTable() {
+nsresult PermissionManager::CreateTable() {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ACCESS_THREAD_BOUND(mThreadBoundData, data);
 
   // set the schema version, before creating the table
   nsresult rv = data->mDBConn->SetSchemaVersion(HOSTS_SCHEMA_VERSION);
   if (NS_FAILED(rv)) return rv;
 
   // create the table
@@ -1530,21 +1525,20 @@ nsresult nsPermissionManager::CreateTabl
                          ",expireType INTEGER"
                          ",expireTime INTEGER"
                          ",modificationTime INTEGER"
                          ",isInBrowserElement INTEGER"
                          ")"));
 }
 
 NS_IMETHODIMP
-nsPermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
-                                      const nsACString& aType,
-                                      uint32_t aPermission,
-                                      uint32_t aExpireType,
-                                      int64_t aExpireTime) {
+PermissionManager::AddFromPrincipal(nsIPrincipal* aPrincipal,
+                                    const nsACString& aType,
+                                    uint32_t aPermission, uint32_t aExpireType,
+                                    int64_t aExpireTime) {
   ENSURE_NOT_CHILD_PROCESS;
   NS_ENSURE_ARG_POINTER(aPrincipal);
   NS_ENSURE_TRUE(aExpireType == nsIPermissionManager::EXPIRE_NEVER ||
                      aExpireType == nsIPermissionManager::EXPIRE_TIME ||
                      aExpireType == nsIPermissionManager::EXPIRE_SESSION ||
                      aExpireType == nsIPermissionManager::EXPIRE_POLICY,
                  NS_ERROR_INVALID_ARG);
 
@@ -1576,17 +1570,17 @@ nsPermissionManager::AddFromPrincipal(ns
 
   // A modificationTime of zero will cause AddInternal to use now().
   int64_t modificationTime = 0;
 
   return AddInternal(aPrincipal, aType, aPermission, 0, aExpireType,
                      aExpireTime, modificationTime, eNotify, eWriteToDB);
 }
 
-nsresult nsPermissionManager::AddInternal(
+nsresult PermissionManager::AddInternal(
     nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aPermission,
     int64_t aID, uint32_t aExpireType, int64_t aExpireTime,
     int64_t aModificationTime, NotifyOperationType aNotifyOperation,
     DBOperationType aDBOperation, const bool aIgnoreSessionPermissions,
     const nsACString* aOriginString) {
   MOZ_ASSERT(NS_IsMainThread());
 
   EnsureReadCompleted();
@@ -1877,18 +1871,18 @@ nsresult nsPermissionManager::AddInterna
 
     } break;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
-                                         const nsACString& aType) {
+PermissionManager::RemoveFromPrincipal(nsIPrincipal* aPrincipal,
+                                       const nsACString& aType) {
   ENSURE_NOT_CHILD_PROCESS;
   NS_ENSURE_ARG_POINTER(aPrincipal);
 
   // System principals are never added to the database, no need to remove them.
   if (aPrincipal->IsSystemPrincipal()) {
     return NS_OK;
   }
 
@@ -1899,17 +1893,17 @@ nsPermissionManager::RemoveFromPrincipal
 
   // AddInternal() handles removal, just let it do the work
   return AddInternal(aPrincipal, aType, nsIPermissionManager::UNKNOWN_ACTION, 0,
                      nsIPermissionManager::EXPIRE_NEVER, 0, 0, eNotify,
                      eWriteToDB);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemovePermission(nsIPermission* aPerm) {
+PermissionManager::RemovePermission(nsIPermission* aPerm) {
   if (!aPerm) {
     return NS_OK;
   }
   nsCOMPtr<nsIPrincipal> principal;
   nsresult rv = aPerm->GetPrincipal(getter_AddRefs(principal));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString type;
@@ -1917,29 +1911,29 @@ nsPermissionManager::RemovePermission(ns
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Permissions are uniquely identified by their principal and type.
   // We remove the permission using these two pieces of data.
   return RemoveFromPrincipal(principal, type);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemoveAll() {
+PermissionManager::RemoveAll() {
   ENSURE_NOT_CHILD_PROCESS;
   return RemoveAllInternal(true);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemoveAllSince(int64_t aSince) {
+PermissionManager::RemoveAllSince(int64_t aSince) {
   ENSURE_NOT_CHILD_PROCESS;
   return RemoveAllModifiedSince(aSince);
 }
 
 template <class T>
-nsresult nsPermissionManager::RemovePermissionEntries(T aCondition) {
+nsresult PermissionManager::RemovePermissionEntries(T aCondition) {
   Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> array;
   for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
     PermissionHashKey* entry = iter.Get();
     for (const auto& permEntry : entry->GetPermissions()) {
       if (!aCondition(permEntry)) {
         continue;
       }
 
@@ -1958,105 +1952,105 @@ nsresult nsPermissionManager::RemovePerm
       }
     }
   }
 
   for (auto& i : array) {
     // AddInternal handles removal, so let it do the work...
     AddInternal(Get<0>(i), Get<1>(i), nsIPermissionManager::UNKNOWN_ACTION, 0,
                 nsIPermissionManager::EXPIRE_NEVER, 0, 0,
-                nsPermissionManager::eNotify, nsPermissionManager::eWriteToDB,
+                PermissionManager::eNotify, PermissionManager::eWriteToDB,
                 false, &Get<2>(i));
   }
 
   // now re-import any defaults as they may now be required if we just deleted
   // an override.
   ImportLatestDefaults();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemoveByType(const nsACString& aType) {
+PermissionManager::RemoveByType(const nsACString& aType) {
   ENSURE_NOT_CHILD_PROCESS;
 
   int32_t typeIndex = GetTypeIndex(aType, false);
   // If type == -1, the type isn't known,
   // so just return NS_OK
   if (typeIndex == -1) {
     return NS_OK;
   }
 
   return RemovePermissionEntries(
       [typeIndex](const PermissionEntry& aPermEntry) {
         return static_cast<uint32_t>(typeIndex) == aPermEntry.mType;
       });
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemoveByTypeSince(const nsACString& aType,
-                                       int64_t aModificationTime) {
+PermissionManager::RemoveByTypeSince(const nsACString& aType,
+                                     int64_t aModificationTime) {
   ENSURE_NOT_CHILD_PROCESS;
 
   int32_t typeIndex = GetTypeIndex(aType, false);
   // If type == -1, the type isn't known,
   // so just return NS_OK
   if (typeIndex == -1) {
     return NS_OK;
   }
 
   return RemovePermissionEntries(
       [typeIndex, aModificationTime](const PermissionEntry& aPermEntry) {
         return uint32_t(typeIndex) == aPermEntry.mType &&
                aModificationTime <= aPermEntry.mModificationTime;
       });
 }
 
-void nsPermissionManager::CloseDB(bool aRebuildOnSuccess) {
+void PermissionManager::CloseDB(bool aRebuildOnSuccess) {
   EnsureReadCompleted();
 
   mState = eClosed;
 
   nsCOMPtr<nsIInputStream> defaultsInputStream;
   if (aRebuildOnSuccess) {
     defaultsInputStream = GetDefaultsInputStream();
   }
 
-  RefPtr<nsPermissionManager> self = this;
+  RefPtr<PermissionManager> self = this;
   mThread->Dispatch(NS_NewRunnableFunction(
-      "nsPermissionManager::CloseDB",
+      "PermissionManager::CloseDB",
       [self, aRebuildOnSuccess, defaultsInputStream] {
         MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
         // Null the statements, this will finalize them.
         data->mStmtInsert = nullptr;
         data->mStmtDelete = nullptr;
         data->mStmtUpdate = nullptr;
         if (data->mDBConn) {
-          mozilla::DebugOnly<nsresult> rv = data->mDBConn->Close();
+          DebugOnly<nsresult> rv = data->mDBConn->Close();
           MOZ_ASSERT(NS_SUCCEEDED(rv));
           data->mDBConn = nullptr;
 
           if (aRebuildOnSuccess) {
             self->TryInitDB(true, defaultsInputStream);
           }
         }
       }));
 }
 
-nsresult nsPermissionManager::RemoveAllFromIPC() {
+nsresult PermissionManager::RemoveAllFromIPC() {
   MOZ_ASSERT(IsChildProcess());
 
   // Remove from memory and notify immediately. Since the in-memory
   // database is authoritative, we do not need confirmation from the
   // on-disk database to notify observers.
   RemoveAllFromMemory();
 
   return NS_OK;
 }
 
-nsresult nsPermissionManager::RemoveAllInternal(bool aNotifyObservers) {
+nsresult PermissionManager::RemoveAllInternal(bool aNotifyObservers) {
   ENSURE_NOT_CHILD_PROCESS;
 
   EnsureReadCompleted();
 
   // Let's broadcast the removeAll() to any content process.
   nsTArray<ContentParent*> parents;
   ContentParent::GetAll(parents);
   for (ContentParent* parent : parents) {
@@ -2070,78 +2064,78 @@ nsresult nsPermissionManager::RemoveAllI
 
   // Re-import the defaults
   ImportLatestDefaults();
 
   if (aNotifyObservers) {
     NotifyObservers(nullptr, u"cleared");
   }
 
-  RefPtr<nsPermissionManager> self = this;
+  RefPtr<PermissionManager> self = this;
   mThread->Dispatch(
-      NS_NewRunnableFunction("nsPermissionManager::RemoveAllInternal", [self] {
+      NS_NewRunnableFunction("PermissionManager::RemoveAllInternal", [self] {
         MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
 
         if (self->mState == eClosed || !data->mDBConn) {
           return;
         }
 
         // clear the db
         nsresult rv = data->mDBConn->ExecuteSimpleSQL(
             NS_LITERAL_CSTRING("DELETE FROM moz_perms"));
         if (NS_WARN_IF(NS_FAILED(rv))) {
           NS_DispatchToMainThread(NS_NewRunnableFunction(
-              "nsPermissionManager::RemoveAllInternal-Failure",
+              "PermissionManager::RemoveAllInternal-Failure",
               [self] { self->CloseDB(true); }));
         }
       }));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::TestExactPermissionFromPrincipal(nsIPrincipal* aPrincipal,
-                                                      const nsACString& aType,
-                                                      uint32_t* aPermission) {
+PermissionManager::TestExactPermissionFromPrincipal(nsIPrincipal* aPrincipal,
+                                                    const nsACString& aType,
+                                                    uint32_t* aPermission) {
   return CommonTestPermission(aPrincipal, -1, aType, aPermission,
                               nsIPermissionManager::UNKNOWN_ACTION, false, true,
                               true);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::TestExactPermanentPermission(nsIPrincipal* aPrincipal,
-                                                  const nsACString& aType,
-                                                  uint32_t* aPermission) {
+PermissionManager::TestExactPermanentPermission(nsIPrincipal* aPrincipal,
+                                                const nsACString& aType,
+                                                uint32_t* aPermission) {
   return CommonTestPermission(aPrincipal, -1, aType, aPermission,
                               nsIPermissionManager::UNKNOWN_ACTION, false, true,
                               false);
 }
 
-nsresult nsPermissionManager::LegacyTestPermissionFromURI(
-    nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
+nsresult PermissionManager::LegacyTestPermissionFromURI(
+    nsIURI* aURI, const OriginAttributes* aOriginAttributes,
     const nsACString& aType, uint32_t* aPermission) {
   return CommonTestPermission(aURI, aOriginAttributes, -1, aType, aPermission,
                               nsIPermissionManager::UNKNOWN_ACTION, false,
                               false, true);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::TestPermissionFromPrincipal(nsIPrincipal* aPrincipal,
-                                                 const nsACString& aType,
-                                                 uint32_t* aPermission) {
+PermissionManager::TestPermissionFromPrincipal(nsIPrincipal* aPrincipal,
+                                               const nsACString& aType,
+                                               uint32_t* aPermission) {
   return CommonTestPermission(aPrincipal, -1, aType, aPermission,
                               nsIPermissionManager::UNKNOWN_ACTION, false,
                               false, true);
 }
 
 NS_IMETHODIMP
-nsPermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
-                                         const nsACString& aType,
-                                         bool aExactHostMatch,
-                                         nsIPermission** aResult) {
+PermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
+                                       const nsACString& aType,
+                                       bool aExactHostMatch,
+                                       nsIPermission** aResult) {
   NS_ENSURE_ARG_POINTER(aPrincipal);
   *aResult = nullptr;
 
   EnsureReadCompleted();
 
   if (aPrincipal->IsSystemPrincipal()) {
     return NS_OK;
   }
@@ -2183,35 +2177,34 @@ nsPermissionManager::GetPermissionObject
       perm.mExpireTime, perm.mModificationTime);
   if (NS_WARN_IF(!r)) {
     return NS_ERROR_FAILURE;
   }
   r.forget(aResult);
   return NS_OK;
 }
 
-nsresult nsPermissionManager::CommonTestPermissionInternal(
+nsresult PermissionManager::CommonTestPermissionInternal(
     nsIPrincipal* aPrincipal, nsIURI* aURI,
     const OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
     const nsACString& aType, uint32_t* aPermission, bool aExactHostMatch,
     bool aIncludingSession) {
   MOZ_ASSERT(aPrincipal || aURI);
   NS_ENSURE_ARG_POINTER(aPrincipal || aURI);
   MOZ_ASSERT_IF(aPrincipal, !aURI && !aOriginAttributes);
   MOZ_ASSERT_IF(aURI || aOriginAttributes, !aPrincipal);
 
   EnsureReadCompleted();
 
 #ifdef DEBUG
   {
     nsCOMPtr<nsIPrincipal> prin = aPrincipal;
     if (!prin) {
       if (aURI) {
-        prin = mozilla::BasePrincipal::CreateContentPrincipal(
-            aURI, OriginAttributes());
+        prin = BasePrincipal::CreateContentPrincipal(aURI, OriginAttributes());
       }
     }
     MOZ_ASSERT(prin);
     MOZ_ASSERT(PermissionAvailable(prin, aType));
   }
 #endif
 
   PermissionHashKey* entry =
@@ -2231,20 +2224,18 @@ nsresult nsPermissionManager::CommonTest
   return NS_OK;
 }
 
 // Returns PermissionHashKey for a given { host, isInBrowserElement }
 // tuple. This is not simply using PermissionKey because we will walk-up domains
 // in case of |host| contains sub-domains. Returns null if nothing found. Also
 // accepts host on the format "<foo>". This will perform an exact match lookup
 // as the string doesn't contain any dots.
-nsPermissionManager::PermissionHashKey*
-nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal,
-                                          uint32_t aType,
-                                          bool aExactHostMatch) {
+PermissionManager::PermissionHashKey* PermissionManager::GetPermissionHashKey(
+    nsIPrincipal* aPrincipal, uint32_t aType, bool aExactHostMatch) {
   EnsureReadCompleted();
 
   MOZ_ASSERT(PermissionAvailable(aPrincipal, mTypeArray[aType]));
 
   nsresult rv;
   RefPtr<PermissionKey> key = PermissionKey::CreateFromPrincipal(
       aPrincipal, IsOAForceStripPermission(mTypeArray[aType]), rv);
   if (!key) {
@@ -2286,18 +2277,17 @@ nsPermissionManager::GetPermissionHashKe
   return nullptr;
 }
 
 // Returns PermissionHashKey for a given { host, isInBrowserElement }
 // tuple. This is not simply using PermissionKey because we will walk-up domains
 // in case of |host| contains sub-domains. Returns null if nothing found. Also
 // accepts host on the format "<foo>". This will perform an exact match lookup
 // as the string doesn't contain any dots.
-nsPermissionManager::PermissionHashKey*
-nsPermissionManager::GetPermissionHashKey(
+PermissionManager::PermissionHashKey* PermissionManager::GetPermissionHashKey(
     nsIURI* aURI, const OriginAttributes* aOriginAttributes, uint32_t aType,
     bool aExactHostMatch) {
   MOZ_ASSERT(aURI);
 
 #ifdef DEBUG
   {
     nsCOMPtr<nsIPrincipal> principal;
     nsresult rv = NS_OK;
@@ -2367,27 +2357,27 @@ nsPermissionManager::GetPermissionHashKe
                                   aExactHostMatch);
     }
   }
 
   // No entry, really...
   return nullptr;
 }
 
-NS_IMETHODIMP nsPermissionManager::GetAll(
+NS_IMETHODIMP PermissionManager::GetAll(
     nsTArray<RefPtr<nsIPermission>>& aResult) {
   return GetAllWithTypePrefix(NS_LITERAL_CSTRING(""), aResult);
 }
 
-NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(
+NS_IMETHODIMP PermissionManager::GetAllWithTypePrefix(
     const nsACString& aPrefix, nsTArray<RefPtr<nsIPermission>>& aResult) {
   aResult.Clear();
   if (XRE_IsContentProcess()) {
     NS_WARNING(
-        "nsPermissionManager's getAllWithTypePrefix is not available in the "
+        "PermissionManager's getAllWithTypePrefix is not available in the "
         "content process, as not all permissions may be available.");
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   EnsureReadCompleted();
 
   for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
     PermissionHashKey* entry = iter.Get();
@@ -2422,17 +2412,17 @@ NS_IMETHODIMP nsPermissionManager::GetAl
       }
       aResult.AppendElement(std::move(permission));
     }
   }
 
   return NS_OK;
 }
 
-nsresult nsPermissionManager::GetStripPermsForPrincipal(
+nsresult PermissionManager::GetStripPermsForPrincipal(
     nsIPrincipal* aPrincipal, nsTArray<PermissionEntry>& aResult) {
   aResult.Clear();
   aResult.SetCapacity(kStripOAPermissions.size());
 
   // No special strip permissions
   if (kStripOAPermissions.empty()) {
     return NS_OK;
   }
@@ -2462,17 +2452,17 @@ nsresult nsPermissionManager::GetStripPe
     }
     aResult.AppendElement(perm);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::GetAllForPrincipal(
+PermissionManager::GetAllForPrincipal(
     nsIPrincipal* aPrincipal, nsTArray<RefPtr<nsIPermission>>& aResult) {
   aResult.Clear();
 
   MOZ_ASSERT(PermissionAvailable(aPrincipal, EmptyCString()));
 
   nsresult rv;
   RefPtr<PermissionKey> key =
       PermissionKey::CreateFromPrincipal(aPrincipal, false, rv);
@@ -2527,19 +2517,19 @@ nsPermissionManager::GetAllForPrincipal(
       continue;
     }
     aResult.AppendElement(permission);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPermissionManager::Observe(nsISupports* aSubject,
-                                           const char* aTopic,
-                                           const char16_t* someData) {
+NS_IMETHODIMP PermissionManager::Observe(nsISupports* aSubject,
+                                         const char* aTopic,
+                                         const char16_t* someData) {
   ENSURE_NOT_CHILD_PROCESS;
 
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
     // The profile is about to change,
     // or is going away because the application is shutting down.
     RemoveIdleDailyMaintenanceJob();
     RemoveAllFromMemory();
     CloseDB(false);
@@ -2559,40 +2549,38 @@ NS_IMETHODIMP nsPermissionManager::Obser
     InitDB(false);
   } else if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY)) {
     PerformIdleDailyMaintenance();
   }
 
   return NS_OK;
 }
 
-nsresult nsPermissionManager::RemoveAllModifiedSince(
-    int64_t aModificationTime) {
+nsresult PermissionManager::RemoveAllModifiedSince(int64_t aModificationTime) {
   ENSURE_NOT_CHILD_PROCESS;
 
   return RemovePermissionEntries(
       [aModificationTime](const PermissionEntry& aPermEntry) {
         return aModificationTime <= aPermEntry.mModificationTime;
       });
 }
 
 NS_IMETHODIMP
-nsPermissionManager::RemovePermissionsWithAttributes(
-    const nsAString& aPattern) {
+PermissionManager::RemovePermissionsWithAttributes(const nsAString& aPattern) {
   ENSURE_NOT_CHILD_PROCESS;
-  mozilla::OriginAttributesPattern pattern;
+  OriginAttributesPattern pattern;
   if (!pattern.Init(aPattern)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   return RemovePermissionsWithAttributes(pattern);
 }
 
-nsresult nsPermissionManager::RemovePermissionsWithAttributes(
-    mozilla::OriginAttributesPattern& aPattern) {
+nsresult PermissionManager::RemovePermissionsWithAttributes(
+    OriginAttributesPattern& aPattern) {
   Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> permissions;
   for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
     PermissionHashKey* entry = iter.Get();
 
     nsCOMPtr<nsIPrincipal> principal;
     nsresult rv = GetPrincipalFromOrigin(entry->GetKey()->mOrigin, false,
                                          getter_AddRefs(principal));
     if (NS_FAILED(rv)) {
@@ -2609,64 +2597,63 @@ nsresult nsPermissionManager::RemovePerm
         continue;
       }
     }
   }
 
   for (auto& i : permissions) {
     AddInternal(Get<0>(i), Get<1>(i), nsIPermissionManager::UNKNOWN_ACTION, 0,
                 nsIPermissionManager::EXPIRE_NEVER, 0, 0,
-                nsPermissionManager::eNotify, nsPermissionManager::eWriteToDB,
+                PermissionManager::eNotify, PermissionManager::eWriteToDB,
                 false, &Get<2>(i));
   }
 
   return NS_OK;
 }
 
 //*****************************************************************************
-//*** nsPermissionManager private methods
+//*** PermissionManager private methods
 //*****************************************************************************
 
-nsresult nsPermissionManager::RemoveAllFromMemory() {
+nsresult PermissionManager::RemoveAllFromMemory() {
   mLargestID = 0;
   mTypeArray.clear();
   mPermissionTable.Clear();
 
   return NS_OK;
 }
 
 // wrapper function for mangling (host,type,perm,expireType,expireTime)
 // set into an nsIPermission.
-void nsPermissionManager::NotifyObserversWithPermission(
+void PermissionManager::NotifyObserversWithPermission(
     nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aPermission,
     uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
     const char16_t* aData) {
   nsCOMPtr<nsIPermission> permission =
       Permission::Create(aPrincipal, aType, aPermission, aExpireType,
                          aExpireTime, aModificationTime);
   if (permission) NotifyObservers(permission, aData);
 }
 
 // notify observers that the permission list changed. there are four possible
 // values for aData:
 // "deleted" means a permission was deleted. aPermission is the deleted
 // permission. "added"   means a permission was added. aPermission is the added
 // permission. "changed" means a permission was altered. aPermission is the new
 // permission. "cleared" means the entire permission list was cleared.
 // aPermission is null.
-void nsPermissionManager::NotifyObservers(nsIPermission* aPermission,
-                                          const char16_t* aData) {
-  nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+void PermissionManager::NotifyObservers(nsIPermission* aPermission,
+                                        const char16_t* aData) {
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
   if (observerService)
     observerService->NotifyObservers(aPermission, kPermissionChangeNotification,
                                      aData);
 }
 
-nsresult nsPermissionManager::Read(const MonitorAutoLock& aProofOfLock) {
+nsresult PermissionManager::Read(const MonitorAutoLock& aProofOfLock) {
   ENSURE_NOT_CHILD_PROCESS;
 
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ACCESS_THREAD_BOUND(mThreadBoundData, data);
 
   nsresult rv;
 
   nsCOMPtr<mozIStorageStatement> stmt;
@@ -2722,17 +2709,17 @@ nsresult nsPermissionManager::Read(const
   if (readError) {
     NS_ERROR("Error occured while reading the permissions database!");
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
-void nsPermissionManager::CompleteMigrations() {
+void PermissionManager::CompleteMigrations() {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == eReady);
 
   nsresult rv;
 
   nsTArray<MigrationEntry> entries;
   {
     MonitorAutoLock lock(mMonitor);
@@ -2750,17 +2737,17 @@ void nsPermissionManager::CompleteMigrat
                                          aExpireType, aExpireTime,
                                          aModificationTime, entry.mId);
           return NS_OK;
         });
     Unused << NS_WARN_IF(NS_FAILED(rv));
   }
 }
 
-void nsPermissionManager::CompleteRead() {
+void PermissionManager::CompleteRead() {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == eReady);
 
   nsresult rv;
 
   nsTArray<ReadEntry> entries;
   {
     MonitorAutoLock lock(mMonitor);
@@ -2781,17 +2768,17 @@ void nsPermissionManager::CompleteRead()
     rv = AddInternal(principal, entry.mType, entry.mPermission, entry.mId,
                      entry.mExpireType, entry.mExpireTime,
                      entry.mModificationTime, eDontNotify, op, false,
                      &entry.mOrigin);
     Unused << NS_WARN_IF(NS_FAILED(rv));
   }
 }
 
-void nsPermissionManager::MaybeAddReadEntryFromMigration(
+void PermissionManager::MaybeAddReadEntryFromMigration(
     const nsACString& aOrigin, const nsCString& aType, uint32_t aPermission,
     uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
     int64_t aId) {
   MonitorAutoLock lock(mMonitor);
 
   // We convert a migration to a ReadEntry only if we don't have an existing
   // ReadEntry for the same origin + type.
   for (const ReadEntry& entry : mReadEntries) {
@@ -2811,33 +2798,32 @@ void nsPermissionManager::MaybeAddReadEn
   entry.mFromMigration = true;
 
   mReadEntries.AppendElement(entry);
 }
 
 static const char kMatchTypeHost[] = "host";
 static const char kMatchTypeOrigin[] = "origin";
 
-void nsPermissionManager::UpdateDB(OperationType aOp, int64_t aID,
-                                   const nsACString& aOrigin,
-                                   const nsACString& aType,
-                                   uint32_t aPermission, uint32_t aExpireType,
-                                   int64_t aExpireTime,
-                                   int64_t aModificationTime) {
+void PermissionManager::UpdateDB(OperationType aOp, int64_t aID,
+                                 const nsACString& aOrigin,
+                                 const nsACString& aType, uint32_t aPermission,
+                                 uint32_t aExpireType, int64_t aExpireTime,
+                                 int64_t aModificationTime) {
   ENSURE_NOT_CHILD_PROCESS_NORET;
 
   MOZ_ASSERT(NS_IsMainThread());
   EnsureReadCompleted();
 
   nsCString origin(aOrigin);
   nsCString type(aType);
 
-  RefPtr<nsPermissionManager> self = this;
+  RefPtr<PermissionManager> self = this;
   mThread->Dispatch(NS_NewRunnableFunction(
-      "nsPermissionManager::UpdateDB",
+      "PermissionManager::UpdateDB",
       [self, aOp, aID, origin, type, aPermission, aExpireType, aExpireTime,
        aModificationTime] {
         nsresult rv;
 
         MOZ_ACCESS_THREAD_BOUND(self->mThreadBoundData, data);
 
         if (self->mState == eClosed || !data->mDBConn) {
           // no statement is ok - just means we don't have a profile
@@ -2908,17 +2894,17 @@ void nsPermissionManager::UpdateDB(Opera
           return;
         }
 
         rv = stmt->Execute();
         MOZ_ASSERT(NS_SUCCEEDED(rv));
       }));
 }
 
-bool nsPermissionManager::GetPermissionsFromOriginOrKey(
+bool PermissionManager::GetPermissionsFromOriginOrKey(
     const nsACString& aOrigin, const nsACString& aKey,
     nsTArray<IPC::Permission>& aPerms) {
   EnsureReadCompleted();
 
   aPerms.Clear();
   if (NS_WARN_IF(XRE_IsContentProcess())) {
     return false;
   }
@@ -2968,17 +2954,17 @@ bool nsPermissionManager::GetPermissions
                             permEntry.mExpireType, permEntry.mExpireTime));
       }
     }
   }
 
   return true;
 }
 
-void nsPermissionManager::SetPermissionsWithKey(
+void PermissionManager::SetPermissionsWithKey(
     const nsACString& aPermissionKey, nsTArray<IPC::Permission>& aPerms) {
   if (NS_WARN_IF(XRE_IsParentProcess())) {
     return;
   }
 
   RefPtr<GenericNonExclusivePromise::Private> promise;
   bool foundKey =
       mPermissionKeyPromiseMap.Get(aPermissionKey, getter_AddRefs(promise));
@@ -3019,19 +3005,18 @@ void nsPermissionManager::SetPermissions
     uint64_t modificationTime = 0;
     AddInternal(principal, perm.type, perm.capability, 0, perm.expireType,
                 perm.expireTime, modificationTime, eNotify, eNoDBOperation,
                 true /* ignoreSessionPermissions */);
   }
 }
 
 /* static */
-void nsPermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
-                                          bool aForceStripOA,
-                                          nsACString& aKey) {
+void PermissionManager::GetKeyForOrigin(const nsACString& aOrigin,
+                                        bool aForceStripOA, nsACString& aKey) {
   aKey.Truncate();
 
   // We only key origins for http, https, and ftp URIs. All origins begin with
   // the URL which they apply to, which means that they should begin with their
   // scheme in the case where they are one of these interesting URIs. We don't
   // want to actually parse the URL here however, because this can be called on
   // hot paths.
   if (!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("http:")) &&
@@ -3064,44 +3049,44 @@ void nsPermissionManager::GetKeyForOrigi
 
   // Append the stripped suffix to the output origin key.
   nsAutoCString suffix;
   attrs.CreateSuffix(suffix);
   aKey.Append(suffix);
 }
 
 /* static */
-void nsPermissionManager::GetKeyForPrincipal(nsIPrincipal* aPrincipal,
-                                             bool aForceStripOA,
-                                             nsACString& aKey) {
+void PermissionManager::GetKeyForPrincipal(nsIPrincipal* aPrincipal,
+                                           bool aForceStripOA,
+                                           nsACString& aKey) {
   nsAutoCString origin;
   nsresult rv = aPrincipal->GetOrigin(origin);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aKey.Truncate();
     return;
   }
   GetKeyForOrigin(origin, aForceStripOA, aKey);
 }
 
 /* static */
-void nsPermissionManager::GetKeyForPermission(nsIPrincipal* aPrincipal,
-                                              const nsACString& aType,
-                                              nsACString& aKey) {
+void PermissionManager::GetKeyForPermission(nsIPrincipal* aPrincipal,
+                                            const nsACString& aType,
+                                            nsACString& aKey) {
   // Preload permissions have the "" key.
   if (IsPreloadPermission(aType)) {
     aKey.Truncate();
     return;
   }
 
   GetKeyForPrincipal(aPrincipal, IsOAForceStripPermission(aType), aKey);
 }
 
 /* static */
 nsTArray<std::pair<nsCString, nsCString>>
-nsPermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
+PermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
   MOZ_ASSERT(aPrincipal);
 
   nsTArray<std::pair<nsCString, nsCString>> pairs;
   nsCOMPtr<nsIPrincipal> prin = aPrincipal;
   while (prin) {
     // Add the pair to the list
     std::pair<nsCString, nsCString>* pair =
         pairs.AppendElement(std::make_pair(EmptyCString(), EmptyCString()));
@@ -3116,30 +3101,30 @@ nsPermissionManager::GetAllKeysForPrinci
   }
 
   MOZ_ASSERT(pairs.Length() >= 1,
              "Every principal should have at least one pair item.");
   return pairs;
 }
 
 NS_IMETHODIMP
-nsPermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(
+PermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(
     nsIPrincipal* aPrincipal) {
   nsTArray<ContentParent*> cps;
   ContentParent::GetAll(cps);
   for (ContentParent* cp : cps) {
     nsresult rv = cp->TransmitPermissionsForPrincipal(aPrincipal);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
-bool nsPermissionManager::PermissionAvailable(nsIPrincipal* aPrincipal,
-                                              const nsACString& aType) {
+bool PermissionManager::PermissionAvailable(nsIPrincipal* aPrincipal,
+                                            const nsACString& aType) {
   EnsureReadCompleted();
 
   if (XRE_IsContentProcess()) {
     nsAutoCString permissionKey;
     // NOTE: GetKeyForPermission accepts a null aType.
     GetKeyForPermission(aPrincipal, aType, permissionKey);
 
     // If we have a pending promise for the permission key in question, we don't
@@ -3154,18 +3139,18 @@ bool nsPermissionManager::PermissionAvai
                                  permissionKey.get())
                      .get());
       return false;
     }
   }
   return true;
 }
 
-void nsPermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
-                                                   nsIRunnable* aRunnable) {
+void PermissionManager::WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
+                                                 nsIRunnable* aRunnable) {
   MOZ_ASSERT(aRunnable);
 
   if (!XRE_IsContentProcess()) {
     aRunnable->Run();
     return;
   }
 
   nsTArray<RefPtr<GenericNonExclusivePromise>> promises;
@@ -3196,22 +3181,22 @@ void nsPermissionManager::WhenPermission
   auto* thread = AbstractThread::MainThread();
 
   RefPtr<nsIRunnable> runnable = aRunnable;
   GenericNonExclusivePromise::All(thread, promises)
       ->Then(
           thread, __func__, [runnable]() { runnable->Run(); },
           []() {
             NS_WARNING(
-                "nsPermissionManager permission promise rejected. We're "
+                "PermissionManager permission promise rejected. We're "
                 "probably shutting down.");
           });
 }
 
-void nsPermissionManager::EnsureReadCompleted() {
+void PermissionManager::EnsureReadCompleted() {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mState == eInitializing) {
     MonitorAutoLock lock(mMonitor);
 
     while (mState == eInitializing) {
       mMonitor.Wait();
     }
@@ -3236,21 +3221,21 @@ void nsPermissionManager::EnsureReadComp
     case eClosed:
       return;
 
     default:
       MOZ_CRASH("Invalid state");
   }
 }
 
-already_AddRefed<nsIInputStream> nsPermissionManager::GetDefaultsInputStream() {
+already_AddRefed<nsIInputStream> PermissionManager::GetDefaultsInputStream() {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoCString defaultsURL;
-  mozilla::Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
+  Preferences::GetCString(kDefaultsUrlPrefName, defaultsURL);
   if (defaultsURL.IsEmpty()) {  // == Don't use built-in permissions.
     return nullptr;
   }
 
   nsCOMPtr<nsIURI> defaultsURI;
   nsresult rv = NS_NewURI(getter_AddRefs(defaultsURI), defaultsURL);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
@@ -3263,17 +3248,17 @@ already_AddRefed<nsIInputStream> nsPermi
 
   nsCOMPtr<nsIInputStream> inputStream;
   rv = channel->Open(getter_AddRefs(inputStream));
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return inputStream.forget();
 }
 
-void nsPermissionManager::ConsumeDefaultsInputStream(
+void PermissionManager::ConsumeDefaultsInputStream(
     nsIInputStream* aInputStream, const MonitorAutoLock& aProofOfLock) {
   MOZ_ASSERT(!NS_IsMainThread());
 
   mDefaultEntries.Clear();
 
   if (!aInputStream) {
     return;
   }
@@ -3333,17 +3318,17 @@ void nsPermissionManager::ConsumeDefault
     entry->mPermission = permission;
     entry->mHostOrOrigin = lineArray[3];
     entry->mType = lineArray[1];
   } while (isMore);
 }
 
 // ImportLatestDefaults will import the latest default cookies read during the
 // last DB initialization.
-nsresult nsPermissionManager::ImportLatestDefaults() {
+nsresult PermissionManager::ImportLatestDefaults() {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mState == eReady);
 
   nsresult rv;
 
   MonitorAutoLock lock(mMonitor);
 
   for (const DefaultEntry& entry : mDefaultEntries) {
@@ -3359,22 +3344,21 @@ nsresult nsPermissionManager::ImportLate
               uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
               int64_t aModificationTime) {
             nsCOMPtr<nsIPrincipal> principal;
             nsresult rv =
                 GetPrincipalFromOrigin(aOrigin, IsOAForceStripPermission(aType),
                                        getter_AddRefs(principal));
             NS_ENSURE_SUCCESS(rv, rv);
 
-            return AddInternal(principal, aType, aPermission,
-                               nsPermissionManager::cIDPermissionIsDefault,
-                               aExpireType, aExpireTime, aModificationTime,
-                               nsPermissionManager::eDontNotify,
-                               nsPermissionManager::eNoDBOperation, false,
-                               &aOrigin);
+            return AddInternal(
+                principal, aType, aPermission,
+                PermissionManager::cIDPermissionIsDefault, aExpireType,
+                aExpireTime, aModificationTime, PermissionManager::eDontNotify,
+                PermissionManager::eNoDBOperation, false, &aOrigin);
           });
 
       if (NS_FAILED(rv)) {
         NS_WARNING("There was a problem importing a host permission");
       }
       continue;
     }
 
@@ -3424,40 +3408,38 @@ nsresult nsPermissionManager::ImportLate
  *                           determine the result of the permission check.
  * @param aDefaultPermissionIsValid whether the previous argument contains a
  *                                  valid value.
  * @param aExactHostMatch whether to look for the exact host name or also for
  *                        subdomains that can have the same permission.
  * @param aIncludingSession whether to include session permissions when
  *                          testing for the permission.
  */
-nsPermissionManager::TestPreparationResult
-nsPermissionManager::CommonPrepareToTestPermission(
+PermissionManager::TestPreparationResult
+PermissionManager::CommonPrepareToTestPermission(
     nsIPrincipal* aPrincipal, int32_t aTypeIndex, const nsACString& aType,
     uint32_t* aPermission, uint32_t aDefaultPermission,
     bool aDefaultPermissionIsValid, bool aExactHostMatch,
     bool aIncludingSession) {
-  using mozilla::AsVariant;
-
-  auto* basePrin = mozilla::BasePrincipal::Cast(aPrincipal);
+  auto* basePrin = BasePrincipal::Cast(aPrincipal);
   if (basePrin && basePrin->IsSystemPrincipal()) {
     *aPermission = ALLOW_ACTION;
     return AsVariant(NS_OK);
   }
 
   EnsureReadCompleted();
 
   // For some permissions, query the default from a pref. We want to avoid
   // doing this for all permissions so that permissions can opt into having
   // the pref lookup overhead on each call.
   int32_t defaultPermission =
       aDefaultPermissionIsValid ? aDefaultPermission : UNKNOWN_ACTION;
   if (!aDefaultPermissionIsValid && HasDefaultPref(aType)) {
-    mozilla::Unused << mDefaultPrefBranch->GetIntPref(
-        PromiseFlatCString(aType).get(), &defaultPermission);
+    Unused << mDefaultPrefBranch->GetIntPref(PromiseFlatCString(aType).get(),
+                                             &defaultPermission);
   }
 
   // Set the default.
   *aPermission = defaultPermission;
 
   int32_t typeIndex =
       aTypeIndex == -1 ? GetTypeIndex(aType, false) : aTypeIndex;
 
@@ -3489,8 +3471,10 @@ nsPermissionManager::CommonPrepareToTest
 
   // If type == -1, the type isn't known, just signal that we are done.
   if (typeIndex == -1) {
     return AsVariant(NS_OK);
   }
 
   return AsVariant(typeIndex);
 }
+
+}  // namespace mozilla
rename from extensions/permissions/nsPermissionManager.h
rename to extensions/permissions/PermissionManager.h
--- a/extensions/permissions/nsPermissionManager.h
+++ b/extensions/permissions/PermissionManager.h
@@ -1,16 +1,16 @@
 /* -*- 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 nsPermissionManager_h__
-#define nsPermissionManager_h__
+#ifndef mozilla_PermissionManager_h
+#define mozilla_PermissionManager_h
 
 #include "nsIPermissionManager.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
 #include "nsIInputStream.h"
 #include "nsTHashtable.h"
 #include "nsTArray.h"
@@ -28,39 +28,37 @@
 #include "mozilla/MozPromise.h"
 #include "mozilla/ThreadBound.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Variant.h"
 #include "mozilla/Vector.h"
 
 #include <utility>
 
+class nsIPermission;
+class mozIStorageConnection;
+class mozIStorageStatement;
+
 namespace IPC {
 struct Permission;
 }
 
 namespace mozilla {
 class OriginAttributesPattern;
 
 namespace dom {
 class ContentChild;
-}
-
-}  // namespace mozilla
-
-class nsIPermission;
-class mozIStorageConnection;
-class mozIStorageStatement;
+}  // namespace dom
 
 ////////////////////////////////////////////////////////////////////////////////
 
-class nsPermissionManager final : public nsIPermissionManager,
-                                  public nsIObserver,
-                                  public nsSupportsWeakReference {
-  friend class mozilla::dom::ContentChild;
+class PermissionManager final : public nsIPermissionManager,
+                                public nsIObserver,
+                                public nsSupportsWeakReference {
+  friend class dom::ContentChild;
 
  public:
   class PermissionEntry {
    public:
     PermissionEntry(int64_t aID, uint32_t aType, uint32_t aPermission,
                     uint32_t aExpireType, int64_t aExpireTime,
                     int64_t aModificationTime)
         : mID(aID),
@@ -89,21 +87,21 @@ class nsPermissionManager final : public
    */
   class PermissionKey {
    public:
     static PermissionKey* CreateFromPrincipal(nsIPrincipal* aPrincipal,
                                               bool aForceStripOA,
                                               nsresult& aResult);
     static PermissionKey* CreateFromURI(nsIURI* aURI, nsresult& aResult);
     static PermissionKey* CreateFromURIAndOriginAttributes(
-        nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
+        nsIURI* aURI, const OriginAttributes* aOriginAttributes,
         bool aForceStripOA, nsresult& aResult);
 
     explicit PermissionKey(const nsACString& aOrigin)
-        : mOrigin(aOrigin), mHashCode(mozilla::HashString(aOrigin)) {}
+        : mOrigin(aOrigin), mHashCode(HashString(aOrigin)) {}
 
     bool operator==(const PermissionKey& aKey) const {
       return mOrigin.Equals(aKey.mOrigin);
     }
 
     PLDHashNumber GetHashCode() const { return mHashCode; }
 
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PermissionKey)
@@ -162,19 +160,19 @@ class nsPermissionManager final : public
     AutoTArray<PermissionEntry, 1> mPermissions;
   };
 
   // nsISupports
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPERMISSIONMANAGER
   NS_DECL_NSIOBSERVER
 
-  nsPermissionManager();
+  PermissionManager();
   static already_AddRefed<nsIPermissionManager> GetXPCOMSingleton();
-  static nsPermissionManager* GetInstance();
+  static PermissionManager* GetInstance();
   nsresult Init();
 
   // enums for AddInternal()
   enum OperationType {
     eOperationNone,
     eOperationAdding,
     eOperationRemoving,
     eOperationChanging,
@@ -198,30 +196,29 @@ class nsPermissionManager final : public
     MOZ_ASSERT(!HasDefaultPref(aType));
 
     return CommonTestPermission(aPrincipal, -1, aType, aPermission,
                                 nsIPermissionManager::UNKNOWN_ACTION, true,
                                 false, true);
   }
 
   nsresult LegacyTestPermissionFromURI(
-      nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
+      nsIURI* aURI, const OriginAttributes* aOriginAttributes,
       const nsACString& aType, uint32_t* aPermission);
 
   /**
    * Initialize the permission-manager service.
    * The permission manager is always initialized at startup because when it
    * was lazy-initialized on demand, it was possible for it to be created
    * once shutdown had begun, resulting in the manager failing to correctly
    * shutdown because it missed its shutdown observer notification.
    */
   static void Startup();
 
-  nsresult RemovePermissionsWithAttributes(
-      mozilla::OriginAttributesPattern& aAttrs);
+  nsresult RemovePermissionsWithAttributes(OriginAttributesPattern& aAttrs);
 
   /**
    * See `nsIPermissionManager::GetPermissionsWithKey` for more info on
    * permission keys.
    *
    * Get the permission key corresponding to the given Principal. This method is
    * intentionally infallible, as we want to provide an permission key to every
    * principal. Principals which don't have meaningful URIs with http://,
@@ -311,34 +308,34 @@ class nsPermissionManager final : public
   /**
    * The content process doesn't have access to every permission. Instead, when
    * LOAD_DOCUMENT_URI channels for http://, https://, and ftp:// URIs are
    * opened, the permissions for those channels are sent down to the content
    * process before the OnStartRequest message. Permissions for principals with
    * other schemes are sent down at process startup.
    *
    * Permissions are keyed and grouped by "Permission Key"s.
-   * `nsPermissionManager::GetKeyForPrincipal` provides the mechanism for
+   * `PermissionManager::GetKeyForPrincipal` provides the mechanism for
    * determining the permission key for a given principal.
    *
    * This method may only be called in the parent process. It fills the nsTArray
    * argument with the IPC::Permission objects which have a matching origin.
    *
    * @param origin The origin to use to find the permissions of interest.
    * @param key The key to use to find the permissions of interest. Only used
    *            when the origin argument is empty.
    * @param perms  An array which will be filled with the permissions which
    *               match the given origin.
    */
   bool GetPermissionsFromOriginOrKey(const nsACString& aOrigin,
                                      const nsACString& aKey,
                                      nsTArray<IPC::Permission>& aPerms);
 
   /**
-   * See `nsPermissionManager::GetPermissionsWithKey` for more info on
+   * See `PermissionManager::GetPermissionsWithKey` for more info on
    * Permission keys.
    *
    * `SetPermissionsWithKey` may only be called in the Child process, and
    * initializes the permission manager with the permissions for a given
    * Permission key. marking permissions with that key as available.
    *
    * @param permissionKey  The key for the permissions which have been sent
    * over.
@@ -362,17 +359,17 @@ class nsPermissionManager final : public
    * for.
    * @param aRunnable  The runnable to run when permissions are available for
    * the given principal.
    */
   void WhenPermissionsAvailable(nsIPrincipal* aPrincipal,
                                 nsIRunnable* aRunnable);
 
  private:
-  virtual ~nsPermissionManager();
+  ~PermissionManager();
 
   /**
    * Get all permissions for a given principal, which should not be isolated
    * by user context or private browsing. The principal has its origin
    * attributes stripped before perm db lookup. This is currently only affects
    * the "cookie" permission.
    * @param aPrincipal Used for creating the permission key.
    */
@@ -420,22 +417,22 @@ class nsPermissionManager final : public
     }
 
     return mTypeArray.length() - 1;
   }
 
   PermissionHashKey* GetPermissionHashKey(nsIPrincipal* aPrincipal,
                                           uint32_t aType, bool aExactHostMatch);
   PermissionHashKey* GetPermissionHashKey(
-      nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
-      uint32_t aType, bool aExactHostMatch);
+      nsIURI* aURI, const OriginAttributes* aOriginAttributes, uint32_t aType,
+      bool aExactHostMatch);
 
   // The int32_t is the type index, the nsresult is an early bail-out return
   // code.
-  typedef mozilla::Variant<int32_t, nsresult> TestPreparationResult;
+  typedef Variant<int32_t, nsresult> TestPreparationResult;
   TestPreparationResult CommonPrepareToTestPermission(
       nsIPrincipal* aPrincipal, int32_t aTypeIndex, const nsACString& aType,
       uint32_t* aPermission, uint32_t aDefaultPermission,
       bool aDefaultPermissionIsValid, bool aExactHostMatch,
       bool aIncludingSession);
 
   // If aTypeIndex is passed -1, we try to inder the type index from aType.
   nsresult CommonTestPermission(nsIPrincipal* aPrincipal, int32_t aTypeIndex,
@@ -466,52 +463,54 @@ class nsPermissionManager final : public
     if (preparationResult.is<nsresult>()) {
       return preparationResult.as<nsresult>();
     }
 
     return CommonTestPermissionInternal(
         nullptr, aURI, nullptr, preparationResult.as<int32_t>(), aType,
         aPermission, aExactHostMatch, aIncludingSession);
   }
-  nsresult CommonTestPermission(
-      nsIURI* aURI, const mozilla::OriginAttributes* aOriginAttributes,
-      int32_t aTypeIndex, const nsACString& aType, uint32_t* aPermission,
-      uint32_t aDefaultPermission, bool aDefaultPermissionIsValid,
-      bool aExactHostMatch, bool aIncludingSession) {
+  nsresult CommonTestPermission(nsIURI* aURI,
+                                const OriginAttributes* aOriginAttributes,
+                                int32_t aTypeIndex, const nsACString& aType,
+                                uint32_t* aPermission,
+                                uint32_t aDefaultPermission,
+                                bool aDefaultPermissionIsValid,
+                                bool aExactHostMatch, bool aIncludingSession) {
     auto preparationResult = CommonPrepareToTestPermission(
         nullptr, aTypeIndex, aType, aPermission, aDefaultPermission,
         aDefaultPermissionIsValid, aExactHostMatch, aIncludingSession);
     if (preparationResult.is<nsresult>()) {
       return preparationResult.as<nsresult>();
     }
 
     return CommonTestPermissionInternal(
         nullptr, aURI, aOriginAttributes, preparationResult.as<int32_t>(),
         aType, aPermission, aExactHostMatch, aIncludingSession);
   }
   // Only one of aPrincipal or aURI is allowed to be passed in.
   nsresult CommonTestPermissionInternal(
       nsIPrincipal* aPrincipal, nsIURI* aURI,
-      const mozilla::OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
+      const OriginAttributes* aOriginAttributes, int32_t aTypeIndex,
       const nsACString& aType, uint32_t* aPermission, bool aExactHostMatch,
       bool aIncludingSession);
 
   nsresult OpenDatabase(nsIFile* permissionsFile);
 
   void InitDB(bool aRemoveFile);
   nsresult TryInitDB(bool aRemoveFile, nsIInputStream* aDefaultsInputStream);
 
   void AddIdleDailyMaintenanceJob();
   void RemoveIdleDailyMaintenanceJob();
   void PerformIdleDailyMaintenance();
 
   nsresult ImportLatestDefaults();
   already_AddRefed<nsIInputStream> GetDefaultsInputStream();
   void ConsumeDefaultsInputStream(nsIInputStream* aDefaultsInputStream,
-                                  const mozilla::MonitorAutoLock& aProofOfLock);
+                                  const MonitorAutoLock& aProofOfLock);
 
   nsresult CreateTable();
   void NotifyObserversWithPermission(nsIPrincipal* aPrincipal,
                                      const nsACString& aType,
                                      uint32_t aPermission, uint32_t aExpireType,
                                      int64_t aExpireTime,
                                      int64_t aModificationTime,
                                      const char16_t* aData);
@@ -551,26 +550,25 @@ class nsPermissionManager final : public
                        const nsACString* aOriginString = nullptr);
 
   void MaybeAddReadEntryFromMigration(const nsACString& aOrigin,
                                       const nsCString& aType,
                                       uint32_t aPermission,
                                       uint32_t aExpireType, int64_t aExpireTime,
                                       int64_t aModificationTime, int64_t aId);
 
-  nsRefPtrHashtable<nsCStringHashKey,
-                    mozilla::GenericNonExclusivePromise::Private>
+  nsRefPtrHashtable<nsCStringHashKey, GenericNonExclusivePromise::Private>
       mPermissionKeyPromiseMap;
 
   nsCOMPtr<nsIFile> mPermissionsFile;
 
   // This monitor is used to ensure the database reading before any other
   // operation. The reading of the database happens OMT. See |State| to know the
   // steps of the database reading.
-  mozilla::Monitor mMonitor;
+  Monitor mMonitor;
 
   enum State {
     // Initial state. The database has not been read yet.
     // |TryInitDB| is called at startup time to read the database OMT.
     // During the reading, |mReadEntries| will be populated with all the
     // existing permissions.
     eInitializing,
 
@@ -582,17 +580,17 @@ class nsPermissionManager final : public
 
     // The permissions are fully read and any pending operation can proceed.
     eReady,
 
     // The permission manager has been terminated. No extra database operations
     // will be allowed.
     eClosed,
   };
-  mozilla::Atomic<State> mState;
+  Atomic<State> mState;
 
   // A single entry, from the database.
   struct ReadEntry {
     ReadEntry()
         : mId(0),
           mPermission(0),
           mExpireType(0),
           mExpireTime(0),
@@ -658,49 +656,51 @@ class nsPermissionManager final : public
     nsCString mType;
     uint32_t mPermission;
   };
 
   // List of entries read from the default settings.
   // This array is protected by the monitor.
   nsTArray<DefaultEntry> mDefaultEntries;
 
-  nsresult Read(const mozilla::MonitorAutoLock& aProofOfLock);
+  nsresult Read(const MonitorAutoLock& aProofOfLock);
   void CompleteRead();
 
   void CompleteMigrations();
 
   bool mMemoryOnlyDB;
 
   nsTHashtable<PermissionHashKey> mPermissionTable;
   // a unique, monotonically increasing id used to identify each database entry
   int64_t mLargestID;
 
   nsCOMPtr<nsIPrefBranch> mDefaultPrefBranch;
 
   // NOTE: Ensure this is the last member since it has a large inline buffer.
   // An array to store the strings identifying the different types.
-  mozilla::Vector<nsCString, 512> mTypeArray;
+  Vector<nsCString, 512> mTypeArray;
 
   nsCOMPtr<nsIThread> mThread;
 
   struct ThreadBoundData {
     nsCOMPtr<mozIStorageConnection> mDBConn;
 
     nsCOMPtr<mozIStorageStatement> mStmtInsert;
     nsCOMPtr<mozIStorageStatement> mStmtDelete;
     nsCOMPtr<mozIStorageStatement> mStmtUpdate;
   };
-  mozilla::ThreadBound<ThreadBoundData> mThreadBoundData;
+  ThreadBound<ThreadBoundData> mThreadBoundData;
 
   friend class DeleteFromMozHostListener;
   friend class CloseDatabaseListener;
 };
 
 // {4F6B5E00-0C36-11d5-A535-0010A401EB10}
 #define NS_PERMISSIONMANAGER_CID                   \
   {                                                \
     0x4f6b5e00, 0xc36, 0x11d5, {                   \
       0xa5, 0x35, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 \
     }                                              \
   }
 
-#endif /* nsPermissionManager_h__ */
+}  // namespace mozilla
+
+#endif  // mozilla_PermissionManager_h
--- a/extensions/permissions/components.conf
+++ b/extensions/permissions/components.conf
@@ -5,18 +5,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 Classes = [
     {
         'cid': '{4f6b5e00-0c36-11d5-a535-0010a401eb10}',
         'contract_ids': ['@mozilla.org/permissionmanager;1'],
         'singleton': True,
         'type': 'nsIPermissionManager',
-        'constructor': 'nsPermissionManager::GetXPCOMSingleton',
-        'headers': ['/extensions/permissions/nsPermissionManager.h'],
+        'constructor': 'mozilla::PermissionManager::GetXPCOMSingleton',
+        'headers': ['/extensions/permissions/PermissionManager.h'],
     },
     {
         'cid': '{07611dc6-bf4d-4d8a-a64b-f3a5904dddc7}',
         'contract_ids': ['@mozilla.org/permissiondelegatehandler;1'],
         'type': 'PermissionDelegateHandler',
         'headers': ['/extensions/permissions/PermissionDelegateHandler.h'],
     },
 ]
--- a/extensions/permissions/moz.build
+++ b/extensions/permissions/moz.build
@@ -8,22 +8,23 @@ TEST_DIRS += ['test']
 
 TESTING_JS_MODULES += [
     'test/PermissionTestUtils.jsm',
 ]
 
 EXPORTS.mozilla += [
     'Permission.h',
     'PermissionDelegateHandler.h',
+    'PermissionManager.h',
 ]
 
 UNIFIED_SOURCES += [
-    'nsPermissionManager.cpp',
     'Permission.cpp',
     'PermissionDelegateHandler.cpp',
+    'PermissionManager.cpp',
 ]
 
 XPCOM_MANIFESTS += [
     'components.conf',
 ]
 
 LOCAL_INCLUDES += [
     '/caps',
--- a/extensions/permissions/test/browser.ini
+++ b/extensions/permissions/test/browser.ini
@@ -1,10 +1,10 @@
 [DEFAULT]
 
 [browser_permmgr_sync.js]
 fail-if = fission
 # The browser_permmgr_sync test tests e10s specific behavior, and runs code
 # paths which would hit the debug only assertion in
-# nsPermissionManager::PermissionKey::CreateFromPrincipal. Because of this, it
+# PermissionManager::PermissionKey::CreateFromPrincipal. Because of this, it
 # is only run in e10s opt builds.
 skip-if = debug || !e10s
 [browser_permmgr_viewsrc.js]
--- a/extensions/permissions/test/gtest/PermissionManagerTest.cpp
+++ b/extensions/permissions/test/gtest/PermissionManagerTest.cpp
@@ -1,31 +1,31 @@
 /* -*- 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 "nsNetUtil.h"
-#include "nsPermissionManager.h"
 #include "mozilla/OriginAttributes.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Unused.h"
 #include "gtest/gtest.h"
 #include "gtest/MozGTestBench.h"
 
 using namespace mozilla;
 
-class PermissionManager : public ::testing::Test {
+class PermissionManagerTester : public ::testing::Test {
  protected:
-  PermissionManager()
+  PermissionManagerTester()
       : mNonExistentType(
             NS_LITERAL_CSTRING("permissionTypeThatIsGuaranteedToNeverExist")) {}
   void SetUp() override {
-    mPermissionManager = nsPermissionManager::GetInstance();
+    mPermissionManager = PermissionManager::GetInstance();
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_NewURI(
         getter_AddRefs(uri),
         NS_LITERAL_CSTRING("https://test.origin.with.subdomains.example.com"));
     MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
     mPrincipal =
         mozilla::BasePrincipal::CreateContentPrincipal(uri, OriginAttributes());
   }
@@ -33,20 +33,20 @@ class PermissionManager : public ::testi
   void TearDown() override {
     mPermissionManager = nullptr;
     mPrincipal = nullptr;
   }
 
   static const unsigned kNumIterations = 100000;
 
   nsLiteralCString mNonExistentType;
-  RefPtr<nsPermissionManager> mPermissionManager;
+  RefPtr<PermissionManager> mPermissionManager;
   nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
-MOZ_GTEST_BENCH_F(PermissionManager, TestNonExistentPermissionFromPrincipal,
-                  [this] {
+MOZ_GTEST_BENCH_F(PermissionManagerTester,
+                  TestNonExistentPermissionFromPrincipal, [this] {
                     for (unsigned i = 0; i < kNumIterations; ++i) {
                       uint32_t result = 0;
                       Unused << mPermissionManager->TestPermissionFromPrincipal(
                           mPrincipal, mNonExistentType, &result);
                     }
                   });
--- a/extensions/permissions/test/gtest/moz.build
+++ b/extensions/permissions/test/gtest/moz.build
@@ -3,14 +3,10 @@
 # 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 += [
     'PermissionManagerTest.cpp',
 ]
 
-LOCAL_INCLUDES += [
-    '/extensions/permissions',
-]
-
 FINAL_LIBRARY = 'xul-gtest'
 
--- a/extensions/permissions/test/unit/test_permmanager_migrate_10-11.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_10-11.js
@@ -121,17 +121,17 @@ add_task(async function test() {
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
   await PlacesTestUtils.addVisits(Services.io.newURI("ftp://127.0.0.1:8080"));
   await PlacesTestUtils.addVisits(Services.io.newURI("https://localhost:8080"));
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_4-7.js
@@ -195,17 +195,17 @@ add_task(async function test() {
   );
   await PlacesTestUtils.addVisits(
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js
@@ -207,17 +207,17 @@ add_task(function test() {
     ["https://263.123.555.676", "A", 1, 0, 0],
   ];
 
   let found = expected.map(it => 0);
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_5-7a.js
@@ -262,17 +262,17 @@ add_task(async function test() {
   );
   await PlacesTestUtils.addVisits(
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_5-7b.js
@@ -114,17 +114,17 @@ add_task(function test() {
     ["http://localhost", "B", 2, 0, 0, 0],
   ];
 
   let found = expected.map(it => 0);
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_6-7a.js
@@ -263,17 +263,17 @@ add_task(async function test() {
   );
   await PlacesTestUtils.addVisits(
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_6-7b.js
@@ -110,17 +110,17 @@ add_task(function test() {
     ["http://foo.com^inBrowser=1", "A", 2, 0, 0, 0],
   ];
 
   let found = expected.map(it => 0);
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_7-8.js
@@ -250,17 +250,17 @@ add_task(async function test() {
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
   await PlacesTestUtils.addVisits(Services.io.newURI("ftp://127.0.0.1:8080"));
   await PlacesTestUtils.addVisits(Services.io.newURI("https://localhost:8080"));
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js
+++ b/extensions/permissions/test/unit/test_permmanager_migrate_9-10.js
@@ -187,17 +187,17 @@ add_task(async function test() {
     Services.io.newURI("ftp://some.subdomain.of.foo.com:8000/some/subdirectory")
   );
   await PlacesTestUtils.addVisits(Services.io.newURI("ftp://127.0.0.1:8080"));
   await PlacesTestUtils.addVisits(Services.io.newURI("https://localhost:8080"));
 
   // This will force the permission-manager to reload the data.
   Services.obs.notifyObservers(null, "testonly-reload-permissions-from-disk");
 
-  // Force initialization of the nsPermissionManager
+  // Force initialization of the PermissionManager
   for (let permission of Services.perms.all) {
     let isExpected = false;
 
     expected.forEach((it, i) => {
       if (
         permission.principal.origin == it[0] &&
         permission.type == it[1] &&
         permission.capability == it[2] &&
--- a/extensions/permissions/test/unit/test_permmanager_oa_strip.js
+++ b/extensions/permissions/test/unit/test_permmanager_oa_strip.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const TEST_URI = Services.io.newURI("http://example.com");
 const TEST_PERMISSION = "test/oastrip";
 const TEST_PERMISSION2 = "test/oastrip2";
 const TEST_PERMISSION3 = "test/oastrip3";
 
 // List of permissions which are not isolated by private browsing or user context
-// as per array kStripOAPermissions in nsPermissionManager.cpp
+// as per array kStripOAPermissions in PermissionManager.cpp
 const STRIPPED_PERMS = ["cookie"];
 
 let principal = Services.scriptSecurityManager.createContentPrincipal(
   TEST_URI,
   {}
 );
 let principalPrivateBrowsing = Services.scriptSecurityManager.createContentPrincipal(
   TEST_URI,
--- a/extensions/permissions/test/unit/test_permmanager_removebytypesince.js
+++ b/extensions/permissions/test/unit/test_permmanager_removebytypesince.js
@@ -24,17 +24,17 @@ add_task(async function test() {
   pm.addFromPrincipal(principal, "pear", 1);
   pm.addFromPrincipal(principal, "cucumber", 1);
 
   // sleep briefly, then record the time - we'll remove some permissions since then.
   await new Promise(resolve => do_timeout(20, resolve));
 
   let since = Date.now();
 
-  // *sob* - on Windows at least, the now recorded by nsPermissionManager.cpp
+  // *sob* - on Windows at least, the now recorded by PermissionManager.cpp
   // might be a couple of ms *earlier* than what JS sees.  So another sleep
   // to ensure our |since| is greater than the time of the permissions we
   // are now adding.  Sadly this means we'll never be able to test when since
   // exactly equals the modTime, but there you go...
   await new Promise(resolve => do_timeout(20, resolve));
 
   pm.addFromPrincipal(principal2, "apple", 2);
   pm.addFromPrincipal(principal2, "pear", 2);
--- a/extensions/permissions/test/unit/test_permmanager_removesince.js
+++ b/extensions/permissions/test/unit/test_permmanager_removesince.js
@@ -35,17 +35,17 @@ function* do_run_test() {
   pm.addFromPrincipal(principal1, "test/remove-since", 1);
 
   // sleep briefly, then record the time - we'll remove all since then.
   do_timeout(20, continue_test);
   yield;
 
   let since = Number(Date.now());
 
-  // *sob* - on Windows at least, the now recorded by nsPermissionManager.cpp
+  // *sob* - on Windows at least, the now recorded by PermissionManager.cpp
   // might be a couple of ms *earlier* than what JS sees.  So another sleep
   // to ensure our |since| is greater than the time of the permissions we
   // are now adding.  Sadly this means we'll never be able to test when since
   // exactly equals the modTime, but there you go...
   do_timeout(20, continue_test);
   yield;
 
   // add another item - this second one should get nuked.
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -43,17 +43,16 @@ LOCAL_INCLUDES += [
     '/dom/storage',
     '/dom/svg',
     '/dom/xslt/base',
     '/dom/xslt/xml',
     '/dom/xslt/xpath',
     '/dom/xslt/xslt',
     '/dom/xul',
     '/editor/composer',
-    '/extensions/permissions',
     '/js/xpconnect/loader',
     '/js/xpconnect/src',
     '/netwerk/base',
     '/netwerk/cookie',
     '/view',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -87,17 +87,17 @@
 #include "nsJSEnvironment.h"
 #include "nsContentSink.h"
 #include "nsFrameMessageManager.h"
 #include "nsDOMMutationObserver.h"
 #include "nsHyphenationManager.h"
 #include "nsWindowMemoryReporter.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/ProcessPriorityManager.h"
-#include "nsPermissionManager.h"
+#include "mozilla/PermissionManager.h"
 #include "nsApplicationCacheService.h"
 #include "mozilla/dom/CustomElementRegistry.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "ThirdPartyUtil.h"
 #include "TouchManager.h"
 #include "DecoderDoctorLogger.h"
@@ -241,17 +241,17 @@ nsresult nsLayoutStatics::Initialize() {
   TouchManager::InitializeStatics();
 
   nsWindowMemoryReporter::Init();
 
   SVGElementFactory::Init();
 
   ProcessPriorityManager::Init();
 
-  nsPermissionManager::Startup();
+  PermissionManager::Startup();
 
   UIDirectionManager::Initialize();
 
   CacheObserver::Init();
 
   IMEStateManager::Init();
 
   ServiceWorkerRegistrar::Initialize();
--- a/layout/tools/reftest/selftest/files/leaks.log
+++ b/layout/tools/reftest/selftest/files/leaks.log
@@ -53,17 +53,17 @@ 1141 |nsHttpHandler                     
 1142 |nsHttpRequestHead                     |       92       92|    1190        1|
 1145 |nsIDNService                          |       56       56|       1        1|
 1146 |nsIOService                           |      176      176|       1        1|
 1176 |nsJSPrincipals                        |       16       64|   12583        4|
 1186 |nsLocalFile                           |       88      264|   13423        3|
 1192 |nsMainThreadPtrHolder<T>              |       20       80|    2253        4|
 1222 |nsNodeWeakReference                   |       16       16|     919        1|
 1223 |nsNotifyAddrListener                  |      112      112|       1        1|
-1241 |nsPermissionManager                   |      136      136|       1        1|
+1241 |PermissionManager                     |      136      136|       1        1|
 1248 |nsPrefBranch                          |       76       76|      63        1|
 1257 |nsProxyInfo                           |       72       72|    1098        1|
 1265 |nsRedirectHistoryEntry                |       32       32|      69        1|
 1307 |nsSiteSecurityService                 |       56       56|       1        1|
 1311 |nsSocketTransportService              |      208      208|       1        1|
 1313 |nsStandardURL                         |      196     1372|   59651        7|
 1319 |nsStreamConverterService              |       48       48|       1        1|
 1324 |nsStringBuffer                        |        8     1688|  722245      211|
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -317,17 +317,16 @@ DIRS += [ 'mozurl', 'rust-helper' ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/docshell/base',
     '/dom/base',
-    '/extensions/permissions',
     '/netwerk/protocol/http',
     '/netwerk/socket',
     '/netwerk/url-classifier',
     '/security/manager/ssl',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     LOCAL_INCLUDES += [
--- a/netwerk/cookie/CookieJarSettings.cpp
+++ b/netwerk/cookie/CookieJarSettings.cpp
@@ -6,24 +6,24 @@
 
 #include "mozilla/AntiTrackingUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/ContentBlockingAllowList.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/net/CookieJarSettings.h"
 #include "mozilla/net/NeckoChannelParams.h"
 #include "mozilla/Permission.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/SchedulerGroup.h"
 #include "mozilla/StaticPrefs_network.h"
 #include "mozilla/Unused.h"
 #include "nsGlobalWindowInner.h"
 #if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
 #  include "nsIProtocolHandler.h"
 #endif
-#include "nsPermissionManager.h"
 #include "nsICookieService.h"
 
 namespace mozilla {
 namespace net {
 
 static StaticRefPtr<CookieJarSettings> sBlockinAll;
 
 namespace {
@@ -202,30 +202,30 @@ CookieJarSettings::CookiePermission(nsIP
         return rv;
       }
 
       return NS_OK;
     }
   }
 
   // Let's ask the permission manager.
-  nsPermissionManager* pm = nsPermissionManager::GetInstance();
+  PermissionManager* pm = PermissionManager::GetInstance();
   if (NS_WARN_IF(!pm)) {
     return NS_ERROR_FAILURE;
   }
 
 #if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
   // Check if this protocol doesn't allow cookies.
   bool hasFlags;
   nsCOMPtr<nsIURI> uri;
   aPrincipal->GetURI(getter_AddRefs(uri));
   rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_FORBIDS_COOKIE_ACCESS,
                            &hasFlags);
   if (NS_FAILED(rv) || hasFlags) {
-    *aCookiePermission = nsPermissionManager::DENY_ACTION;
+    *aCookiePermission = PermissionManager::DENY_ACTION;
     rv = NS_OK;  // Reset, so it's not caught as a bad status after the `else`.
   } else         // Note the tricky `else` which controls the call below.
 #endif
 
     rv = pm->TestPermissionFromPrincipal(
         aPrincipal, NS_LITERAL_CSTRING("cookie"), aCookiePermission);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
--- a/netwerk/cookie/CookiePermission.cpp
+++ b/netwerk/cookie/CookiePermission.cpp
@@ -43,21 +43,21 @@ already_AddRefed<nsICookiePermission> Co
   if (!gSingleton) {
     gSingleton = new CookiePermission();
     ClearOnShutdown(&gSingleton);
   }
   return do_AddRef(gSingleton);
 }
 
 bool CookiePermission::Init() {
-  // Initialize nsPermissionManager and fetch relevant prefs. This is only
+  // Initialize PermissionManager and fetch relevant prefs. This is only
   // required for some methods on nsICookiePermission, so it should be done
   // lazily.
 
-  mPermMgr = nsPermissionManager::GetInstance();
+  mPermMgr = PermissionManager::GetInstance();
   return mPermMgr != nullptr;
 }
 
 NS_IMETHODIMP
 CookiePermission::CanSetCookie(nsIURI* aURI, nsIChannel* /*aChannel*/,
                                nsICookie* aCookie, bool* aIsSession,
                                int64_t* aExpiry, bool* aResult) {
   NS_ASSERTION(aURI, "null uri");
--- a/netwerk/cookie/CookiePermission.h
+++ b/netwerk/cookie/CookiePermission.h
@@ -1,17 +1,17 @@
 /* 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_net_CookiePermission_h
 #define mozilla_net_CookiePermission_h
 
 #include "nsICookiePermission.h"
-#include "nsPermissionManager.h"
+#include "mozilla/PermissionManager.h"
 
 namespace mozilla {
 namespace net {
 
 class CookiePermission final : public nsICookiePermission {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICOOKIEPERMISSION
@@ -21,15 +21,15 @@ class CookiePermission final : public ns
 
   bool Init();
 
  private:
   ~CookiePermission() = default;
 
   bool EnsureInitialized() { return (mPermMgr != nullptr) || Init(); };
 
-  RefPtr<nsPermissionManager> mPermMgr;
+  RefPtr<mozilla::PermissionManager> mPermMgr;
 };
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif
--- a/netwerk/cookie/moz.build
+++ b/netwerk/cookie/moz.build
@@ -56,17 +56,16 @@ MOCHITEST_MANIFESTS += [
 ]
 
 IPDL_SOURCES = [
     'PCookieService.ipdl',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
-    '/extensions/permissions',
     '/intl/uconv',
     '/netwerk/base',
     '/netwerk/protocol/http',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPermissions.html
+++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersPushPermissions.html
@@ -17,17 +17,17 @@ const ACCESS_SESSION = SpecialPowers.Ci.
 
 const EXPIRE_TIME = SpecialPowers.Ci.nsIPermissionManager.EXPIRE_TIME;
 // expire Setting:
 //     start                 expire time point
 //   ----|------------------------|-----------
 //       <------------------------>
 //                 PERIOD
 var start;
-// PR_Now() that called in nsPermissionManager to get the system time
+// PR_Now() that called in PermissionManager to get the system time
 // is sometimes 100ms~600s more than Date.now() on Android 4.3 API11.
 // Thus, the PERIOD should be larger than 600ms in this test.
 const PERIOD = 900;
 var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('specialPowers_framescript.js'));
 SimpleTest.requestFlakyTimeout("untriaged");
 
 function starttest(){
   SpecialPowers.addPermission("pPROMPT", PROMPT_ACTION, document);
@@ -205,17 +205,17 @@ async function permissionPollingCheck() 
     errorHandler('expired permission should be removed!');
   }
 }
 
 function getPlatformInfo() {
   var version = SpecialPowers.Services.sysinfo.getProperty('version');
   version = parseFloat(version);
 
-  // PR_Now() that called in nsPermissionManager to get the system time and
+  // PR_Now() that called in PermissionManager to get the system time and
   // Date.now() are out of sync on win32 platform(XP/win7). The PR_Now() is
   // 15~20ms less than Date.now(). Unfortunately, this time skew can't be
   // avoided, so it needs to add a time buffer to compensate.
   // Version 5.1 is win XP, 6.1 is win7
   if (navigator.platform.startsWith('Win32') && (version <= 6.1)) {
     return { platform: "Win32", timeCompensation: -100 };
   }
 
--- a/testing/mozbase/mozprofile/mozprofile/permissions.py
+++ b/testing/mozbase/mozprofile/mozprofile/permissions.py
@@ -232,17 +232,17 @@ class Permissions(object):
     def write_db(self, locations):
         """write permissions to the sqlite database"""
 
         # Open database and create table
         permDB = sqlite3.connect(os.path.join(self._profileDir, "permissions.sqlite"))
         cursor = permDB.cursor()
 
         # SQL copied from
-        # http://dxr.mozilla.org/mozilla-central/source/extensions/cookie/nsPermissionManager.cpp
+        # http://dxr.mozilla.org/mozilla-central/source/extensions/permissions/PermissionManager.cpp
         cursor.execute("""CREATE TABLE IF NOT EXISTS moz_hosts (
               id INTEGER PRIMARY KEY
              ,origin TEXT
              ,type TEXT
              ,permission INTEGER
              ,expireType INTEGER
              ,expireTime INTEGER
              ,modificationTime INTEGER
--- a/toolkit/components/antitracking/AntiTrackingUtils.cpp
+++ b/toolkit/components/antitracking/AntiTrackingUtils.cpp
@@ -8,21 +8,21 @@
 
 #include "AntiTrackingLog.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/net/CookieJarSettings.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/WindowGlobalParent.h"
 #include "mozilla/dom/WindowContext.h"
 #include "mozilla/net/NeckoChannelParams.h"
+#include "mozilla/PermissionManager.h"
 #include "nsIChannel.h"
 #include "nsIPermission.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
-#include "nsPermissionManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsSandboxFlags.h"
 #include "nsScriptSecurityManager.h"
 
 #define ANTITRACKING_PERM_KEY "3rdPartyStorage"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -133,17 +133,17 @@ bool AntiTrackingUtils::IsStorageAccessP
 }
 
 // static
 bool AntiTrackingUtils::CheckStoragePermission(nsIPrincipal* aPrincipal,
                                                const nsAutoCString& aType,
                                                bool aIsInPrivateBrowsing,
                                                uint32_t* aRejectedReason,
                                                uint32_t aBlockedReason) {
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  PermissionManager* permManager = PermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     LOG(("Failed to obtain the permission manager"));
     return false;
   }
 
   uint32_t result = 0;
   if (aIsInPrivateBrowsing) {
     LOG_PRIN(("Querying the permissions for private modei looking for a "
--- a/toolkit/components/antitracking/ContentBlocking.cpp
+++ b/toolkit/components/antitracking/ContentBlocking.cpp
@@ -11,29 +11,29 @@
 
 #include "mozilla/ContentBlockingAllowList.h"
 #include "mozilla/ContentBlockingUserInteraction.h"
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/WindowContext.h"
 #include "mozilla/dom/WindowGlobalParent.h"
 #include "mozilla/net/CookieJarSettings.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindowInner.h"
 #include "nsIClassifiedChannel.h"
 #include "nsICookiePermission.h"
 #include "nsICookieService.h"
 #include "nsIPermission.h"
 #include "nsIPrincipal.h"
 #include "nsIURI.h"
 #include "nsIOService.h"
 #include "nsIWebProgressListener.h"
-#include "nsPermissionManager.h"
 #include "nsScriptSecurityManager.h"
 
 namespace mozilla {
 
 LazyLogModule gAntiTrackingLog("AntiTracking");
 
 }
 
@@ -495,17 +495,17 @@ ContentBlocking::SaveAccessForOriginOnPa
            aParentPrincipal);
 
   if (NS_WARN_IF(!aParentPrincipal)) {
     // The child process is sending something wrong. Let's ignore it.
     LOG(("aParentPrincipal is null, bailing out early"));
     return ParentAccessGrantPromise::CreateAndReject(false, __func__);
   }
 
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  PermissionManager* permManager = PermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     LOG(("Permission manager is null, bailing out early"));
     return ParentAccessGrantPromise::CreateAndReject(false, __func__);
   }
 
   // Remember that this pref is stored in seconds!
   uint32_t expirationType = nsIPermissionManager::EXPIRE_TIME;
   uint32_t expirationTime = aExpirationTime * 1000;
@@ -1023,17 +1023,17 @@ bool ContentBlocking::ShouldAllowAccessF
 
 bool ContentBlocking::ShouldAllowAccessFor(
     nsIPrincipal* aPrincipal, nsICookieJarSettings* aCookieJarSettings) {
   MOZ_ASSERT(aPrincipal);
   MOZ_ASSERT(aCookieJarSettings);
 
   uint32_t access = nsICookiePermission::ACCESS_DEFAULT;
   if (aPrincipal->GetIsContentPrincipal()) {
-    nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+    PermissionManager* permManager = PermissionManager::GetInstance();
     if (permManager) {
       Unused << NS_WARN_IF(NS_FAILED(permManager->TestPermissionFromPrincipal(
           aPrincipal, NS_LITERAL_CSTRING("cookie"), &access)));
     }
   }
 
   if (access != nsICookiePermission::ACCESS_DEFAULT) {
     return access != nsICookiePermission::ACCESS_DENY;
--- a/toolkit/components/antitracking/ContentBlockingAllowList.cpp
+++ b/toolkit/components/antitracking/ContentBlockingAllowList.cpp
@@ -4,20 +4,20 @@
  * 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 "AntiTrackingLog.h"
 #include "ContentBlockingAllowList.h"
 
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/Document.h"
+#include "mozilla/PermissionManager.h"
 #include "mozilla/ScopeExit.h"
 #include "nsContentUtils.h"
 #include "nsIHttpChannelInternal.h"
-#include "nsPermissionManager.h"
 
 using namespace mozilla;
 
 /* static */ bool ContentBlockingAllowList::Check(
     nsIPrincipal* aTopWinPrincipal, bool aIsPrivateBrowsing) {
   bool isAllowed = false;
   nsresult rv = Check(aTopWinPrincipal, aIsPrivateBrowsing, isAllowed);
   if (NS_SUCCEEDED(rv) && isAllowed) {
@@ -92,17 +92,17 @@ nsresult ContentBlockingAllowList::Check
     // Nothing to do!
     return NS_OK;
   }
 
   LOG_PRIN(("Deciding whether the user has overridden content blocking for %s",
             _spec),
            aContentBlockingAllowListPrincipal);
 
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  PermissionManager* permManager = PermissionManager::GetInstance();
   NS_ENSURE_TRUE(permManager, NS_ERROR_FAILURE);
 
   // Check both the normal mode and private browsing mode user override
   // permissions.
   std::pair<const nsLiteralCString, bool> types[] = {
       {NS_LITERAL_CSTRING("trackingprotection"), false},
       {NS_LITERAL_CSTRING("trackingprotection-pb"), true}};
 
--- a/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp
+++ b/toolkit/components/antitracking/ContentBlockingUserInteraction.cpp
@@ -4,34 +4,34 @@
  * 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 "AntiTrackingLog.h"
 #include "ContentBlockingUserInteraction.h"
 #include "AntiTrackingUtils.h"
 
 #include "mozilla/dom/ContentChild.h"
+#include "mozilla/PermissionManager.h"
 #include "nsIPrincipal.h"
-#include "nsPermissionManager.h"
 #include "nsXULAppAPI.h"
 #include "prtime.h"
 
 namespace mozilla {
 
 /* static */
 void ContentBlockingUserInteraction::Observe(nsIPrincipal* aPrincipal) {
   if (!aPrincipal) {
     // The content process may have sent us garbage data.
     return;
   }
 
   if (XRE_IsParentProcess()) {
     LOG_PRIN(("Saving the userInteraction for %s", _spec), aPrincipal);
 
-    nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+    PermissionManager* permManager = PermissionManager::GetInstance();
     if (NS_WARN_IF(!permManager)) {
       LOG(("Permission manager is null, bailing out early"));
       return;
     }
 
     // Remember that this pref is stored in seconds!
     uint32_t expirationType = nsIPermissionManager::EXPIRE_TIME;
     uint32_t expirationTime =
@@ -60,17 +60,17 @@ void ContentBlockingUserInteraction::Obs
   LOG_PRIN(("Asking the parent process to save the user-interaction for us: %s",
             _spec),
            aPrincipal);
   cc->SendStoreUserInteractionAsPermission(IPC::Principal(aPrincipal));
 }
 
 /* static */
 bool ContentBlockingUserInteraction::Exists(nsIPrincipal* aPrincipal) {
-  nsPermissionManager* permManager = nsPermissionManager::GetInstance();
+  PermissionManager* permManager = PermissionManager::GetInstance();
   if (NS_WARN_IF(!permManager)) {
     return false;
   }
 
   uint32_t result = 0;
   nsresult rv = permManager->TestPermissionWithoutDefaultsFromPrincipal(
       aPrincipal, USER_INTERACTION_PERM, &result);
   if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp
+++ b/toolkit/components/antitracking/TemporaryAccessGrantObserver.cpp
@@ -1,38 +1,38 @@
 /* -*- 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 "TemporaryAccessGrantObserver.h"
 
+#include "mozilla/PermissionManager.h"
 #include "nsIObserverService.h"
-#include "nsPermissionManager.h"
 #include "nsTHashtable.h"
 #include "nsXULAppAPI.h"
 
 using namespace mozilla;
 
 UniquePtr<TemporaryAccessGrantObserver::ObserversTable>
     TemporaryAccessGrantObserver::sObservers;
 
 TemporaryAccessGrantObserver::TemporaryAccessGrantObserver(
-    nsPermissionManager* aPM, nsIPrincipal* aPrincipal, const nsACString& aType)
+    PermissionManager* aPM, nsIPrincipal* aPrincipal, const nsACString& aType)
     : mPM(aPM), mPrincipal(aPrincipal), mType(aType) {
   MOZ_ASSERT(XRE_IsParentProcess(),
              "Enforcing temporary access grant lifetimes can only be done in "
              "the parent process");
 }
 
 NS_IMPL_ISUPPORTS(TemporaryAccessGrantObserver, nsIObserver)
 
 // static
-void TemporaryAccessGrantObserver::Create(nsPermissionManager* aPM,
+void TemporaryAccessGrantObserver::Create(PermissionManager* aPM,
                                           nsIPrincipal* aPrincipal,
                                           const nsACString& aType) {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   if (!sObservers) {
     sObservers = MakeUnique<ObserversTable>();
   }
   Unused << sObservers
--- a/toolkit/components/antitracking/TemporaryAccessGrantObserver.h
+++ b/toolkit/components/antitracking/TemporaryAccessGrantObserver.h
@@ -12,21 +12,22 @@
 #include "nsHashKeys.h"
 #include "nsIObserver.h"
 #include "nsString.h"
 #include "PLDHashTable.h"
 
 template <class, class>
 class nsDataHashtable;
 class nsITimer;
-class nsPermissionManager;
 class TemporaryAccessGrantCacheKey;
 
 namespace mozilla {
 
+class PermissionManager;
+
 class TemporaryAccessGrantCacheKey : public PLDHashEntryHdr {
  public:
   typedef std::pair<nsCOMPtr<nsIPrincipal>, nsCString> KeyType;
   typedef const KeyType* KeyTypePointer;
 
   explicit TemporaryAccessGrantCacheKey(KeyTypePointer aKey)
       : mPrincipal(aKey->first), mType(aKey->second) {}
   TemporaryAccessGrantCacheKey(TemporaryAccessGrantCacheKey&& aOther) = default;
@@ -57,32 +58,31 @@ class TemporaryAccessGrantCacheKey : pub
   nsCString mType;
 };
 
 class TemporaryAccessGrantObserver final : public nsIObserver {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
-  static void Create(nsPermissionManager* aPM, nsIPrincipal* aPrincipal,
+  static void Create(PermissionManager* aPM, nsIPrincipal* aPrincipal,
                      const nsACString& aType);
 
   void SetTimer(nsITimer* aTimer);
 
  private:
-  TemporaryAccessGrantObserver(nsPermissionManager* aPM,
-                               nsIPrincipal* aPrincipal,
+  TemporaryAccessGrantObserver(PermissionManager* aPM, nsIPrincipal* aPrincipal,
                                const nsACString& aType);
   ~TemporaryAccessGrantObserver() = default;
 
  private:
   typedef nsDataHashtable<TemporaryAccessGrantCacheKey, nsCOMPtr<nsITimer>>
       ObserversTable;
   static UniquePtr<ObserversTable> sObservers;
   nsCOMPtr<nsITimer> mTimer;
-  RefPtr<nsPermissionManager> mPM;
+  RefPtr<PermissionManager> mPM;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsCString mType;
 };
 
 }  // namespace mozilla
 
 #endif  // mozilla_temporaryaccessgrantobserver_h
--- a/toolkit/components/antitracking/moz.build
+++ b/toolkit/components/antitracking/moz.build
@@ -57,17 +57,16 @@ UNIFIED_SOURCES += [
     'SettingsChangeObserver.cpp',
     'StorageAccess.cpp',
     'StoragePrincipalHelper.cpp',
     'TemporaryAccessGrantObserver.cpp',
     'URLDecorationStripper.cpp',
 ]
 
 LOCAL_INCLUDES += [
-    '/extensions/permissions',
     '/netwerk/base',
     '/netwerk/protocol/http',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'