Bug 1596843 - Part 3: Remove the unused nsIPermissionManager.updateExpireTime() method; r=baku
☠☠ backed out by de185bb7bdd5 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 17 Nov 2019 07:23:32 +0000
changeset 502334 a9827fae8655ff42f431f8073ad54a29b1def620
parent 502333 8b2220bc47afa4a203e32530f73fd34e1fd9b687
child 502335 69ee727d5b4588e9f666bd99e89ae230b8fcb8e6
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1596843
milestone72.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 1596843 - Part 3: Remove the unused nsIPermissionManager.updateExpireTime() method; r=baku Differential Revision: https://phabricator.services.mozilla.com/D53239
extensions/permissions/nsPermissionManager.cpp
extensions/permissions/test/unit/test_permmanager_expiration.js
netwerk/base/nsIPermissionManager.idl
--- a/extensions/permissions/nsPermissionManager.cpp
+++ b/extensions/permissions/nsPermissionManager.cpp
@@ -3022,65 +3022,16 @@ void nsPermissionManager::UpdateDB(
   }
 
   nsCOMPtr<mozIStoragePendingStatement> pending;
   rv = aStmt->ExecuteAsync(nullptr, getter_AddRefs(pending));
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 }
 
 NS_IMETHODIMP
-nsPermissionManager::UpdateExpireTime(nsIPrincipal* aPrincipal,
-                                      const nsACString& aType,
-                                      bool aExactHostMatch,
-                                      uint64_t aSessionExpireTime,
-                                      uint64_t aPersistentExpireTime) {
-  NS_ENSURE_ARG_POINTER(aPrincipal);
-
-  uint64_t nowms = PR_Now() / 1000;
-  if (aSessionExpireTime < nowms || aPersistentExpireTime < nowms) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
-    return NS_OK;
-  }
-
-  // Setting the expire time of an nsEP is non-sensical.
-  if (IsExpandedPrincipal(aPrincipal)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  MOZ_ASSERT(PermissionAvailable(aPrincipal, aType));
-
-  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;
-
-  PermissionHashKey* entry =
-      GetPermissionHashKey(aPrincipal, typeIndex, aExactHostMatch);
-  if (!entry) {
-    return NS_OK;
-  }
-
-  int32_t idx = entry->GetPermissionIndex(typeIndex);
-  if (-1 == idx) {
-    return NS_OK;
-  }
-
-  PermissionEntry& perm = entry->GetPermissions()[idx];
-  if (perm.mExpireType == EXPIRE_TIME) {
-    perm.mExpireTime = aPersistentExpireTime;
-  } else if (perm.mExpireType == EXPIRE_SESSION && perm.mExpireTime != 0) {
-    perm.mExpireTime = aSessionExpireTime;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsPermissionManager::GetPermissionsWithKey(const nsACString& aPermissionKey,
                                            nsTArray<IPC::Permission>& aPerms) {
   aPerms.Clear();
   if (NS_WARN_IF(XRE_IsContentProcess())) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
--- a/extensions/permissions/test/unit/test_permmanager_expiration.js
+++ b/extensions/permissions/test/unit/test_permmanager_expiration.js
@@ -79,72 +79,29 @@ function* do_run_test() {
   pm.addFromPrincipal(
     principal,
     "test/expiration-perm-nexp",
     1,
     pm.EXPIRE_NEVER,
     0
   );
 
-  // add a permission for renewal
-  pm.addFromPrincipal(
-    principal,
-    "test/expiration-perm-renewable",
-    1,
-    pm.EXPIRE_TIME,
-    now + 100
-  );
-  pm.addFromPrincipal(
-    principal,
-    "test/expiration-session-renewable",
-    1,
-    pm.EXPIRE_SESSION,
-    now + 100
-  );
-
-  // And immediately renew them with longer timeouts
-  pm.updateExpireTime(
-    principal,
-    "test/expiration-perm-renewable",
-    true,
-    now + 100,
-    now + 1e6
-  );
-  pm.updateExpireTime(
-    principal,
-    "test/expiration-session-renewable",
-    true,
-    now + 1e6,
-    now + 100
-  );
-
   // check that the second two haven't expired yet
   Assert.equal(
     1,
     pm.testPermissionFromPrincipal(principal, "test/expiration-perm-exp3")
   );
   Assert.equal(
     1,
     pm.testPermissionFromPrincipal(principal, "test/expiration-session-exp3")
   );
   Assert.equal(
     1,
     pm.testPermissionFromPrincipal(principal, "test/expiration-perm-nexp")
   );
-  Assert.equal(
-    1,
-    pm.testPermissionFromPrincipal(principal, "test/expiration-perm-renewable")
-  );
-  Assert.equal(
-    1,
-    pm.testPermissionFromPrincipal(
-      principal,
-      "test/expiration-session-renewable"
-    )
-  );
 
   // ... and the first one has
   do_timeout(10, continue_test);
   yield;
   Assert.equal(
     0,
     pm.testPermissionFromPrincipal(principal, "test/expiration-perm-exp")
   );
@@ -178,23 +135,10 @@ function* do_run_test() {
     null,
     pm.getPermissionObject(principal, "test/expiration-perm-exp2", false)
   );
   Assert.equal(
     null,
     pm.getPermissionObject(principal, "test/expiration-session-exp2", false)
   );
 
-  // Check that the renewable permissions actually got renewed
-  Assert.equal(
-    1,
-    pm.testPermissionFromPrincipal(principal, "test/expiration-perm-renewable")
-  );
-  Assert.equal(
-    1,
-    pm.testPermissionFromPrincipal(
-      principal,
-      "test/expiration-session-renewable"
-    )
-  );
-
   do_finish_generator_test(test_generator);
 }
--- a/netwerk/base/nsIPermissionManager.idl
+++ b/netwerk/base/nsIPermissionManager.idl
@@ -194,36 +194,16 @@ interface nsIPermissionManager : nsISupp
 
   /**
    * Returns all stored permissions.
    * @return an array of nsIPermission objects
    */
   readonly attribute Array<nsIPermission> all;
 
   /**
-   * If the current permission is set to expire, reset the expiration time. If
-   * there is no permission or the current permission does not expire, this
-   * method will silently return.
-   *
-   * @param sessionExpiretime  an integer representation of when this permission
-   *                           should be forgotten (milliseconds since
-   *                           Jan 1 1970 0:00:00), if it is currently
-   *                           EXPIRE_SESSION.
-   * @param sessionExpiretime  an integer representation of when this permission
-   *                           should be forgotten (milliseconds since
-   *                           Jan 1 1970 0:00:00), if it is currently
-   *                           EXPIRE_TIME.
-   */
-  void updateExpireTime(in nsIPrincipal principal,
-                        in ACString type,
-                        in boolean exactHost,
-                        in uint64_t sessionExpireTime,
-                        in uint64_t persistentExpireTime);
-
-  /**
    * 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