Bug 1171708 - Add flushWindow method to TabStateFlusher. r?billm draft
authorMike Conley <mconley@mozilla.com>
Fri, 06 Nov 2015 13:09:14 -0500
changeset 308813 91d8ab369785377c2967f475acc0de4830e581df
parent 308812 2987b998b7ce2fb92138f04d27d0a9a43faedeee
child 308814 ff963e1c01623c9a0e8103cc3aff85ca93add7f2
child 308837 a15834e739c98140e21438031c791c2ae5792a8b
child 308844 c84d9f53b335701b92816e3b24f4f7013dc63f42
push id7531
push usermconley@mozilla.com
push dateFri, 13 Nov 2015 22:48:42 +0000
reviewersbillm
bugs1171708
milestone45.0a1
Bug 1171708 - Add flushWindow method to TabStateFlusher. r?billm
browser/components/sessionstore/TabStateFlusher.jsm
--- a/browser/components/sessionstore/TabStateFlusher.jsm
+++ b/browser/components/sessionstore/TabStateFlusher.jsm
@@ -23,16 +23,24 @@ this.TabStateFlusher = Object.freeze({
    * resolve when we heard back from the content process and the parent has
    * all the latest data.
    */
   flush(browser) {
     return TabStateFlusherInternal.flush(browser);
   },
 
   /**
+   * Requests an async flush for all browsers of a given window. Returns a Promise
+   * that will resolve when we've heard back from all browsers.
+   */
+  flushWindow(window) {
+    return TabStateFlusherInternal.flushWindow(window);
+  },
+
+  /**
    * Resolves the flush request with the given flush ID.
    */
   resolve(browser, flushID) {
     TabStateFlusherInternal.resolve(browser, flushID);
   },
 
   /**
    * Resolves all active flush requests for a given browser. This should be
@@ -71,16 +79,26 @@ var TabStateFlusherInternal = {
       perBrowserRequests.set(id, resolve);
 
       // Update the flush requests stored per browser.
       this._requests.set(permanentKey, perBrowserRequests);
     });
   },
 
   /**
+   * Requests an async flush for all browsers of a given window. Returns a Promise
+   * that will resolve when we've heard back from all browsers.
+   */
+  flushWindow(window) {
+    let browsers = window.gBrowser.browsers;
+    let promises = browsers.map((browser) => this.flush(browser));
+    return Promise.all(promises);
+  },
+
+  /**
    * Resolves the flush request with the given flush ID.
    */
   resolve(browser, flushID) {
     // Nothing to do if there are no pending flushes for the given browser.
     if (!this._requests.has(browser.permanentKey)) {
       return;
     }