Bug 1731994: part 1) const-qualify some members of `ContentPermissionRequestBase`. r=edgar
authorMirko Brodesser <mbrodesser@mozilla.com>
Thu, 23 Sep 2021 08:48:16 +0000
changeset 593022 9ba235034c43eb01175931d005acb806ea4b8ef0
parent 593021 739ccd54d7c8ea04235c06cc335e93d769cd60f7
child 593023 5dece26f14db8ee184ce88f0fd0df645d0be8640
push id38820
push usersmolnar@mozilla.com
push dateThu, 23 Sep 2021 21:45:25 +0000
treeherdermozilla-central@4eda9eb8926b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedgar
bugs1731994
milestone94.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 1731994: part 1) const-qualify some members of `ContentPermissionRequestBase`. r=edgar Differential Revision: https://phabricator.services.mozilla.com/D126337
dom/base/nsContentPermissionHelper.cpp
dom/base/nsContentPermissionHelper.h
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -470,17 +470,17 @@ ContentPermissionRequestBase::GetIsHandl
 NS_IMETHODIMP
 ContentPermissionRequestBase::GetTypes(nsIArray** aTypes) {
   nsTArray<nsString> emptyOptions;
   return nsContentPermissionUtils::CreatePermissionArray(mType, emptyOptions,
                                                          aTypes);
 }
 
 ContentPermissionRequestBase::PromptResult
-ContentPermissionRequestBase::CheckPromptPrefs() {
+ContentPermissionRequestBase::CheckPromptPrefs() const {
   MOZ_ASSERT(!mPrefName.IsEmpty(),
              "This derived class must support checking pref types");
 
   nsAutoCString prefName(mPrefName);
   prefName.AppendLiteral(".prompt.testing");
   if (Preferences::GetBool(PromiseFlatCString(prefName).get(), false)) {
     prefName.AppendLiteral(".allow");
     if (Preferences::GetBool(PromiseFlatCString(prefName).get(), true)) {
--- a/dom/base/nsContentPermissionHelper.h
+++ b/dom/base/nsContentPermissionHelper.h
@@ -118,17 +118,17 @@ class ContentPermissionRequestBase : pub
 
   enum class PromptResult {
     Granted,
     Denied,
     Pending,
   };
   nsresult ShowPrompt(PromptResult& aResult);
 
-  PromptResult CheckPromptPrefs();
+  PromptResult CheckPromptPrefs() const;
 
   // Check if the permission has an opportunity to request.
   bool CheckPermissionDelegate();
 
   enum class DelayedTaskType {
     Allow,
     Deny,
     Request,
@@ -141,18 +141,18 @@ class ContentPermissionRequestBase : pub
                                const nsACString& aPrefName,
                                const nsACString& aType);
   virtual ~ContentPermissionRequestBase() = default;
 
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsCOMPtr<nsIPrincipal> mTopLevelPrincipal;
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   RefPtr<PermissionDelegateHandler> mPermissionHandler;
-  nsCString mPrefName;
-  nsCString mType;
+  const nsCString mPrefName;
+  const nsCString mType;
   bool mIsHandlingUserInput;
   bool mMaybeUnsafePermissionDelegate;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 using mozilla::dom::ContentPermissionRequestParent;