Bug 1235379 - Eliminate deferred session storage mode. r=ttaubert, a=sylvestre
authorBill McCloskey <billm@mozilla.com>
Tue, 29 Dec 2015 12:45:21 -0800
changeset 310777 d1d72c3be215d6314189afa968e377959413380d
parent 310776 75038d8f97033e7e2a5eb5c28f125f5f613b348a
child 310778 62a772079ed99c96a64961034a359bb34e53034e
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert, sylvestre
bugs1235379
milestone45.0a2
Bug 1235379 - Eliminate deferred session storage mode. r=ttaubert, a=sylvestre
browser/app/profile/firefox.js
browser/components/sessionstore/PrivacyFilter.jsm
browser/components/sessionstore/PrivacyLevel.jsm
browser/components/sessionstore/TabState.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1009,18 +1009,16 @@ pref("browser.selfsupport.url", "https:/
 pref("browser.sessionstore.resume_from_crash", true);
 pref("browser.sessionstore.resume_session_once", false);
 
 // minimal interval between two save operations in milliseconds
 pref("browser.sessionstore.interval", 15000);
 // on which sites to save text data, POSTDATA and cookies
 // 0 = everywhere, 1 = unencrypted sites, 2 = nowhere
 pref("browser.sessionstore.privacy_level", 0);
-// the same as browser.sessionstore.privacy_level, but for saving deferred session data
-pref("browser.sessionstore.privacy_level_deferred", 1);
 // how many tabs can be reopened (per window)
 pref("browser.sessionstore.max_tabs_undo", 10);
 // how many windows can be reopened (per session) - on non-OS X platforms this
 // pref may be ignored when dealing with pop-up windows to ensure proper startup
 pref("browser.sessionstore.max_windows_undo", 3);
 // number of crashes that can occur before the about:sessionrestore page is displayed
 // (this pref has no effect if more than 6 hours have passed since the last crash)
 pref("browser.sessionstore.max_resumed_crashes", 1);
--- a/browser/components/sessionstore/PrivacyFilter.jsm
+++ b/browser/components/sessionstore/PrivacyFilter.jsm
@@ -13,72 +13,69 @@ Cu.import("resource://gre/modules/XPCOMU
 XPCOMUtils.defineLazyModuleGetter(this, "PrivacyLevel",
   "resource:///modules/sessionstore/PrivacyLevel.jsm");
 
 /**
  * Returns whether the current privacy level allows saving data for the given
  * |url|.
  *
  * @param url The URL we want to save data for.
- * @param isPinned Whether the given |url| is contained in a pinned tab.
  * @return bool
  */
-function checkPrivacyLevel(url, isPinned) {
+function checkPrivacyLevel(url) {
   let isHttps = url.startsWith("https:");
-  return PrivacyLevel.canSave({isHttps: isHttps, isPinned: isPinned});
+  return PrivacyLevel.canSave({isHttps});
 }
 
 /**
  * A module that provides methods to filter various kinds of data collected
  * from a tab by the current privacy level as set by the user.
  */
 this.PrivacyFilter = Object.freeze({
   /**
    * Filters the given (serialized) session storage |data| according to the
    * current privacy level and returns a new object containing only data that
    * we're allowed to store.
    *
    * @param data The session storage data as collected from a tab.
-   * @param isPinned Whether the tab we collected from is pinned.
    * @return object
    */
-  filterSessionStorageData: function (data, isPinned) {
+  filterSessionStorageData: function (data) {
     let retval = {};
 
     for (let host of Object.keys(data)) {
-      if (checkPrivacyLevel(host, isPinned)) {
+      if (checkPrivacyLevel(host)) {
         retval[host] = data[host];
       }
     }
 
     return Object.keys(retval).length ? retval : null;
   },
 
   /**
    * Filters the given (serialized) form |data| according to the current
    * privacy level and returns a new object containing only data that we're
    * allowed to store.
    *
    * @param data The form data as collected from a tab.
-   * @param isPinned Whether the tab we collected from is pinned.
    * @return object
    */
-  filterFormData: function (data, isPinned) {
+  filterFormData: function (data) {
     // If the given form data object has an associated URL that we are not
     // allowed to store data for, bail out. We explicitly discard data for any
     // children as well even if storing data for those frames would be allowed.
-    if (data.url && !checkPrivacyLevel(data.url, isPinned)) {
+    if (data.url && !checkPrivacyLevel(data.url)) {
       return;
     }
 
     let retval = {};
 
     for (let key of Object.keys(data)) {
       if (key === "children") {
-        let recurse = child => this.filterFormData(child, isPinned);
+        let recurse = child => this.filterFormData(child);
         let children = data.children.map(recurse).filter(child => child);
 
         if (children.length) {
           retval.children = children;
         }
       // Only copy keys other than "children" if we have a valid URL in
       // data.url and we thus passed the privacy level check.
       } else if (data.url) {
--- a/browser/components/sessionstore/PrivacyLevel.jsm
+++ b/browser/components/sessionstore/PrivacyLevel.jsm
@@ -9,64 +9,43 @@ this.EXPORTED_SYMBOLS = ["PrivacyLevel"]
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
   "@mozilla.org/browser/sessionstartup;1", "nsISessionStartup");
 
-const PREF_NORMAL = "browser.sessionstore.privacy_level";
-const PREF_DEFERRED = "browser.sessionstore.privacy_level_deferred";
+const PREF = "browser.sessionstore.privacy_level";
 
 // The following constants represent the different possible privacy levels that
 // can be set by the user and that we need to consider when collecting text
 // data, and cookies.
 //
 // Collect data from all sites (http and https).
 const PRIVACY_NONE = 0;
 // Collect data from unencrypted sites (http), only.
 const PRIVACY_ENCRYPTED = 1;
 // Collect no data.
 const PRIVACY_FULL = 2;
 
 /**
- * Determines the current privacy level as set by the user.
- *
- * @param isPinned
- *        Whether to return the privacy level for pinned tabs.
- * @return {int} The privacy level as read from the user's preferences.
- */
-function getCurrentLevel(isPinned) {
-  let pref = PREF_NORMAL;
-
-  // If we're in the process of quitting and we're not autoresuming the session
-  // then we will use the deferred privacy level for non-pinned tabs.
-  if (!isPinned && Services.startup.shuttingDown && !gSessionStartup.isAutomaticRestoreEnabled()) {
-    pref = PREF_DEFERRED;
-  }
-
-  return Services.prefs.getIntPref(pref);
-}
-
-/**
  * The external API as exposed by this module.
  */
 var PrivacyLevel = Object.freeze({
   /**
    * Checks whether we're allowed to save data for a specific site.
    *
-   * @param {isHttps: boolean, isPinned: boolean}
-   *        An object that must have two properties: 'isHttps' and 'isPinned'.
+   * @param {isHttps: boolean}
+   *        An object that must have one property: 'isHttps'.
    *        'isHttps' tells whether the site us secure communication (HTTPS).
-   *        'isPinned' tells whether the site is loaded in a pinned tab.
    * @return {bool} Whether we can save data for the specified site.
    */
-  canSave: function ({isHttps, isPinned}) {
-    let level = getCurrentLevel(isPinned);
+  canSave: function ({isHttps}) {
+    let level = Services.prefs.getIntPref(PREF);
 
     // Never save any data when full privacy is requested.
     if (level == PRIVACY_FULL) {
       return false;
     }
 
     // Don't save data for encrypted sites when requested.
     if (isHttps && level == PRIVACY_ENCRYPTED) {
--- a/browser/components/sessionstore/TabState.jsm
+++ b/browser/components/sessionstore/TabState.jsm
@@ -220,19 +220,19 @@ var TabStateInternal = {
     let isPinned = tabData.pinned || false;
 
     for (let key of Object.keys(data)) {
       let value = data[key];
 
       // Filter sensitive data according to the current privacy level.
       if (!includePrivateData) {
         if (key === "storage") {
-          value = PrivacyFilter.filterSessionStorageData(value, isPinned);
+          value = PrivacyFilter.filterSessionStorageData(value);
         } else if (key === "formdata") {
-          value = PrivacyFilter.filterFormData(value, isPinned);
+          value = PrivacyFilter.filterFormData(value);
         }
       }
 
       if (key === "history") {
         tabData.entries = value.entries;
 
         if (value.hasOwnProperty("index")) {
           tabData.index = value.index;