browser/modules/TabCrashReporter.jsm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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