Bug 1472491: Part 5ε - Add PurgeSessionHistoryChild actor. r=mconley
authorKris Maglione <maglione.k@gmail.com>
Mon, 30 Jul 2018 10:14:12 -0700
changeset 431484 2d586e4a214e2e03b7c596872691f57acf240dcb
parent 431483 b683542cac352cb84c409aa52827accc0669a856
child 431485 1194a1b4bf239c861da8f8f89ab5e8dacb68848c
push id34443
push usercsabou@mozilla.com
push dateWed, 15 Aug 2018 00:53:32 +0000
treeherdermozilla-central@b80906e2fbc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1472491
milestone63.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 1472491: Part 5ε - Add PurgeSessionHistoryChild actor. r=mconley MozReview-Commit-ID: 7oOXuPNsPPG
toolkit/actors/PurgeSessionHistoryChild.jsm
toolkit/actors/moz.build
toolkit/content/browser-content.js
toolkit/modules/ActorManagerParent.jsm
new file mode 100644
--- /dev/null
+++ b/toolkit/actors/PurgeSessionHistoryChild.jsm
@@ -0,0 +1,39 @@
+/* vim: set ts=2 sw=2 sts=2 et tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+var EXPORTED_SYMBOLS = ["PurgeSessionHistoryChild"];
+
+ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
+
+class PurgeSessionHistoryChild extends ActorChild {
+  receiveMessage(message) {
+    if (message.name != "Browser:PurgeSessionHistory") {
+      return;
+    }
+    let sessionHistory = this.docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
+    if (!sessionHistory) {
+      return;
+    }
+
+    // place the entry at current index at the end of the history list, so it won't get removed
+    if (sessionHistory.index < sessionHistory.count - 1) {
+      let legacy = sessionHistory.legacySHistory;
+      legacy.QueryInterface(Ci.nsISHistoryInternal);
+      let indexEntry = legacy.getEntryAtIndex(sessionHistory.index, false);
+      indexEntry.QueryInterface(Ci.nsISHEntry);
+      legacy.addEntry(indexEntry, true);
+    }
+
+    let purge = sessionHistory.count;
+    if (this.content.location.href != "about:blank") {
+      --purge; // Don't remove the page the user's staring at from shistory
+    }
+
+    if (purge > 0) {
+      sessionHistory.legacySHistory.PurgeHistory(purge);
+    }
+  }
+}
--- a/toolkit/actors/moz.build
+++ b/toolkit/actors/moz.build
@@ -5,15 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 FINAL_TARGET_FILES.actors += [
     'AudioPlaybackChild.jsm',
     'DateTimePickerChild.jsm',
     'FindBarChild.jsm',
     'PopupBlockingChild.jsm',
     'PrintingChild.jsm',
+    'PurgeSessionHistoryChild.jsm',
     'SelectChild.jsm',
     'SelectionSourceChild.jsm',
     'ThumbnailsChild.jsm',
     'UnselectedTabHoverChild.jsm',
     'WebChannelChild.jsm',
     'ZoomChild.jsm',
 ]
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -41,40 +41,16 @@ var AutoScrollListener = {
         this._controller = new AutoScrollController(global);
       }
       this._controller.handleEvent(event);
     }
   }
 };
 Services.els.addSystemEventListener(global, "mousedown", AutoScrollListener, true);
 
-addMessageListener("Browser:PurgeSessionHistory", function BrowserPurgeHistory() {
-  let sessionHistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
-  if (!sessionHistory) {
-    return;
-  }
-
-  // place the entry at current index at the end of the history list, so it won't get removed
-  if (sessionHistory.index < sessionHistory.count - 1) {
-    let legacy = sessionHistory.legacySHistory;
-    legacy.QueryInterface(Ci.nsISHistoryInternal);
-    let indexEntry = legacy.getEntryAtIndex(sessionHistory.index, false);
-    indexEntry.QueryInterface(Ci.nsISHEntry);
-    legacy.addEntry(indexEntry, true);
-  }
-
-  let purge = sessionHistory.count;
-  if (global.content.location.href != "about:blank") {
-    --purge; // Don't remove the page the user's staring at from shistory
-  }
-
-  if (purge > 0) {
-    sessionHistory.legacySHistory.PurgeHistory(purge);
-  }
-});
 
 let AutoComplete = {
   _connected: false,
 
   init() {
     addEventListener("unload", this, {once: true});
     addEventListener("DOMContentLoaded", this, {once: true});
     // WebExtension browserAction is preloaded and does not receive DCL, wait
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -151,16 +151,25 @@ let ACTORS = {
         "Printing:Preview:Exit",
         "Printing:Preview:Navigate",
         "Printing:Preview:ParseDocument",
         "Printing:Print",
       ],
     },
   },
 
+  PurgeSessionHistory: {
+    child: {
+      module: "resource://gre/actors/PurgeSessionHistoryChild.jsm",
+      messages: [
+        "Browser:PurgeSessionHistory",
+      ],
+    },
+  },
+
   Select: {
     child: {
       module: "resource://gre/actors/SelectChild.jsm",
       events: {
         "mozshowdropdown": {},
         "mozshowdropdown-sourcetouch": {},
       },
     },