Skip to content

Commit

Permalink
Bug 811778 - Only send crash reports on wifi. r=fabrice, a=blocking-b…
Browse files Browse the repository at this point in the history
…asecamp
  • Loading branch information
hfiguiere committed Nov 26, 2012
1 parent 863b76f commit b2b478f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions b2g/chrome/content/shell.js
Expand Up @@ -77,6 +77,13 @@ var shell = {
return this.CrashSubmit;
},

onlineForCrashReport: function shell_onlineForCrashReport() {
let wifiManager = navigator.mozWifiManager;
let onWifi = (wifiManager &&
(wifiManager.connection.status == 'connected'));
return !Services.io.offline && onWifi;
},

reportCrash: function shell_reportCrash(isChrome, aCrashID) {
let crashID = aCrashID;
try {
Expand Down Expand Up @@ -109,16 +116,19 @@ var shell = {

// This function submits a crash when we're online.
submitCrash: function shell_submitCrash(aCrashID) {
if (!Services.io.offline) {
if (this.onlineForCrashReport()) {
this.CrashSubmit.submit(aCrashID);
return;
}

Services.obs.addObserver(function observer(subject, topic, state) {
if (state == 'online') {
let network = subject.QueryInterface(Ci.nsINetworkInterface);
if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
&& network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
shell.CrashSubmit.submit(aCrashID);
Services.obs.removeObserver(observer, topic);
}
}, "network:offline-status-changed", false);
}, "network-interface-state-changed", false);
},

get contentBrowser() {
Expand Down

0 comments on commit b2b478f

Please sign in to comment.