зеркало из https://github.com/mozilla/gecko-dev.git
Bug 976897 - Define new notification between NetworkManager and outer modules to prevent the race condition of setting routes and using network interface. r=vyang.
This commit is contained in:
Родитель
7286272afa
Коммит
06dc584c4c
|
@ -199,7 +199,7 @@ var shell = {
|
|||
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
}
|
||||
}, "network-interface-state-changed", false);
|
||||
}, "network-connection-state-changed", false);
|
||||
},
|
||||
|
||||
get contentBrowser() {
|
||||
|
|
|
@ -39,7 +39,7 @@ const kSmsReadSuccessObserverTopic = "sms-read-success";
|
|||
const kSmsReadErrorObserverTopic = "sms-read-error";
|
||||
|
||||
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
||||
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
|
||||
const kNetworkConnStateChangedTopic = "network-connection-state-changed";
|
||||
const kMobileMessageDeletedObserverTopic = "mobile-message-deleted";
|
||||
|
||||
const kPrefRilRadioDisabled = "ril.radio.disabled";
|
||||
|
@ -233,7 +233,7 @@ MmsConnection.prototype = {
|
|||
},
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic,
|
||||
Services.obs.addObserver(this, kNetworkConnStateChangedTopic,
|
||||
false);
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
this.settings.forEach(function(name) {
|
||||
|
@ -406,7 +406,7 @@ MmsConnection.prototype = {
|
|||
|
||||
shutdown: function() {
|
||||
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
|
||||
Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
|
||||
|
||||
this.connectTimer.cancel();
|
||||
this.flushPendingCallbacks(_HTTP_STATUS_RADIO_DISABLED);
|
||||
|
@ -418,7 +418,7 @@ MmsConnection.prototype = {
|
|||
|
||||
observe: function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case kNetworkInterfaceStateChangedTopic: {
|
||||
case kNetworkConnStateChangedTopic: {
|
||||
// The network for MMS connection must be nsIRilNetworkInterface.
|
||||
if (!(subject instanceof Ci.nsIRilNetworkInterface)) {
|
||||
return;
|
||||
|
|
|
@ -40,6 +40,7 @@ const TOPIC_ACTIVE_CHANGED = "network-active-changed";
|
|||
const TOPIC_MOZSETTINGS_CHANGED = "mozsettings-changed";
|
||||
const TOPIC_PREF_CHANGED = "nsPref:changed";
|
||||
const TOPIC_XPCOM_SHUTDOWN = "xpcom-shutdown";
|
||||
const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
|
||||
const PREF_MANAGE_OFFLINE_STATUS = "network.gonk.manage-offline-status";
|
||||
|
||||
const POSSIBLE_USB_INTERFACE_NAME = "rndis0,usb0";
|
||||
|
@ -276,6 +277,11 @@ NetworkManager.prototype = {
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Notify outer modules like MmsService to start the transaction after
|
||||
// the configuration of the network interface is done.
|
||||
Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED, null);
|
||||
#endif
|
||||
break;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
case TOPIC_INTERFACE_REGISTERED:
|
||||
|
|
|
@ -69,6 +69,7 @@ const CDMAICCINFO_CID =
|
|||
|
||||
const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown";
|
||||
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
|
||||
const kNetworkConnStateChangedTopic = "network-connection-state-changed";
|
||||
const kSmsReceivedObserverTopic = "sms-received";
|
||||
const kSilentSmsReceivedObserverTopic = "silent-sms-received";
|
||||
const kSmsSendingObserverTopic = "sms-sending";
|
||||
|
@ -1901,7 +1902,7 @@ function RadioInterface(aClientId, aWorkerMessenger) {
|
|||
Services.obs.addObserver(this, kSysClockChangeObserverTopic, false);
|
||||
Services.obs.addObserver(this, kScreenStateChangedTopic, false);
|
||||
|
||||
Services.obs.addObserver(this, kNetworkInterfaceStateChangedTopic, false);
|
||||
Services.obs.addObserver(this, kNetworkConnStateChangedTopic, false);
|
||||
Services.prefs.addObserver(kPrefCellBroadcastDisabled, this, false);
|
||||
|
||||
this.portAddressedSmsApps = {};
|
||||
|
@ -1940,7 +1941,7 @@ RadioInterface.prototype = {
|
|||
Services.obs.removeObserver(this, kMozSettingsChangedObserverTopic);
|
||||
Services.obs.removeObserver(this, kSysClockChangeObserverTopic);
|
||||
Services.obs.removeObserver(this, kScreenStateChangedTopic);
|
||||
Services.obs.removeObserver(this, kNetworkInterfaceStateChangedTopic);
|
||||
Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -3182,7 +3183,7 @@ RadioInterface.prototype = {
|
|||
}
|
||||
this._sntp.updateOffset(offset);
|
||||
break;
|
||||
case kNetworkInterfaceStateChangedTopic:
|
||||
case kNetworkConnStateChangedTopic:
|
||||
let network = subject.QueryInterface(Ci.nsINetworkInterface);
|
||||
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
return;
|
||||
|
|
|
@ -68,7 +68,7 @@ function setEmulatorAPN() {
|
|||
function waitNetworkConnected(networkType) {
|
||||
log("wait network " + networkType + " connected");
|
||||
|
||||
let interfaceStateChangeTopic = "network-interface-state-changed";
|
||||
let interfaceStateChangeTopic = "network-connection-state-changed";
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
let deferred = Promise.defer();
|
||||
|
||||
|
@ -90,7 +90,7 @@ function waitNetworkConnected(networkType) {
|
|||
function waitNetworkDisconnected(networkType) {
|
||||
log("wait network " + networkType + " disconnected");
|
||||
|
||||
let interfaceStateChangeTopic = "network-interface-state-changed";
|
||||
let interfaceStateChangeTopic = "network-connection-state-changed";
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
let deferred = Promise.defer();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче