Bug 1167923 - Change TabStateCache to use either xul:tab or xul:browser as key. r=ttaubert
authorAllasso Travesser <allassopraise@gmail.com>
Wed, 24 Jun 2015 07:19:00 -0400
changeset 282463 732640286a2082c6ed685879ca9c1cda35c3d9ed
parent 282462 5e376b895220eeb611705a7dbce4f4fe53d1aa78
child 282464 3606409b170fbadec766916c5c8ccfcada8bc179
push id897
push userjlund@mozilla.com
push dateMon, 14 Sep 2015 18:56:12 +0000
treeherdermozilla-release@9411e2d2b214 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1167923
milestone41.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 1167923 - Change TabStateCache to use either xul:tab or xul:browser as key. r=ttaubert
browser/components/sessionstore/TabStateCache.jsm
--- a/browser/components/sessionstore/TabStateCache.jsm
+++ b/browser/components/sessionstore/TabStateCache.jsm
@@ -13,70 +13,74 @@ this.EXPORTED_SYMBOLS = ["TabStateCache"
  * to tab data (as objects).
  *
  * Note that we should never cache private data, as:
  * - that data is used very seldom by SessionStore;
  * - caching private data in addition to public data is memory consuming.
  */
 this.TabStateCache = Object.freeze({
   /**
-   * Retrieves cached data for a given |browser|.
+   * Retrieves cached data for a given |tab| or associated |browser|.
    *
-   * @param browser (xul:browser)
-   *        The browser to retrieve cached data for.
+   * @param browserOrTab (xul:tab or xul:browser)
+   *        The tab or browser to retrieve cached data for.
    * @return (object)
-   *         The cached data stored for the given |browser|.
+   *         The cached data stored for the given |tab|
+   *         or associated |browser|.
    */
-  get: function (browser) {
-    return TabStateCacheInternal.get(browser);
+  get: function (browserOrTab) {
+    return TabStateCacheInternal.get(browserOrTab);
   },
 
   /**
-   * Updates cached data for a given |browser|.
+   * Updates cached data for a given |tab| or associated |browser|.
    *
-   * @param browser (xul:browser)
-   *        The browser belonging to the given tab data.
+   * @param browserOrTab (xul:tab or xul:browser)
+   *        The tab or browser belonging to the given tab data.
    * @param newData (object)
-   *        The new data to be stored for the given |browser|.
+   *        The new data to be stored for the given |tab|
+   *        or associated |browser|.
    */
-  update: function (browser, newData) {
-    TabStateCacheInternal.update(browser, newData);
+  update: function (browserOrTab, newData) {
+    TabStateCacheInternal.update(browserOrTab, newData);
   }
 });
 
 let TabStateCacheInternal = {
   _data: new WeakMap(),
 
   /**
-   * Retrieves cached data for a given |browser|.
+   * Retrieves cached data for a given |tab| or associated |browser|.
    *
-   * @param browser (xul:browser)
-   *        The browser to retrieve cached data for.
+   * @param browserOrTab (xul:tab or xul:browser)
+   *        The tab or browser to retrieve cached data for.
    * @return (object)
-   *         The cached data stored for the given |browser|.
+   *         The cached data stored for the given |tab|
+   *         or associated |browser|.
    */
-  get: function (browser) {
-    return this._data.get(browser.permanentKey);
+  get: function (browserOrTab) {
+    return this._data.get(browserOrTab.permanentKey);
   },
 
   /**
-   * Updates cached data for a given |browser|.
+   * Updates cached data for a given |tab| or associated |browser|.
    *
-   * @param browser (xul:browser)
-   *        The browser belonging to the given tab data.
+   * @param browserOrTab (xul:tab or xul:browser)
+   *        The tab or browser belonging to the given tab data.
    * @param newData (object)
-   *        The new data to be stored for the given |browser|.
+   *        The new data to be stored for the given |tab|
+   *        or associated |browser|.
    */
-  update: function (browser, newData) {
-    let data = this._data.get(browser.permanentKey) || {};
+  update: function (browserOrTab, newData) {
+    let data = this._data.get(browserOrTab.permanentKey) || {};
 
     for (let key of Object.keys(newData)) {
       let value = newData[key];
       if (value === null) {
         delete data[key];
       } else {
         data[key] = value;
       }
     }
 
-    this._data.set(browser.permanentKey, data);
+    this._data.set(browserOrTab.permanentKey, data);
   }
 };