browser/modules/TabCrashReporter.jsm

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 let Cc = Components.classes;
     8 let Ci = Components.interfaces;
     9 let Cu = Components.utils;
    11 this.EXPORTED_SYMBOLS = [ "TabCrashReporter" ];
    13 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    14 Cu.import("resource://gre/modules/Services.jsm");
    16 XPCOMUtils.defineLazyModuleGetter(this, "CrashSubmit",
    17   "resource://gre/modules/CrashSubmit.jsm");
    19 this.TabCrashReporter = {
    20   init: function () {
    21     if (this.initialized)
    22       return;
    23     this.initialized = true;
    25     Services.obs.addObserver(this, "ipc:content-shutdown", false);
    26     Services.obs.addObserver(this, "oop-frameloader-crashed", false);
    28     this.childMap = new Map();
    29     this.browserMap = new WeakMap();
    30   },
    32   observe: function (aSubject, aTopic, aData) {
    33     switch (aTopic) {
    34       case "ipc:content-shutdown":
    35         aSubject.QueryInterface(Ci.nsIPropertyBag2);
    37         if (!aSubject.get("abnormal"))
    38           return;
    40         this.childMap.set(aSubject.get("childID"), aSubject.get("dumpID"));
    41         break;
    43       case "oop-frameloader-crashed":
    44         aSubject.QueryInterface(Ci.nsIFrameLoader);
    46         let browser = aSubject.ownerElement;
    47         if (!browser)
    48           return;
    50         this.browserMap.set(browser, aSubject.childID);
    51         break;
    52     }
    53   },
    55   submitCrashReport: function (aBrowser) {
    56     let childID = this.browserMap.get(aBrowser);
    57     let dumpID = this.childMap.get(childID);
    58     if (!dumpID)
    59       return
    61     if (CrashSubmit.submit(dumpID)) {
    62       this.childMap.set(childID, null); // Avoid resubmission.
    63     }
    64   },
    66   onAboutTabCrashedLoad: function (aBrowser) {
    67     if (!this.childMap)
    68       return;
    70     let dumpID = this.childMap.get(this.browserMap.get(aBrowser));
    71     if (!dumpID)
    72       return;
    74     aBrowser.contentDocument.documentElement.classList.add("crashDumpAvaible");
    75   }
    76 }

mercurial