Bug 1301160 - Part 1 - Include tab IDs in the session store data. r=sebastian
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 04 Jan 2017 15:34:11 +0100
changeset 374393 99c708631eee0d35590ca719671ea3d75ebf4b92
parent 374392 af1e1981ddc8806263292f1f72f01e13eed1f35d
child 374394 5fae18a086f5845d443172f977d25b3c34c82593
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1301160
milestone53.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 1301160 - Part 1 - Include tab IDs in the session store data. r=sebastian Having the previous tab ID in the session store data is required in order to be able to create a mapping between old and new IDs on starting up. Likewise, the parent ID now needs to be tracked on the Gecko side as well, so it can be saved by the session store and later used when restoring a tab/session. MozReview-Commit-ID: 3zwoZ9YpZlC
mobile/android/chrome/content/browser.js
mobile/android/components/SessionStore.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3478,22 +3478,24 @@ Tab.prototype = {
             { name: "getNextTabId", sig: "()I" }
           ],
         });
         this.id = jTabs.getNextTabId();
         JNI.UnloadClasses(jenv);
       }
 
       this.desktopMode = ("desktopMode" in aParams) ? aParams.desktopMode : false;
+      this.parentId = ("parentId" in aParams && typeof aParams.parentId == "number")
+                      ? aParams.parentId : -1;
 
       let message = {
         type: "Tab:Added",
         tabID: this.id,
         uri: truncate(uri, MAX_URI_LENGTH),
-        parentId: ("parentId" in aParams) ? aParams.parentId : -1,
+        parentId: this.parentId,
         tabIndex: ("tabIndex" in aParams) ? aParams.tabIndex : -1,
         external: ("external" in aParams) ? aParams.external : false,
         selected: ("selected" in aParams || aParams.cancelEditMode === true)
                   ? aParams.selected !== false || aParams.cancelEditMode === true : true,
         cancelEditMode: aParams.cancelEditMode === true,
         title: truncate(title, MAX_TITLE_LENGTH),
         delayLoad: aParams.delayLoad || false,
         desktopMode: this.desktopMode,
@@ -3533,26 +3535,28 @@ Tab.prototype = {
     this.browser.addEventListener("PluginBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingCast", this, true, true);
 
     Services.obs.addObserver(this, "before-first-paint", false);
     Services.obs.addObserver(this, "media-playback", false);
     Services.obs.addObserver(this, "media-playback-resumed", false);
 
-    // Always intialise new tabs with basic session store data to avoid
+    // Always initialise new tabs with basic session store data to avoid
     // problems with functions that always expect it to be present
     this.browser.__SS_data = {
       entries: [{
         url: aURL,
         title: truncate(title, MAX_TITLE_LENGTH)
       }],
       index: 1,
       desktopMode: this.desktopMode,
-      isPrivate: isPrivate
+      isPrivate: isPrivate,
+      tabId: this.id,
+      parentId: this.parentId
     };
 
     if (aParams.delayLoad) {
       // If this is a zombie tab, mark the browser for delay loading, which will
       // restore the tab when selected using the session data added above
       this.browser.__SS_restore = true;
     } else {
       let flags = "flags" in aParams ? aParams.flags : Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -1018,21 +1018,24 @@ SessionStore.prototype = {
     // If this browser is being restored, skip any session save activity
     if (aBrowser.__SS_restore) {
       return;
     }
 
     aHistory = aHistory || { entries: [{ url: aBrowser.currentURI.spec, title: aBrowser.contentTitle }], index: 1 };
 
     let tabData = {};
+    let tab = aWindow.BrowserApp.getTabForBrowser(aBrowser);
     tabData.entries = aHistory.entries;
     tabData.index = aHistory.index;
     tabData.attributes = { image: aBrowser.mIconURL };
-    tabData.desktopMode = aWindow.BrowserApp.getTabForBrowser(aBrowser).desktopMode;
+    tabData.desktopMode = tab.desktopMode;
     tabData.isPrivate = aBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing;
+    tabData.tabId = tab.id;
+    tabData.parentId = tab.parentId;
 
     aBrowser.__SS_data = tabData;
   },
 
   _collectWindowData: function ss__collectWindowData(aWindow) {
     // Ignore windows not tracked by SessionStore
     if (!aWindow.__SSID || !this._windows[aWindow.__SSID]) {
       return;
@@ -1639,20 +1642,20 @@ SessionStore.prototype = {
           delayLoad: true,
           title: entry.title,
           desktopMode: (tabData.desktopMode == true),
           isPrivate: (tabData.isPrivate == true)
         };
         tab = window.BrowserApp.addTab(entry.url, params);
       } else {
         tab = window.BrowserApp.getTabForId(tabData.tabId);
-        delete tabData.tabId;
 
         // Don't restore tab if user has closed it
         if (tab == null) {
+          delete tabData.tabId;
           continue;
         }
       }
 
       tab.browser.__SS_data = tabData;
       tab.browser.__SS_extdata = tabData.extData;
 
       if (window.BrowserApp.selectedTab == tab) {