Bug 1058550 - Data use alert isn't showed when limit is passed. r=vchang, a=bajaj
authorAlbert Crespell <acperez@tid.es>
Tue, 02 Sep 2014 15:22:25 +0200
changeset 224719 aadfdeffc7564eda326e4f38ab8359322a60e294
parent 224718 f2834ac816b245fa5273b07afad06f8a8fc6cdd2
child 224720 630e8e47d348fbe9d2be2b82be976a1710cffd9b
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang, bajaj
bugs1058550
milestone34.0a2
Bug 1058550 - Data use alert isn't showed when limit is passed. r=vchang, a=bajaj
dom/network/NetworkStatsService.jsm
--- a/dom/network/NetworkStatsService.jsm
+++ b/dom/network/NetworkStatsService.jsm
@@ -19,18 +19,17 @@ Cu.import("resource://gre/modules/XPCOMU
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetworkStatsDB.jsm");
 
 const NET_NETWORKSTATSSERVICE_CONTRACTID = "@mozilla.org/network/netstatsservice;1";
 const NET_NETWORKSTATSSERVICE_CID = Components.ID("{18725604-e9ac-488a-8aa0-2471e7f6c0a4}");
 
 const TOPIC_BANDWIDTH_CONTROL = "netd-bandwidth-control"
 
-const TOPIC_INTERFACE_REGISTERED   = "network-interface-registered";
-const TOPIC_INTERFACE_UNREGISTERED = "network-interface-unregistered";
+const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
 const NET_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
 const NET_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
 
 // Networks have different status that NetworkStats API needs to be aware of.
 // Network is present and ready, so NetworkManager provides the whole info.
 const NETWORK_STATUS_READY   = 0;
 // Network is present but hasn't established a connection yet (e.g. SIM that has not
 // enabled 3G since boot).
@@ -69,18 +68,17 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "@mozilla.org/system-message-internal;1",
                                    "nsISystemMessagesInternal");
 
 this.NetworkStatsService = {
   init: function() {
     debug("Service started");
 
     Services.obs.addObserver(this, "xpcom-shutdown", false);
-    Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, false);
-    Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, false);
+    Services.obs.addObserver(this, TOPIC_CONNECTION_STATE_CHANGED, false);
     Services.obs.addObserver(this, TOPIC_BANDWIDTH_CONTROL, false);
     Services.obs.addObserver(this, "profile-after-change", false);
 
     this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
     // Object to store network interfaces, each network interface is composed
     // by a network object (network type and network Id) and a interfaceName
     // that contains the name of the physical interface (wlan0, rmnet0, etc.).
@@ -178,18 +176,17 @@ this.NetworkStatsService = {
       case "NetworkStats:MaxStorageAge":
         // This message is sync.
         return this._db.maxStorageSamples * this._db.sampleRate;
     }
   },
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
-      case TOPIC_INTERFACE_REGISTERED:
-      case TOPIC_INTERFACE_UNREGISTERED:
+      case TOPIC_CONNECTION_STATE_CHANGED:
 
         // If new interface is registered (notified from NetworkService),
         // the stats are updated for the new interface without waiting to
         // complete the updating period.
 
         let network = aSubject.QueryInterface(Ci.nsINetworkInterface);
         debug("Network " + network.name + " of type " + network.type + " status change");
 
@@ -223,18 +220,17 @@ this.NetworkStatsService = {
         debug("Service shutdown");
 
         this.messages.forEach(function(aMsgName) {
           ppmm.removeMessageListener(aMsgName, this);
         }, this);
 
         Services.obs.removeObserver(this, "xpcom-shutdown");
         Services.obs.removeObserver(this, "profile-after-change");
-        Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
-        Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
+        Services.obs.removeObserver(this, TOPIC_CONNECTION_STATE_CHANGED);
         Services.obs.removeObserver(this, TOPIC_BANDWIDTH_CONTROL);
 
         this.timer.cancel();
         this.timer = null;
 
         // Update stats before shutdown
         this.updateAllStats();
         break;