Backed out 17 changesets (bug 843452)
authorWes Kocher <wkocher@mozilla.com>
Thu, 28 Aug 2014 16:51:41 -0700
changeset 224047 de824c1ec349b605618a5641bd4aa81e18c56775
parent 224046 c65a8e93d3552b6cf0b23bbfc6470279905171e1
child 224048 100b82ca2f3f2bfebb8f2bba94942cd00af98990
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)
bugs843452
milestone34.0a1
backs oute72a0297d488893caff937f512c34817c62c4198
73f62ce4190f9ff238ea2c30acde5f38dc01701c
6d4a49ebd9fc9e87dfa472cac8fe001e2178ab7b
ac93e396669f536b591b43edfe885402d3f16e6b
cf4fc721821ec68df1dcd9f3baf4de522d551598
9a94ea71d232a52ef12d25730edba42365b75448
b95ff097374d706aa9abc08944865265ea6f1441
8d6428a93500bef32e830827a669da24de805137
e31b86ef0e80e3e281a0c4ab50ef4cda61cd0240
bd4efde535cd39ee20f93a67c54f575c26fe21b4
02bbcd8ac571f0ee65ca6172c941352c12249389
f7f41bf82b22dded5266e7583c4aa4314886494f
20f42764cd38c81d2a34dc0c8b5b536f8aa40bd5
82f8670f5c179b3519e7d710ed1ca81b39baedd8
52f25f1278e3c8a3db134487122712f155aca361
181337820a7cc992678276253c32a1691895fb88
9bd12641af031cd1693c52a0edc8aed9583aaf91
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 17 changesets (bug 843452) Backed out changeset e72a0297d488 (bug 843452) Backed out changeset 73f62ce4190f (bug 843452) Backed out changeset 6d4a49ebd9fc (bug 843452) Backed out changeset ac93e396669f (bug 843452) Backed out changeset cf4fc721821e (bug 843452) Backed out changeset 9a94ea71d232 (bug 843452) Backed out changeset b95ff097374d (bug 843452) Backed out changeset 8d6428a93500 (bug 843452) Backed out changeset e31b86ef0e80 (bug 843452) Backed out changeset bd4efde535cd (bug 843452) Backed out changeset 02bbcd8ac571 (bug 843452) Backed out changeset f7f41bf82b22 (bug 843452) Backed out changeset 20f42764cd38 (bug 843452) Backed out changeset 82f8670f5c17 (bug 843452) Backed out changeset 52f25f1278e3 (bug 843452) Backed out changeset 181337820a7c (bug 843452) Backed out changeset 9bd12641af03 (bug 843452)
b2g/installer/package-manifest.in
dom/bluetooth/BluetoothRilListener.cpp
dom/bluetooth/BluetoothRilListener.h
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth2/BluetoothRilListener.cpp
dom/bluetooth2/BluetoothRilListener.h
dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth2/bluez/BluetoothHfpManager.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/mobileconnection/interfaces/moz.build
dom/mobileconnection/interfaces/nsIMobileConnectionGonkService.idl
dom/mobileconnection/interfaces/nsIMobileConnectionProvider.idl
dom/mobileconnection/interfaces/nsIMobileConnectionService.idl
dom/mobileconnection/src/DOMMMIError.cpp
dom/mobileconnection/src/DOMMMIError.h
dom/mobileconnection/src/MobileCellInfo.cpp
dom/mobileconnection/src/MobileCellInfo.h
dom/mobileconnection/src/MobileConnection.cpp
dom/mobileconnection/src/MobileConnection.h
dom/mobileconnection/src/MobileConnectionCallback.cpp
dom/mobileconnection/src/MobileConnectionCallback.h
dom/mobileconnection/src/MobileConnectionInfo.cpp
dom/mobileconnection/src/MobileConnectionInfo.h
dom/mobileconnection/src/MobileNetworkInfo.cpp
dom/mobileconnection/src/MobileNetworkInfo.h
dom/mobileconnection/src/gonk/MobileConnectionGonkService.js
dom/mobileconnection/src/gonk/MobileConnectionGonkService.manifest
dom/mobileconnection/src/ipc/MobileConnectionChild.cpp
dom/mobileconnection/src/ipc/MobileConnectionChild.h
dom/mobileconnection/src/ipc/MobileConnectionIPCSerializer.h
dom/mobileconnection/src/ipc/MobileConnectionIPCService.cpp
dom/mobileconnection/src/ipc/MobileConnectionIPCService.h
dom/mobileconnection/src/ipc/MobileConnectionParent.cpp
dom/mobileconnection/src/ipc/MobileConnectionParent.h
dom/mobileconnection/src/ipc/PMobileConnection.ipdl
dom/mobileconnection/src/ipc/PMobileConnectionRequest.ipdl
dom/mobileconnection/src/ipc/PMobileConnectionTypes.ipdlh
dom/mobileconnection/src/moz.build
dom/mobilemessage/src/gonk/MmsService.js
dom/moz.build
dom/phonenumberutils/PhoneNumberUtils.jsm
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/NetworkManager.js
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/RadioInterfaceLayer.manifest
dom/system/gonk/nsIRadioInterfaceLayer.idl
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_icc_ICCUtilsHelper.js
dom/system/gonk/tests/test_ril_worker_mmi.js
dom/system/gonk/tests/test_ril_worker_mmi_cf.js
dom/webidl/DOMMMIError.webidl
dom/webidl/MozMobileConnection.webidl
dom/webidl/MozMobileConnectionArray.webidl
dom/webidl/MozMobileNetworkInfo.webidl
dom/webidl/moz.build
layout/build/nsLayoutModule.cpp
services/mobileid/MobileIdentityManager.jsm
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -436,18 +436,16 @@
 @BINPATH@/components/MmsService.manifest
 @BINPATH@/components/MobileMessageDatabaseService.js
 @BINPATH@/components/MobileMessageDatabaseService.manifest
 @BINPATH@/components/RadioInterfaceLayer.js
 @BINPATH@/components/RadioInterfaceLayer.manifest
 @BINPATH@/components/RILContentHelper.js
 @BINPATH@/components/TelephonyService.js
 @BINPATH@/components/TelephonyService.manifest
-@BINPATH@/components/MobileConnectionGonkService.js
-@BINPATH@/components/MobileConnectionGonkService.manifest
 #endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
 
 #ifndef MOZ_WIDGET_GONK
 @BINPATH@/components/extensions.manifest
 @BINPATH@/components/addonManager.js
 @BINPATH@/components/amContentHandler.js
 @BINPATH@/components/amInstallTrigger.js
 @BINPATH@/components/amWebInstallListener.js
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -108,22 +108,22 @@ MobileConnectionListener::NotifyUssdRece
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyDataError(const nsAString & message)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-MobileConnectionListener::NotifyCFStateChanged(bool success,
-                                               uint16_t action,
-                                               uint16_t reason,
-                                               const nsAString& number,
-                                               uint16_t timeSeconds,
-                                               uint16_t serviceClass)
+MobileConnectionListener::NotifyCFStateChange(bool success,
+                                              uint16_t action,
+                                              uint16_t reason,
+                                              const nsAString& number,
+                                              uint16_t timeSeconds,
+                                              uint16_t serviceClass)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyEmergencyCbModeChanged(bool active,
                                                        uint32_t timeoutMs)
 {
@@ -149,46 +149,28 @@ MobileConnectionListener::NotifyRadioSta
 }
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyClirModeChanged(uint32_t aMode)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP
-MobileConnectionListener::NotifyLastKnownNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionListener::NotifyLastKnownHomeNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionListener::NotifyNetworkSelectionModeChanged()
-{
-  return NS_OK;
-}
-
 bool
 MobileConnectionListener::Listen(bool aStart)
 {
-  nsCOMPtr<nsIMobileConnectionService> service =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(service, false);
+  nsCOMPtr<nsIMobileConnectionProvider> provider =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+  NS_ENSURE_TRUE(provider, false);
 
   nsresult rv;
   if (aStart) {
-    rv = service->RegisterListener(mClientId, this);
+    rv = provider->RegisterMobileConnectionMsg(mClientId, this);
   } else {
-    rv = service->UnregisterListener(mClientId, this);
+    rv = provider->UnregisterMobileConnectionMsg(mClientId, this);
   }
 
   return NS_SUCCEEDED(rv);
 }
 
 /**
  *  TelephonyListener Implementation
  */
@@ -365,23 +347,23 @@ BluetoothRilListener::Listen(bool aStart
 }
 
 void
 BluetoothRilListener::SelectClient()
 {
   // Reset mClientId
   mClientId = mMobileConnListeners.Length();
 
-  nsCOMPtr<nsIMobileConnectionService> service =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE_VOID(service);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+  NS_ENSURE_TRUE_VOID(connection);
 
   for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
     nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
-    service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
+    connection->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
     if (!voiceInfo) {
       BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
       continue;
     }
 
     nsString regState;
     voiceInfo->GetState(regState);
     if (regState.EqualsLiteral("registered")) {
--- a/dom/bluetooth/BluetoothRilListener.h
+++ b/dom/bluetooth/BluetoothRilListener.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__
 #define mozilla_dom_bluetooth_bluetoothrillistener_h__
 
 #include "BluetoothCommon.h"
 
 #include "nsAutoPtr.h"
 
 #include "nsIIccProvider.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsITelephonyService.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothRilListener;
 
 class IccListener : public nsIIccListener
 {
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsContentUtils.h"
 #include "nsIAudioManager.h"
 #include "nsIDOMIccInfo.h"
 #include "nsIIccProvider.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsIMobileNetworkInfo.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsITelephonyService.h"
 #include "nsRadioInterfaceLayer.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 
@@ -607,18 +607,18 @@ BluetoothHfpManager::HandleVolumeChanged
     sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs,
                                           new VolumeControlResultHandler());
   }
 }
 
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
 {
-  nsCOMPtr<nsIMobileConnectionService> connection =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
   connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
   NS_ENSURE_TRUE_VOID(voiceInfo);
 
   nsString type;
   voiceInfo->GetType(type);
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -23,17 +23,17 @@
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsServiceManagerUtils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMIccInfo.h"
 #include "nsIIccProvider.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsIMobileNetworkInfo.h"
 #include "nsITelephonyService.h"
 #include "nsRadioInterfaceLayer.h"
 #endif
 
 /**
  * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT
  * Capabilities" in Bluetooth hands-free profile 1.6
@@ -601,18 +601,18 @@ BluetoothHfpManager::HandleVolumeChanged
     SendCommand(RESPONSE_VGS, mCurrentVgs);
   }
 }
 
 #ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
 {
-  nsCOMPtr<nsIMobileConnectionService> connection =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
   connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
   NS_ENSURE_TRUE_VOID(voiceInfo);
 
   nsString type;
   voiceInfo->GetType(type);
--- a/dom/bluetooth2/BluetoothRilListener.cpp
+++ b/dom/bluetooth2/BluetoothRilListener.cpp
@@ -108,22 +108,22 @@ MobileConnectionListener::NotifyUssdRece
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyDataError(const nsAString & message)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-MobileConnectionListener::NotifyCFStateChanged(bool success,
-                                               uint16_t action,
-                                               uint16_t reason,
-                                               const nsAString& number,
-                                               uint16_t timeSeconds,
-                                               uint16_t serviceClass)
+MobileConnectionListener::NotifyCFStateChange(bool success,
+                                              uint16_t action,
+                                              uint16_t reason,
+                                              const nsAString& number,
+                                              uint16_t timeSeconds,
+                                              uint16_t serviceClass)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyEmergencyCbModeChanged(bool active,
                                                        uint32_t timeoutMs)
 {
@@ -149,46 +149,28 @@ MobileConnectionListener::NotifyRadioSta
 }
 
 NS_IMETHODIMP
 MobileConnectionListener::NotifyClirModeChanged(uint32_t aMode)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP
-MobileConnectionListener::NotifyLastKnownNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionListener::NotifyLastKnownHomeNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionListener::NotifyNetworkSelectionModeChanged()
-{
-  return NS_OK;
-}
-
 bool
 MobileConnectionListener::Listen(bool aStart)
 {
-  nsCOMPtr<nsIMobileConnectionService> service =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(service, false);
+  nsCOMPtr<nsIMobileConnectionProvider> provider =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+  NS_ENSURE_TRUE(provider, false);
 
   nsresult rv;
   if (aStart) {
-    rv = service->RegisterListener(mClientId, this);
+    rv = provider->RegisterMobileConnectionMsg(mClientId, this);
   } else {
-    rv = service->UnregisterListener(mClientId, this);
+    rv = provider->UnregisterMobileConnectionMsg(mClientId, this);
   }
 
   return NS_SUCCEEDED(rv);
 }
 
 /**
  *  TelephonyListener Implementation
  */
@@ -365,23 +347,23 @@ BluetoothRilListener::Listen(bool aStart
 }
 
 void
 BluetoothRilListener::SelectClient()
 {
   // Reset mClientId
   mClientId = mMobileConnListeners.Length();
 
-  nsCOMPtr<nsIMobileConnectionService> service =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE_VOID(service);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
+  NS_ENSURE_TRUE_VOID(connection);
 
   for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
     nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
-    service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
+    connection->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
     if (!voiceInfo) {
       BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
       continue;
     }
 
     nsString regState;
     voiceInfo->GetState(regState);
     if (regState.EqualsLiteral("registered")) {
--- a/dom/bluetooth2/BluetoothRilListener.h
+++ b/dom/bluetooth2/BluetoothRilListener.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_bluetooth_bluetoothrillistener_h__
 #define mozilla_dom_bluetooth_bluetoothrillistener_h__
 
 #include "BluetoothCommon.h"
 
 #include "nsAutoPtr.h"
 
 #include "nsIIccProvider.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsITelephonyService.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothRilListener;
 
 class IccListener : public nsIIccListener
 {
--- a/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth2/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "nsContentUtils.h"
 #include "nsIAudioManager.h"
 #include "nsIDOMIccInfo.h"
 #include "nsIIccProvider.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsIMobileNetworkInfo.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsITelephonyService.h"
 #include "nsRadioInterfaceLayer.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 
@@ -1059,18 +1059,18 @@ BluetoothHfpManager::HandleVolumeChanged
     sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs,
                                           new VolumeControlResultHandler());
   }
 }
 
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
 {
-  nsCOMPtr<nsIMobileConnectionService> connection =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
   connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
   NS_ENSURE_TRUE_VOID(voiceInfo);
 
   nsString type;
   voiceInfo->GetType(type);
--- a/dom/bluetooth2/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth2/bluez/BluetoothHfpManager.cpp
@@ -23,17 +23,17 @@
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsServiceManagerUtils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMIccInfo.h"
 #include "nsIIccProvider.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsIMobileNetworkInfo.h"
 #include "nsITelephonyService.h"
 #include "nsRadioInterfaceLayer.h"
 #endif
 
 /**
  * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT
  * Capabilities" in Bluetooth hands-free profile 1.6
@@ -601,18 +601,18 @@ BluetoothHfpManager::HandleVolumeChanged
     SendCommand(RESPONSE_VGS, mCurrentVgs);
   }
 }
 
 #ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
 {
-  nsCOMPtr<nsIMobileConnectionService> connection =
-    do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIMobileConnectionProvider> connection =
+    do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
   NS_ENSURE_TRUE_VOID(connection);
 
   nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
   connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
   NS_ENSURE_TRUE_VOID(voiceInfo);
 
   nsString type;
   voiceInfo->GetType(type);
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -149,21 +149,16 @@
 #include "AudioChannelService.h"
 #include "JavaScriptChild.h"
 #include "mozilla/dom/DataStoreService.h"
 #include "mozilla/dom/telephony/PTelephonyChild.h"
 #include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "mozilla/RemoteSpellCheckEngineChild.h"
 
-#ifdef MOZ_B2G_RIL
-#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
-using namespace mozilla::dom::mobileconnection;
-#endif
-
 using namespace base;
 using namespace mozilla;
 using namespace mozilla::docshell;
 using namespace mozilla::dom::bluetooth;
 using namespace mozilla::dom::devicestorage;
 using namespace mozilla::dom::ipc;
 using namespace mozilla::dom::mobilemessage;
 using namespace mozilla::dom::indexedDB;
@@ -1222,53 +1217,16 @@ ContentChild::DeallocPFileSystemRequestC
     mozilla::dom::FileSystemTaskBase* child =
       static_cast<mozilla::dom::FileSystemTaskBase*>(aFileSystem);
     // The reference is increased in FileSystemTaskBase::Start of
     // FileSystemTaskBase.cpp. We should decrease it after IPC.
     NS_RELEASE(child);
     return true;
 }
 
-PMobileConnectionChild*
-ContentChild::SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
-                                               const uint32_t& aClientId)
-{
-#ifdef MOZ_B2G_RIL
-    // Add an extra ref for IPDL. Will be released in
-    // ContentChild::DeallocPMobileConnectionChild().
-    static_cast<MobileConnectionChild*>(aActor)->AddRef();
-    return PContentChild::SendPMobileConnectionConstructor(aActor, aClientId);
-#else
-    MOZ_CRASH("No support for mobileconnection on this platform!");;
-#endif
-}
-
-PMobileConnectionChild*
-ContentChild::AllocPMobileConnectionChild(const uint32_t& aClientId)
-{
-#ifdef MOZ_B2G_RIL
-    NS_NOTREACHED("No one should be allocating PMobileConnectionChild actors");
-    return nullptr;
-#else
-    MOZ_CRASH("No support for mobileconnection on this platform!");;
-#endif
-}
-
-bool
-ContentChild::DeallocPMobileConnectionChild(PMobileConnectionChild* aActor)
-{
-#ifdef MOZ_B2G_RIL
-    // MobileConnectionChild is refcounted, must not be freed manually.
-    static_cast<MobileConnectionChild*>(aActor)->Release();
-    return true;
-#else
-    MOZ_CRASH("No support for mobileconnection on this platform!");
-#endif
-}
-
 PNeckoChild*
 ContentChild::AllocPNeckoChild()
 {
     return new NeckoChild();
 }
 
 bool
 ContentChild::DeallocPNeckoChild(PNeckoChild* necko)
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -186,24 +186,16 @@ public:
     RecvDataStoreNotify(const uint32_t& aAppId, const nsString& aName,
                         const nsString& aManifestURL) MOZ_OVERRIDE;
 
     virtual PTestShellChild* AllocPTestShellChild() MOZ_OVERRIDE;
     virtual bool DeallocPTestShellChild(PTestShellChild*) MOZ_OVERRIDE;
     virtual bool RecvPTestShellConstructor(PTestShellChild*) MOZ_OVERRIDE;
     jsipc::JavaScriptChild *GetCPOWManager();
 
-    PMobileConnectionChild*
-    SendPMobileConnectionConstructor(PMobileConnectionChild* aActor,
-                                     const uint32_t& aClientId);
-    virtual PMobileConnectionChild*
-    AllocPMobileConnectionChild(const uint32_t& aClientId) MOZ_OVERRIDE;
-    virtual bool
-    DeallocPMobileConnectionChild(PMobileConnectionChild* aActor) MOZ_OVERRIDE;
-
     virtual PNeckoChild* AllocPNeckoChild() MOZ_OVERRIDE;
     virtual bool DeallocPNeckoChild(PNeckoChild*) MOZ_OVERRIDE;
 
     virtual PScreenManagerChild*
     AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
                              float* aSystemDefaultScale,
                              bool* aSuccess) MOZ_OVERRIDE;
     virtual bool DeallocPScreenManagerChild(PScreenManagerChild*) MOZ_OVERRIDE;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -172,21 +172,16 @@ using namespace mozilla::system;
 #endif
 
 #ifdef ENABLE_TESTS
 #include "BackgroundChildImpl.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "nsIIPCBackgroundChildCreateCallback.h"
 #endif
 
-#ifdef MOZ_B2G_RIL
-#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
-using namespace mozilla::dom::mobileconnection;
-#endif
-
 #if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
 #include "mozilla/Sandbox.h"
 #endif
 
 static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
 static const char* sClipboardTextFlavors[] = { kUnicodeMime };
 
 using base::ChildPrivileges;
@@ -3092,42 +3087,16 @@ ContentParent::AllocPTestShellParent()
 
 bool
 ContentParent::DeallocPTestShellParent(PTestShellParent* shell)
 {
     delete shell;
     return true;
 }
 
-PMobileConnectionParent*
-ContentParent::AllocPMobileConnectionParent(const uint32_t& aClientId)
-{
-#ifdef MOZ_B2G_RIL
-    nsRefPtr<MobileConnectionParent> parent = new MobileConnectionParent(aClientId);
-    // We release this ref in DeallocPMobileConnectionParent().
-    parent->AddRef();
-
-    return parent;
-#else
-    MOZ_CRASH("No support for mobileconnection on this platform!");
-#endif
-}
-
-bool
-ContentParent::DeallocPMobileConnectionParent(PMobileConnectionParent* aActor)
-{
-#ifdef MOZ_B2G_RIL
-    // MobileConnectionParent is refcounted, must not be freed manually.
-    static_cast<MobileConnectionParent*>(aActor)->Release();
-    return true;
-#else
-    MOZ_CRASH("No support for mobileconnection on this platform!");
-#endif
-}
-
 PNeckoParent*
 ContentParent::AllocPNeckoParent()
 {
     return new NeckoParent();
 }
 
 bool
 ContentParent::DeallocPNeckoParent(PNeckoParent* necko)
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -458,19 +458,16 @@ private:
                                      const FileDescriptor& aGCLog,
                                      const FileDescriptor& aCCLog) MOZ_OVERRIDE;
     virtual bool
     DeallocPCycleCollectWithLogsParent(PCycleCollectWithLogsParent* aActor) MOZ_OVERRIDE;
 
     virtual PTestShellParent* AllocPTestShellParent() MOZ_OVERRIDE;
     virtual bool DeallocPTestShellParent(PTestShellParent* shell) MOZ_OVERRIDE;
 
-    virtual PMobileConnectionParent* AllocPMobileConnectionParent(const uint32_t& aClientId) MOZ_OVERRIDE;
-    virtual bool DeallocPMobileConnectionParent(PMobileConnectionParent* aActor) MOZ_OVERRIDE;
-
     virtual bool DeallocPNeckoParent(PNeckoParent* necko) MOZ_OVERRIDE;
 
     virtual PExternalHelperAppParent* AllocPExternalHelperAppParent(
             const OptionalURIParams& aUri,
             const nsCString& aMimeContentType,
             const nsCString& aContentDisposition,
             const uint32_t& aContentDispositionHint,
             const nsString& aContentDispositionFilename, 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -17,17 +17,16 @@ include protocol PExternalHelperApp;
 include protocol PDeviceStorageRequest;
 include protocol PFileDescriptorSet;
 include protocol PFMRadio;
 include protocol PFileSystemRequest;
 include protocol PHal;
 include protocol PImageBridge;
 include protocol PIndexedDB;
 include protocol PMemoryReportRequest;
-include protocol PMobileConnection;
 include protocol PNecko;
 include protocol PScreenManager;
 include protocol PSharedBufferManager;
 include protocol PSms;
 include protocol PSpeechSynthesis;
 include protocol PStorage;
 include protocol PTelephony;
 include protocol PTestShell;
@@ -306,17 +305,16 @@ intr protocol PContent
     manages PDeviceStorageRequest;
     manages PFileSystemRequest;
     manages PExternalHelperApp;
     manages PFileDescriptorSet;
     manages PFMRadio;
     manages PHal;
     manages PIndexedDB;
     manages PMemoryReportRequest;
-    manages PMobileConnection;
     manages PNecko;
     manages PScreenManager;
     manages PSms;
     manages PSpeechSynthesis;
     manages PStorage;
     manages PTelephony;
     manages PTestShell;
     manages PJavaScript;
@@ -489,18 +487,16 @@ parent:
 
     sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags)
         returns (bool isSecureURI);
 
     PHal();
 
     PIndexedDB();
 
-    PMobileConnection(uint32_t clientId);
-
     PNecko();
 
     rpc PScreenManager()
         returns (uint32_t numberOfScreens,
                  float systemDefaultScale,
                  bool success);
 
     PSms();
--- a/dom/mobileconnection/interfaces/moz.build
+++ b/dom/mobileconnection/interfaces/moz.build
@@ -3,19 +3,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsICellInfo.idl',
     'nsIMobileCellInfo.idl',
     'nsIMobileConnectionInfo.idl',
-    'nsIMobileConnectionService.idl',
+    'nsIMobileConnectionProvider.idl',
     'nsIMobileNetworkInfo.idl',
     'nsINeighboringCellInfo.idl',
 ]
 
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
-    XPIDL_SOURCES += [
-        'nsIMobileConnectionGonkService.idl',
-    ]
-
 XPIDL_MODULE = 'dom_mobileconnection'
deleted file mode 100644
--- a/dom/mobileconnection/interfaces/nsIMobileConnectionGonkService.idl
+++ /dev/null
@@ -1,49 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsIMobileConnectionService.idl"
-
-%{C++
-#define NS_MOBILECONNECTION_GONK_SERVICE_CONTRACTID \
-        "@mozilla.org/mobileconnection/mobileconnectiongonkservice;1"
-%}
-
-[scriptable, uuid(c5baceda-247a-4018-855d-ad5b00f2e4e2)]
-interface nsIMobileConnectionGonkService : nsIMobileConnectionService
-{
-  void notifyNetworkInfoChanged(in unsigned long clientId, in jsval networkInfo);
-
-  void notifyVoiceInfoChanged(in unsigned long clientId, in jsval voiceInfo);
-
-  void notifyDataInfoChanged(in unsigned long clientId, in jsval dataInfo);
-
-  void notifyDataError(in unsigned long clientId, in DOMString message);
-
-  void notifySignalStrengthChanged(in unsigned long clientId, in jsval signal);
-
-  void notifyOperatorChanged(in unsigned long clientId, in jsval info);
-
-  void notifyOtaStatusChanged(in unsigned long clientId, in DOMString status);
-
-  void notifyRadioStateChanged(in unsigned long clientId,
-                               in DOMString radioState);
-
-  void notifyUssdReceived(in unsigned long clientId,
-                          in DOMString message,
-                          in boolean sessionEnded);
-
-  void notifyEmergencyCallbackModeChanged(in unsigned long clientId,
-                                          in boolean active,
-                                          in unsigned long timeoutMs);
-
-  void notifyIccChanged(in unsigned long clientId, in DOMString iccId);
-
-  void notifyNetworkSelectModeChanged(in unsigned long clientId,
-                                      in DOMString mode);
-
-  void notifySpnAvailable(in unsigned long clientId);
-
-  void notifyLastHomeNetworkChanged(in unsigned long clientId,
-                                    in DOMString network);
-};
rename from dom/mobileconnection/interfaces/nsIMobileConnectionService.idl
rename to dom/mobileconnection/interfaces/nsIMobileConnectionProvider.idl
--- a/dom/mobileconnection/interfaces/nsIMobileConnectionService.idl
+++ b/dom/mobileconnection/interfaces/nsIMobileConnectionProvider.idl
@@ -1,19 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
+interface nsIDOMDOMRequest;
+interface nsIDOMWindow;
 interface nsIMobileConnectionInfo;
 interface nsIMobileNetworkInfo;
 interface nsIVariant;
 
-[scriptable, uuid(bc0d4d76-fd3a-4593-818f-cb6ff87fbb55)]
+[scriptable, uuid(c6d98e6a-d96f-45fe-aa86-01453a6daf9e)]
 interface nsIMobileConnectionListener : nsISupports
 {
   /**
    * Notify when voice info is changed.
    */
   void notifyVoiceChanged();
 
   /**
@@ -41,32 +43,32 @@ interface nsIMobileConnectionListener : 
   void notifyDataError(in DOMString message);
 
   /**
    * Notify when call forwarding state is changed.
    *
    * @param success
    *        Indicates whether the set call forwarding request is success.
    * @param action
-   *        One of the nsIMobileConnectionService.CALL_FORWARD_ACTION_* values.
+   *        One of the nsIMobileConnectionProvider.CALL_FORWARD_ACTION_* values.
    * @param reason
-   *        One of the nsIMobileConnectionService.CALL_FORWARD_REASON_* values.
+   *        One of the nsIMobileConnectionProvider.CALL_FORWARD_REASON_* values.
    * @param number
    *        Phone number of forwarding address.
    * @param timeSeconds
    *        The time in seconds should wait before call is forwarded.
    * @param serviceClass
-   *        One of the nsIMobileConnectionService.ICC_SERVICE_CLASS_* values.
+   *        One of the nsIMobileConnectionProvider.ICC_SERVICE_CLASS_* values.
    */
-  void notifyCFStateChanged(in boolean success,
-                            in unsigned short action,
-                            in unsigned short reason,
-                            in DOMString number,
-                            in unsigned short timeSeconds,
-                            in unsigned short serviceClass);
+  void notifyCFStateChange(in boolean success,
+                           in unsigned short action,
+                           in unsigned short reason,
+                           in DOMString number,
+                           in unsigned short timeSeconds,
+                           in unsigned short serviceClass);
 
   /**
    * Notify when emergency callback mode is changed.
    *
    * @param active
    *        Indicates whether the emergency callback mode is activated.
    * @param timeoutMs
    *        The timeout in millisecond for emergency callback mode.
@@ -94,123 +96,27 @@ interface nsIMobileConnectionListener : 
    * Notify when radio state is changed.
    */
   void notifyRadioStateChanged();
 
   /**
    * Notify when clir mode is changed.
    *
    * @param mode
-   *        One of the nsIMobileConnectionService.CLIR_* values.
+   *        One of the nsIMobileConnectionProvider.CLIR_* values.
    */
   void notifyClirModeChanged(in unsigned long mode);
-
-  /**
-   * Notify when last known network is changed.
-   */
-  void notifyLastKnownNetworkChanged();
-
-  /**
-   * Notify when last known home network is changed.
-   */
-  void notifyLastKnownHomeNetworkChanged();
-
-  /**
-   * Notify when network selection mode is changed.
-   */
-  void notifyNetworkSelectionModeChanged();
 };
 
-%{C++
-#define NO_ADDITIONAL_INFORMATION 0
-%}
-
-[scriptable, builtinclass, uuid(e9d7c247-34c6-42bf-875b-f99b19db394f)]
-interface nsIMobileConnectionCallback : nsISupports
-{
-  /**
-   * notify*Success*() will be called, when request is succeed.
-   */
-  void notifySuccess();
-
-  void notifySuccessWithString(in DOMString result);
-
-  void notifySuccessWithBoolean(in boolean result);
-
-  void notifyGetNetworksSuccess(in uint32_t count,
-                                [array, size_is(count)] in nsIMobileNetworkInfo networks);
-
-  void notifySendCancelMmiSuccess(in jsval result /* MozMMIResult */);
-
-  void notifyGetCallForwardingSuccess(in jsval results /* Array of MozCallForwardingOptions */);
-
-  void notifyGetCallBarringSuccess(in unsigned short program,
-                                   in boolean enabled,
-                                   in unsigned short serviceClass);
-
-  void notifyGetClirStatusSuccess(in unsigned short n, in unsigned short m);
-
-  /**
-   * notifyError() will be called, when request is failed.
-   */
-  [optional_argc]
-  void notifyError(in DOMString name,
-                   [optional] in DOMString message,
-                   [optional] in DOMString serviceCode,
-                   [optional] in unsigned short additionalInformation);
-
-%{C++
-  // non-virtual so it won't affect the vtable
-  inline nsresult NotifyError(const nsAString& aName)
-  {
-    return NotifyError(aName, EmptyString(), EmptyString(),
-                       NO_ADDITIONAL_INFORMATION, 0 /* ARGC = 0 */);
-  }
-  // non-virtual so it won't affect the vtable
-  inline nsresult NotifyError(const nsAString& aName,
-                              const nsAString& aMessage)
-  {
-    return NotifyError(aName, aMessage, EmptyString(), NO_ADDITIONAL_INFORMATION,
-                       1 /* ARGC = 1 */);
-  }
-  // non-virtual so it won't affect the vtable
-  inline nsresult NotifyError(const nsAString& aName,
-                              const nsAString& aMessage,
-                              const nsAString& aServiceCode)
-  {
-    return NotifyError(aName, aMessage, aServiceCode, NO_ADDITIONAL_INFORMATION,
-                       2 /* ARGC = 2 */);
-  }
-  // non-virtual so it won't affect the vtable
-  inline nsresult NotifyError(const nsAString& aName,
-                              const nsAString& aMessage,
-                              const nsAString& aServiceCode,
-                              uint16_t aAdditionInformation)
-  {
-    return NotifyError(aName, aMessage, aServiceCode, aAdditionInformation,
-                       3 /* ARGC = 3 */);
-  }
-%}
-
-};
-
-%{C++
-#define NS_MOBILE_CONNECTION_SERVICE_CID \
-  { 0xc6f229d4, 0x16e2, 0x4600, \
-    { 0x87, 0x2a, 0x3d, 0x3d, 0xc5, 0xb8, 0x55, 0x41 } }
-#define NS_MOBILE_CONNECTION_SERVICE_CONTRACTID \
-  "@mozilla.org/mobileconnection/mobileconnectionservice;1"
-%}
-
 /**
  * XPCOM component (in the content process) that provides the mobile
  * network information.
  */
-[scriptable, uuid(b50ad32d-f70e-4729-a947-e8cfdb6ba81f)]
-interface nsIMobileConnectionService : nsISupports
+[scriptable, uuid(2a3af80f-9f8e-447d-becd-034f95e4cd4d)]
+interface nsIMobileConnectionProvider : nsISupports
 {
   const long ICC_SERVICE_CLASS_VOICE      = (1 << 0);
   const long ICC_SERVICE_CLASS_DATA       = (1 << 1);
   const long ICC_SERVICE_CLASS_FAX        = (1 << 2);
   const long ICC_SERVICE_CLASS_SMS        = (1 << 3);
   const long ICC_SERVICE_CLASS_DATA_SYNC  = (1 << 4);
   const long ICC_SERVICE_CLASS_DATA_ASYNC = (1 << 5);
   const long ICC_SERVICE_CLASS_PACKET     = (1 << 6);
@@ -258,20 +164,20 @@ interface nsIMobileConnectionService : n
   const long CLIR_INVOCATION  = 1;
   const long CLIR_SUPPRESSION = 2;
 
   /**
    * Called when a content process registers receiving unsolicited messages from
    * RadioInterfaceLayer in the chrome process. Only a content process that has
    * the 'mobileconnection' permission is allowed to register.
    */
-  void registerListener(in unsigned long clientId,
-                        in nsIMobileConnectionListener listener);
-  void unregisterListener(in unsigned long clientId,
-                          in nsIMobileConnectionListener listener);
+  void registerMobileConnectionMsg(in unsigned long clientId,
+                                   in nsIMobileConnectionListener listener);
+  void unregisterMobileConnectionMsg(in unsigned long clientId,
+                                     in nsIMobileConnectionListener listener);
 
   /**
    * These two fields require the 'mobilenetwork' permission.
    */
   DOMString getLastKnownNetwork(in unsigned long clientId);
   DOMString getLastKnownHomeNetwork(in unsigned long clientId);
 
   /**
@@ -342,451 +248,502 @@ interface nsIMobileConnectionService : n
    */
   nsIVariant getSupportedNetworkTypes(in unsigned long clientId);
 
   /**
    * Search for available networks.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifyGetNetworksSuccess() will be called. And the
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called. And the request's
    * result will be an array of nsIMobileNetworkInfo.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getNetworks(in unsigned long clientId,
-                   in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getNetworks(in unsigned long clientId,
+                               in nsIDOMWindow window);
 
   /**
    * Manually selects the passed in network, overriding the radio's current
    * selection.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param network
    *        The manually selecting network.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void selectNetwork(in unsigned long clientId,
-                     in nsIMobileNetworkInfo network,
-                     in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest selectNetwork(in unsigned long clientId,
+                                 in nsIDOMWindow window,
+                                 in nsIMobileNetworkInfo network);
 
   /**
    * Tell the radio to automatically select a network.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void selectNetworkAutomatically(in unsigned long clientId,
-                                  in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId,
+                                              in nsIDOMWindow window);
 
   /**
    * Set preferred network type.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param type
    *        DOMString indicates the desired preferred network type.
    *        Possible values: 'wcdma/gsm', 'gsm', 'wcdma', 'wcdma/gsm-auto',
    *        'cdma/evdo', 'cdma', 'evdo', 'wcdma/gsm/cdma/evdo',
    *        'lte/cdma/evdo', 'lte/wcdma/gsm', 'lte/wcdma/gsm/cdma/evdo' or
    *        'lte'.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void setPreferredNetworkType(in unsigned long clientId,
-                               in DOMString type,
-                               in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setPreferredNetworkType(in unsigned long clientId,
+                                           in nsIDOMWindow window,
+                                           in DOMString type);
 
   /**
    * Query current preferred network type.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
+   *
+   * @return a nsIDOMDOMRequest
    *
-   * If successful, the notifySuccessString() will be called. And the result
-   * will be a string indicating the current preferred network type. The value
-   * will be either 'wcdma/gsm', 'gsm', 'wcdma', 'wcdma/gsm-auto', 'cdma/evdo',
-   * 'cdma', 'evdo', 'wcdma/gsm/cdma/evdo', 'lte/cdma/evdo', 'lte/wcdma/gsm',
-   * 'lte/wcdma/gsm/cdma/evdo' or 'lte'.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be a string indicating the current preferred network type.
+   * The value will be either 'wcdma/gsm', 'gsm', 'wcdma', 'wcdma/gsm-auto',
+   * 'cdma/evdo', 'cdma', 'evdo', 'wcdma/gsm/cdma/evdo', 'lte/cdma/evdo',
+   * 'lte/wcdma/gsm', 'lte/wcdma/gsm/cdma/evdo' or 'lte'.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getPreferredNetworkType(in unsigned long clientId,
-                               in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getPreferredNetworkType(in unsigned long clientId,
+                                           in nsIDOMWindow window);
 
   /**
    * Set roaming preference.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param mode
    *        DOMString indicates the desired roaming preference.
    *        Possible values: 'home', 'affiliated', or 'any'.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void setRoamingPreference(in unsigned long clientId,
-                            in DOMString mode,
-                            in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId,
+                                        in nsIDOMWindow window,
+                                        in DOMString mode);
 
   /**
    * Query current roaming preference.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifySuccessWithString() will be called. And the result
-   * will be a string indicating the current roaming preference. The value will
-   * be either 'home', 'affiliated', or 'any'.
+   * @return a nsIDOMDOMRequest
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be a string indicating the current roaming preference.
+   * The value will be either 'home', 'affiliated', or 'any'.
+   *
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getRoamingPreference(in unsigned long clientId,
-                            in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId,
+                                        in nsIDOMWindow window);
 
   /**
    * Set voice privacy preference.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param enabled
    *        Boolean indicates the preferred voice privacy mode used in voice
    *        scrambling in CDMA networks. 'True' means the enhanced voice security
    *        is required.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void setVoicePrivacyMode(in unsigned long clientId,
-                           in bool enabled,
-                           in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId,
+                                       in nsIDOMWindow window,
+                                       in bool enabled);
 
   /**
    * Query current voice privacy mode.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifySuccessWithBoolean() will be called. And the result
-   * will be a boolean indicating the current voice privacy mode.
+   * @return a nsIDOMDOMRequest
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be a boolean indicating the current voice privacy mode.
+   *
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getVoicePrivacyMode(in unsigned long clientId,
-                           in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId,
+                                       in nsIDOMWindow window);
 
   /**
    * Send a MMI message.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param mmi
    *        DOMString containing an MMI string that can be associated to a
    *        USSD request or other RIL functionality.
-   * @param requestCallback
-   *        Called when request is finished.
+   *
+   * @return a nsIDOMDOMRequest
    *
-   * If successful, the notifySendCancelMmiSuccess() will be called. And the
-   * result will contain the information about the mmi operation.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be an object containing information about the operation.
+   * @see MozMMIResult for the detail of result.
    *
-   * Otherwise, the notifyError() will be called.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be a DOMMMIError.
+   * @see DOMMMIError for the detail of error.
    */
-  void sendMMI(in unsigned long clientId,
-               in DOMString mmi,
-               in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest sendMMI(in unsigned long clientId,
+                           in nsIDOMWindow window,
+                           in DOMString mmi);
 
   /**
    * Cancel the current MMI request if one exists.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
+   *
+   * @return a nsIDOMDOMRequest
    *
-   * If successful, the notifySendCancelMmiSuccess() will be called. And the
-   * result will contain the information about the mmi operation.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be an object containing information about the operation.
+   * @see MozMMIResult for the detail of result.
    *
-   * Otherwise, the notifyError() will be called.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be a DOMMMIError.
+   * @see DOMMMIError for the detail of error.
    */
-  void cancelMMI(in unsigned long clientId,
-                 in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest cancelMMI(in unsigned long clientId,
+                             in nsIDOMWindow window);
 
   /**
    * Queries current call forwarding options.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param reason
    *        Indicates the reason the call is being forwarded. It shall be one of
-   *        the nsIMobileConnectionService.CALL_FORWARD_REASON_* values.
-   * @param requestCallback
-   *        Called when request is finished.
+   *        the nsIMobileConnectionProvider.CALL_FORWARD_REASON_* values.
    *
-   * If successful, the notifyGetCallForwardingSuccess() will be called. And the
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called. And the request's
    * result will be an array of MozCallForwardingOptions.
    * @see MozCallForwardingOptions for the detail of result.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getCallForwarding(in unsigned long clientId,
-                         in unsigned short reason,
-                         in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getCallForwarding(in unsigned long clientId,
+                                     in nsIDOMWindow window,
+                                     in unsigned short reason);
 
   /**
    * Configures call forwarding options.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param options
    *        An object containing the call forward rule to set.
    * @see MozCallForwardingOptions for the detail of options.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'
    */
-  void setCallForwarding(in unsigned long clientId,
-                         in jsval options,
-                         in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setCallForwarding(in unsigned long clientId,
+                                     in nsIDOMWindow window,
+                                     in jsval options);
 
   /**
    * Queries current call barring status.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param options
    *        An object containing the call barring rule to query. No need to
    *        specify 'enabled' property.
    * @see MozCallBarringOptions for the detail of options.
-   * @param requestCallback
-   *        Called when request is finished.
+   *
+   * @return a nsIDOMDOMRequest
    *
-   * If successful, the notifyGetCallBarringSuccess() will be called. And the
-   * result will contain correct 'enabled' property indicating the status of
-   * this rule.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be an object of MozCallBarringOptions with correct 'enabled'
+   * property indicating the status of this rule.
+   * @see MozCallBarringOptions for the detail of result.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getCallBarring(in unsigned long clientId,
-                      in jsval options,
-                      in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getCallBarring(in unsigned long clientId,
+                                  in nsIDOMWindow window,
+                                  in jsval options);
 
   /**
    * Configures call barring option.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param options
    *        An object containing the call barring rule to set.
    * @see MozCallBarringOptions for the detail of options.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'
    */
-  void setCallBarring(in unsigned long clientId,
-                      in jsval options,
-                      in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setCallBarring(in unsigned long clientId,
+                                  in nsIDOMWindow window,
+                                  in jsval options);
 
   /**
    * Change call barring facility password.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param options
    *        An object containing information about pin and newPin, and,
    *        this object must have both "pin" and "newPin" attributes
    *        to change the call barring facility password.
    * @see MozCallBarringOptions for the detail of options.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void changeCallBarringPassword(in unsigned long clientId,
-                                 in jsval options,
-                                 in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId,
+                                             in nsIDOMWindow window,
+                                             in jsval options);
 
   /**
    * Configures call waiting options.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param enabled
    *        Boolean indicates the desired call waiting status.
-   * @param requestCallback
-   *        Called when request is finished.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void setCallWaiting(in unsigned long clientId,
-                      in bool enabled,
-                      in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setCallWaiting(in unsigned long clientId,
+                                  in nsIDOMWindow window,
+                                  in bool enabled);
 
   /**
    * Queries current call waiting options.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifySuccessWithBoolean() will be called. And the result
-   * will be a boolean indicating the call waiting status.
+   * @return a nsIDOMDOMRequest
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * If successful, the request's onsuccess will be called. And the request's
+   * result will be a boolean indicating the call waiting status.
+   *
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getCallWaiting(in unsigned long clientId,
-                      in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getCallWaiting(in unsigned long clientId,
+                                  in nsIDOMWindow window);
 
   /**
    * Enables or disables the presentation of the calling line identity (CLI) to
    * the called party when originating a call.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param clirMode
-   *        One of the nsIMobileConnectionService.CLIR_* values.
-   * @param requestCallback
-   *        Called when request is finished.
+   *        One of the nsIMobileConnectionProvider.CLIR_* values.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
-   * 'IllegalSIMorME', or 'GenericFailure'.
+   * If successful, the request's onsuccess will be called.
+   *
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'InvalidParameter', 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void setCallingLineIdRestriction(in unsigned long clientId,
-                                   in unsigned short clirMode,
-                                   in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId,
+                                               in nsIDOMWindow window,
+                                               in unsigned short clirMode);
 
   /**
    * Queries current CLIR status.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifyGetClirStatusSuccess() will be called. And the
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called. And the request's
    * result will be a an object containing CLIR 'n' and 'm' parameter.
    * @see MozClirStatus for the detail of result.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void getCallingLineIdRestriction(in unsigned long clientId,
-                                   in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId,
+                                               in nsIDOMWindow window);
 
   /**
    * Exit emergency callback mode.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
-   * @param requestCallback
-   *        Called when request is finished.
+   * @param window
+   *        Current window.
    *
-   * If successful, the notifySuccess() will be called.
+   * @return a nsIDOMDOMRequest
+   *
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'RadioNotAvailable', 'RequestNotSupported',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    */
-  void exitEmergencyCbMode(in unsigned long clientId,
-                           in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId,
+                                       in nsIDOMWindow window);
 
   /**
    * Set radio enabled/disabled.
    *
    * @param clientId
    *        Indicate the RIL client, 0 ~ (number of client - 1).
+   * @param window
+   *        Current window.
    * @param enabled
    *        Boolean indicates the desired radio power. True to enable the radio.
-   * @param requestCallback
-   *        Called when request is finished.
+   *
+   * @return a nsIDOMDOMRequest
    *
-   * If successful, the notifySuccess() will be called.
+   * If successful, the request's onsuccess will be called.
    *
-   * Otherwise, the notifyError() will be called, and the error will be either
-   * 'InvalidStateError', 'RadioNotAvailable', 'IllegalSIMorME', or
-   * 'GenericFailure'.
+   * Otherwise, the request's onerror will be called, and the request's error
+   * will be either 'InvalidStateError', 'RadioNotAvailable',
+   * 'IllegalSIMorME', or 'GenericFailure'.
    *
    * Note: Request is not available when radioState is null, 'enabling', or
    * 'disabling'. Calling the function in above conditions will receive
    * 'InvalidStateError' error.
    */
-  void setRadioEnabled(in unsigned long clientId,
-                       in bool enabled,
-                       in nsIMobileConnectionCallback requestCallback);
+  nsIDOMDOMRequest setRadioEnabled(in unsigned long clientId,
+                                   in nsIDOMWindow window,
+                                   in bool enabled);
 };
--- a/dom/mobileconnection/src/DOMMMIError.cpp
+++ b/dom/mobileconnection/src/DOMMMIError.cpp
@@ -1,13 +1,13 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
+* License, v. 2.0. If a copy of the MPL was not distributed with this file,
+* You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DOMMMIError.h"
 #include "mozilla/dom/DOMMMIErrorBinding.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMMIError)
 
@@ -32,8 +32,24 @@ DOMMMIError::DOMMMIError(nsPIDOMWindow* 
 {
 }
 
 JSObject*
 DOMMMIError::WrapObject(JSContext* aCx)
 {
   return DOMMMIErrorBinding::Wrap(aCx, this);
 }
+
+// WebIDL interface
+
+/* static */ already_AddRefed<DOMMMIError>
+DOMMMIError::Constructor(const GlobalObject& aGlobal,
+                         const nsAString& aServiceCode,
+                         const nsAString& aName,
+                         const nsAString& aMessage,
+                         const Nullable<int16_t>& aInfo,
+                         ErrorResult& aRv) {
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<DOMMMIError> error = new DOMMMIError(window, aName, aMessage,
+                                                aServiceCode, aInfo);
+
+  return error.forget();
+}
--- a/dom/mobileconnection/src/DOMMMIError.h
+++ b/dom/mobileconnection/src/DOMMMIError.h
@@ -1,13 +1,13 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
+* License, v. 2.0. If a copy of the MPL was not distributed with this file,
+* You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_MmiError_h
 #define mozilla_dom_MmiError_h
 
 #include "mozilla/dom/DOMError.h"
 
 namespace mozilla {
 namespace dom {
@@ -21,16 +21,20 @@ public:
   DOMMMIError(nsPIDOMWindow* aWindow, const nsAString& aName,
               const nsAString& aMessage, const nsAString& aServiceCode,
               const Nullable<int16_t>& aInfo);
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   // WebIDL interface
+  static already_AddRefed<DOMMMIError>
+  Constructor(const GlobalObject& aGlobal, const nsAString& aServiceCode,
+              const nsAString& aName, const nsAString& aMessage,
+              const Nullable<int16_t>& aInfo, ErrorResult& aRv);
 
   void
   GetServiceCode(nsString& aServiceCode) const
   {
     aServiceCode = mServiceCode;
   }
 
   Nullable<int16_t>
--- a/dom/mobileconnection/src/MobileCellInfo.cpp
+++ b/dom/mobileconnection/src/MobileCellInfo.cpp
@@ -12,53 +12,31 @@ using namespace mozilla::dom;
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MobileCellInfo, mWindow)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileCellInfo)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileCellInfo)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileCellInfo)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_INTERFACE_MAP_ENTRY(nsIMobileCellInfo)
 NS_INTERFACE_MAP_END
 
 MobileCellInfo::MobileCellInfo(nsPIDOMWindow* aWindow)
   : mWindow(aWindow)
   , mGsmLocationAreaCode(-1)
   , mGsmCellId(-1)
   , mCdmaBaseStationId(-1)
   , mCdmaBaseStationLatitude(-1)
   , mCdmaBaseStationLongitude(-1)
   , mCdmaSystemId(-1)
   , mCdmaNetworkId(-1)
 {
   SetIsDOMBinding();
 }
 
-MobileCellInfo::MobileCellInfo(int32_t aGsmLocationAreaCode,
-                               int64_t aGsmCellId,
-                               int32_t aCdmaBaseStationId,
-                               int32_t aCdmaBaseStationLatitude,
-                               int32_t aCdmaBaseStationLongitude,
-                               int32_t aCdmaSystemId,
-                               int32_t aCdmaNetworkId)
-  : mGsmLocationAreaCode(aGsmLocationAreaCode)
-  , mGsmCellId(aGsmCellId)
-  , mCdmaBaseStationId(aCdmaBaseStationId)
-  , mCdmaBaseStationLatitude(aCdmaBaseStationLatitude)
-  , mCdmaBaseStationLongitude(aCdmaBaseStationLongitude)
-  , mCdmaSystemId(aCdmaSystemId)
-  , mCdmaNetworkId(aCdmaNetworkId)
-{
-  // The instance created by this way is only used for IPC stuff. It won't be
-  // expose to JS directly, we will clone this instance to the one that is
-  // maintained in MobileConnectionChild. So we don't need SetIsDOMBinding()
-  // here.
-}
-
 void
 MobileCellInfo::Update(nsIMobileCellInfo* aInfo)
 {
   if (!aInfo) {
     return;
   }
 
   aInfo->GetGsmLocationAreaCode(&mGsmLocationAreaCode);
@@ -68,62 +46,10 @@ MobileCellInfo::Update(nsIMobileCellInfo
   aInfo->GetCdmaBaseStationLongitude(&mCdmaBaseStationLongitude);
   aInfo->GetCdmaSystemId(&mCdmaSystemId);
   aInfo->GetCdmaNetworkId(&mCdmaNetworkId);
 }
 
 JSObject*
 MobileCellInfo::WrapObject(JSContext* aCx)
 {
-  MOZ_ASSERT(IsDOMBinding());
   return MozMobileCellInfoBinding::Wrap(aCx, this);
 }
-
-// nsIMobileCellInfo
-
-NS_IMETHODIMP
-MobileCellInfo::GetGsmLocationAreaCode(int32_t* aGsmLocationAreaCode)
-{
-  *aGsmLocationAreaCode = GsmLocationAreaCode();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetGsmCellId(int64_t* aGsmCellId)
-{
-  *aGsmCellId = GsmCellId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetCdmaBaseStationId(int32_t* aCdmaBaseStationId)
-{
-  *aCdmaBaseStationId = CdmaBaseStationId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetCdmaBaseStationLatitude(int32_t* aCdmaBaseStationLatitude)
-{
-  *aCdmaBaseStationLatitude = CdmaBaseStationLatitude();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetCdmaBaseStationLongitude(int32_t* aCdmaBaseStationLongitude)
-{
-  *aCdmaBaseStationLongitude = CdmaBaseStationLongitude();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetCdmaSystemId(int32_t* aCdmaSystemId)
-{
-  *aCdmaSystemId = CdmaSystemId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileCellInfo::GetCdmaNetworkId(int32_t* aCdmaNetworkId)
-{
-  *aCdmaNetworkId = CdmaNetworkId();
-  return NS_OK;
-}
--- a/dom/mobileconnection/src/MobileCellInfo.h
+++ b/dom/mobileconnection/src/MobileCellInfo.h
@@ -9,31 +9,25 @@
 
 #include "nsIMobileCellInfo.h"
 #include "nsPIDOMWindow.h"
 #include "nsWrapperCache.h"
 
 namespace mozilla {
 namespace dom {
 
-class MobileCellInfo MOZ_FINAL : public nsIMobileCellInfo
+class MobileCellInfo MOZ_FINAL : public nsISupports
                                , public nsWrapperCache
 {
 public:
-  NS_DECL_NSIMOBILECELLINFO
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileCellInfo)
 
   MobileCellInfo(nsPIDOMWindow* aWindow);
 
-  MobileCellInfo(int32_t aGsmLocationAreaCode, int64_t aGsmCellId,
-                 int32_t aCdmaBaseStationId, int32_t aCdmaBaseStationLatitude,
-                 int32_t aCdmaBaseStationLongitude, int32_t aCdmaSystemId,
-                 int32_t aCdmaNetworkId);
-
   void
   Update(nsIMobileCellInfo* aInfo);
 
   nsPIDOMWindow*
   GetParentObject() const
   {
     return mWindow;
   }
--- a/dom/mobileconnection/src/MobileConnection.cpp
+++ b/dom/mobileconnection/src/MobileConnection.cpp
@@ -1,31 +1,32 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MobileConnection.h"
 
-#include "MobileConnectionCallback.h"
 #include "mozilla/dom/CFStateChangeEvent.h"
 #include "mozilla/dom/DataErrorEvent.h"
 #include "mozilla/dom/MozClirModeEvent.h"
 #include "mozilla/dom/MozEmergencyCbModeEvent.h"
 #include "mozilla/dom/MozOtaStatusEvent.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/USSDReceivedEvent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsIDOMDOMRequest.h"
 #include "nsIPermissionManager.h"
 #include "nsIVariant.h"
 #include "nsJSON.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 
+#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
+
 #define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum)      \
 {                                                                       \
   uint32_t i = 0;                                                       \
   for (const EnumEntry* entry = _enumType##Values::strings;             \
        entry->value;                                                    \
        ++entry, ++i) {                                                  \
     if (_string.EqualsASCII(entry->value)) {                            \
       _enum.SetValue(static_cast<_enumType>(i));                        \
@@ -35,17 +36,16 @@
 
 #define CONVERT_ENUM_TO_STRING(_enumType, _enum, _string)               \
 {                                                                       \
   uint32_t index = uint32_t(_enum);                                     \
   _string.AssignASCII(_enumType##Values::strings[index].value,          \
                       _enumType##Values::strings[index].length);        \
 }
 
-using mozilla::ErrorResult;
 using namespace mozilla::dom;
 
 class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener
 {
   MobileConnection* mMobileConnection;
 
 public:
   NS_DECL_ISUPPORTS
@@ -72,17 +72,17 @@ private:
 
 NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
                                                   DOMEventTargetHelper)
   // Don't traverse mListener because it doesn't keep any reference to
-  // MobileConnection but a raw pointer instead. Neither does mService because
+  // MobileConnection but a raw pointer instead. Neither does mProvider because
   // it's an xpcom service and is only released at shutting down.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoice)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
                                                 DOMEventTargetHelper)
   tmp->Shutdown();
@@ -100,44 +100,44 @@ NS_IMPL_ADDREF_INHERITED(MobileConnectio
 NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper)
 
 MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
   : DOMEventTargetHelper(aWindow)
   , mClientId(aClientId)
 {
   SetIsDOMBinding();
 
-  mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
+  mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID);
 
-  // Not being able to acquire the service isn't fatal since we check
+  // Not being able to acquire the provider isn't fatal since we check
   // for it explicitly below.
-  if (!mService) {
-    NS_WARNING("Could not acquire nsIMobileConnectionService!");
+  if (!mProvider) {
+    NS_WARNING("Could not acquire nsIMobileConnectionProvider!");
     return;
   }
 
   mListener = new Listener(this);
   mVoice = new MobileConnectionInfo(GetOwner());
   mData = new MobileConnectionInfo(GetOwner());
 
   if (CheckPermission("mobileconnection")) {
-    DebugOnly<nsresult> rv = mService->RegisterListener(mClientId, mListener);
+    DebugOnly<nsresult> rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener);
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
-                     "Failed registering mobile connection messages with service");
+                     "Failed registering mobile connection messages with provider");
     UpdateVoice();
     UpdateData();
   }
 }
 
 void
 MobileConnection::Shutdown()
 {
   if (mListener) {
-    if (mService) {
-      mService->UnregisterListener(mClientId, mListener);
+    if (mProvider) {
+      mProvider->UnregisterMobileConnectionMsg(mClientId, mListener);
     }
 
     mListener->Disconnect();
     mListener = nullptr;
   }
 }
 
 MobileConnection::~MobileConnection()
@@ -170,61 +170,61 @@ MobileConnection::CheckPermission(const 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
   permMgr->TestPermissionFromWindow(GetOwner(), aType, &permission);
   return permission == nsIPermissionManager::ALLOW_ACTION;
 }
 
 void
 MobileConnection::UpdateVoice()
 {
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
   nsCOMPtr<nsIMobileConnectionInfo> info;
-  mService->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
+  mProvider->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
   mVoice->Update(info);
 }
 
 void
 MobileConnection::UpdateData()
 {
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
   nsCOMPtr<nsIMobileConnectionInfo> info;
-  mService->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
+  mProvider->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
   mData->Update(info);
 }
 
 // WebIDL interface
 
 void
 MobileConnection::GetLastKnownNetwork(nsString& aRetVal) const
 {
   aRetVal.SetIsVoid(true);
 
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
-  mService->GetLastKnownNetwork(mClientId, aRetVal);
+  mProvider->GetLastKnownNetwork(mClientId, aRetVal);
 }
 
 void
 MobileConnection::GetLastKnownHomeNetwork(nsString& aRetVal) const
 {
   aRetVal.SetIsVoid(true);
 
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
-  mService->GetLastKnownHomeNetwork(mClientId, aRetVal);
+  mProvider->GetLastKnownHomeNetwork(mClientId, aRetVal);
 }
 
 // All fields below require the "mobileconnection" permission.
 
 MobileConnectionInfo*
 MobileConnection::Voice() const
 {
   return mVoice;
@@ -236,66 +236,66 @@ MobileConnection::Data() const
   return mData;
 }
 
 void
 MobileConnection::GetIccId(nsString& aRetVal) const
 {
   aRetVal.SetIsVoid(true);
 
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
-  mService->GetIccId(mClientId, aRetVal);
+  mProvider->GetIccId(mClientId, aRetVal);
 }
 
 Nullable<MobileNetworkSelectionMode>
 MobileConnection::GetNetworkSelectionMode() const
 {
   Nullable<MobileNetworkSelectionMode> retVal =
     Nullable<MobileNetworkSelectionMode>();
 
-  if (!mService) {
+  if (!mProvider) {
     return retVal;
   }
 
   nsAutoString mode;
-  mService->GetNetworkSelectionMode(mClientId, mode);
+  mProvider->GetNetworkSelectionMode(mClientId, mode);
   CONVERT_STRING_TO_NULLABLE_ENUM(mode, MobileNetworkSelectionMode, retVal);
 
   return retVal;
 }
 
 Nullable<MobileRadioState>
 MobileConnection::GetRadioState() const
 {
   Nullable<MobileRadioState> retVal = Nullable<MobileRadioState>();
 
-  if (!mService) {
+  if (!mProvider) {
     return retVal;
   }
 
   nsAutoString state;
-  mService->GetRadioState(mClientId, state);
+  mProvider->GetRadioState(mClientId, state);
   CONVERT_STRING_TO_NULLABLE_ENUM(state, MobileRadioState, retVal);
 
   return retVal;
 }
 
 void
 MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const
 {
-  if (!mService) {
+  if (!mProvider) {
     return;
   }
 
   nsCOMPtr<nsIVariant> variant;
-  mService->GetSupportedNetworkTypes(mClientId,
-                                     getter_AddRefs(variant));
+  mProvider->GetSupportedNetworkTypes(mClientId,
+                                      getter_AddRefs(variant));
 
   uint16_t type;
   nsIID iid;
   uint32_t count;
   void* data;
 
   // Convert the nsIVariant to an array.  We own the resulting buffer and its
   // elements.
@@ -317,281 +317,253 @@ MobileConnection::GetSupportedNetworkTyp
     }
   }
   NS_Free(data);
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetNetworks(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetNetworks(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetNetworks(mClientId, GetOwner(),
+                                       getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SelectNetwork(mClientId, &aNetwork, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SelectNetwork(mClientId, GetOwner(), &aNetwork,
+                                         getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SelectNetworkAutomatically(mClientId,
-                                                     requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SelectNetworkAutomatically(mClientId, GetOwner(),
+                                                      getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
                                           ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsAutoString type;
   CONVERT_ENUM_TO_STRING(MobilePreferredNetworkType, aType, type);
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetPreferredNetworkType(mClientId, type,
-                                                  requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetPreferredNetworkType(mClientId, GetOwner(), type,
+                                                   getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetPreferredNetworkType(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetPreferredNetworkType(mClientId, GetOwner(),
+                                                   getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
                                        ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsAutoString mode;
   CONVERT_ENUM_TO_STRING(MobileRoamingMode, aMode, mode);
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetRoamingPreference(mClientId, mode, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetRoamingPreference(mClientId, GetOwner(), mode,
+                                                getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetRoamingPreference(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetRoamingPreference(mClientId, GetOwner(),
+                                                getter_AddRefs(request));
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+  }
+
+  return request.forget().downcast<DOMRequest>();
+}
 
-  nsresult rv = mService->GetRoamingPreference(mClientId, requestCallback);
+already_AddRefed<DOMRequest>
+MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
+{
+  if (!mProvider) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled,
+                                               getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
-{
-  if (!mService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetVoicePrivacyMode(mClientId, aEnabled,
-                                              requestCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetVoicePrivacyMode(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetVoicePrivacyMode(mClientId, GetOwner(),
+                                               getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SendMMI(mClientId, aMMIString, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SendMMI(mClientId, GetOwner(), aMMIString,
+                                   getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::CancelMMI(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->CancelMMI(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->CancelMMI(mClientId, GetOwner(),
+                                     getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetCallForwarding(mClientId, aReason, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetCallForwarding(mClientId, GetOwner(), aReason,
+                                             getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
                                           ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   AutoJSAPI jsapi;
   if (!NS_WARN_IF(jsapi.Init(GetOwner()))) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
@@ -599,34 +571,32 @@ MobileConnection::SetCallForwardingOptio
 
   JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetCallForwarding(mClientId, options, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetCallForwarding(mClientId, GetOwner(), options,
+                                             getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
                                        ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   AutoJSAPI jsapi;
   if (!NS_WARN_IF(jsapi.Init(GetOwner()))) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
@@ -634,34 +604,32 @@ MobileConnection::GetCallBarringOption(c
 
   JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetCallBarring(mClientId, options, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetCallBarring(mClientId, GetOwner(), options,
+                                          getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
                                        ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   AutoJSAPI jsapi;
   if (!NS_WARN_IF(jsapi.Init(GetOwner()))) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
@@ -669,34 +637,32 @@ MobileConnection::SetCallBarringOption(c
 
   JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetCallBarring(mClientId, options, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetCallBarring(mClientId, GetOwner(), options,
+                                          getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
                                             ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   AutoJSAPI jsapi;
   if (!NS_WARN_IF(jsapi.Init(GetOwner()))) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
@@ -704,157 +670,144 @@ MobileConnection::ChangeCallBarringPassw
 
   JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->ChangeCallBarringPassword(mClientId, options,
-                                                    requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->ChangeCallBarringPassword(mClientId,
+                                                     GetOwner(),
+                                                     options,
+                                                     getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetCallWaiting(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetCallWaiting(mClientId, GetOwner(),
+                                          getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetCallWaiting(mClientId, aEnabled, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetCallWaiting(mClientId, GetOwner(), aEnabled,
+                                          getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->GetCallingLineIdRestriction(mClientId,
-                                                      requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(),
+                                                       getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
                                               ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetCallingLineIdRestriction(mClientId, aMode,
-                                                      requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetCallingLineIdRestriction(mClientId,
+                                                       GetOwner(),
+                                                       aMode,
+                                                       getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->ExitEmergencyCbMode(mClientId, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->ExitEmergencyCbMode(mClientId, GetOwner(),
+                                               getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<DOMRequest>
 MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
 {
-  if (!mService) {
+  if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
-  nsRefPtr<MobileConnectionCallback> requestCallback =
-    new MobileConnectionCallback(GetOwner(), request);
-
-  nsresult rv = mService->SetRadioEnabled(mClientId, aEnabled, requestCallback);
+  nsCOMPtr<nsIDOMDOMRequest> request;
+  nsresult rv = mProvider->SetRadioEnabled(mClientId, GetOwner(), aEnabled,
+                                           getter_AddRefs(request));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
-  return request.forget();
+  return request.forget().downcast<DOMRequest>();
 }
 
 // nsIMobileConnectionListener
 
 NS_IMETHODIMP
 MobileConnection::NotifyVoiceChanged()
 {
   if (!CheckPermission("mobileconnection")) {
@@ -912,22 +865,22 @@ MobileConnection::NotifyDataError(const 
 
   nsRefPtr<DataErrorEvent> event =
     DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init);
 
   return DispatchTrustedEvent(event);
 }
 
 NS_IMETHODIMP
-MobileConnection::NotifyCFStateChanged(bool aSuccess,
-                                       unsigned short aAction,
-                                       unsigned short aReason,
-                                       const nsAString& aNumber,
-                                       unsigned short aSeconds,
-                                       unsigned short aServiceClass)
+MobileConnection::NotifyCFStateChange(bool aSuccess,
+                                      unsigned short aAction,
+                                      unsigned short aReason,
+                                      const nsAString& aNumber,
+                                      unsigned short aSeconds,
+                                      unsigned short aServiceClass)
 {
   if (!CheckPermission("mobileconnection")) {
     return NS_OK;
   }
 
   CFStateChangeEventInit init;
   init.mBubbles = false;
   init.mCancelable = false;
@@ -1014,26 +967,8 @@ MobileConnection::NotifyClirModeChanged(
   init.mCancelable = false;
   init.mMode = aMode;
 
   nsRefPtr<MozClirModeEvent> event =
     MozClirModeEvent::Constructor(this, NS_LITERAL_STRING("clirmodechange"), init);
 
   return DispatchTrustedEvent(event);
 }
-
-NS_IMETHODIMP
-MobileConnection::NotifyLastKnownNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnection::NotifyLastKnownHomeNetworkChanged()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnection::NotifyNetworkSelectionModeChanged()
-{
-  return NS_OK;
-}
--- a/dom/mobileconnection/src/MobileConnection.h
+++ b/dom/mobileconnection/src/MobileConnection.h
@@ -6,30 +6,30 @@
 #define mozilla_dom_MobileConnection_h
 
 #include "MobileConnectionInfo.h"
 #include "MobileNetworkInfo.h"
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/DOMRequest.h"
 #include "mozilla/dom/MozMobileConnectionBinding.h"
 #include "nsCycleCollectionParticipant.h"
-#include "nsIMobileConnectionService.h"
+#include "nsIMobileConnectionProvider.h"
 #include "nsWeakPtr.h"
 
 namespace mozilla {
 namespace dom {
 
 class MobileConnection MOZ_FINAL : public DOMEventTargetHelper,
                                    private nsIMobileConnectionListener
 {
   /**
    * Class MobileConnection doesn't actually expose
    * nsIMobileConnectionListener. Instead, it owns an
    * nsIMobileConnectionListener derived instance mListener and passes it to
-   * nsIMobileConnectionService. The onreceived events are first delivered to
+   * nsIMobileConnectionProvider. The onreceived events are first delivered to
    * mListener and then forwarded to its owner, MobileConnection. See also bug
    * 775997 comment #51.
    */
   class Listener;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIMOBILECONNECTIONLISTENER
@@ -159,17 +159,17 @@ public:
   IMPL_EVENT_HANDLER(radiostatechange)
   IMPL_EVENT_HANDLER(clirmodechange)
 
 private:
   ~MobileConnection();
 
 private:
   uint32_t mClientId;
-  nsCOMPtr<nsIMobileConnectionService> mService;
+  nsCOMPtr<nsIMobileConnectionProvider> mProvider;
   nsRefPtr<Listener> mListener;
   nsRefPtr<MobileConnectionInfo> mVoice;
   nsRefPtr<MobileConnectionInfo> mData;
 
   bool
   CheckPermission(const char* aType) const;
 
   void
deleted file mode 100644
--- a/dom/mobileconnection/src/MobileConnectionCallback.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MobileConnectionCallback.h"
-
-#include "DOMMMIError.h"
-#include "mozilla/dom/MobileNetworkInfo.h"
-#include "mozilla/dom/MozMobileConnectionBinding.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "nsJSUtils.h"
-#include "nsServiceManagerUtils.h"
-
-using namespace mozilla::dom;
-
-NS_IMPL_ISUPPORTS(MobileConnectionCallback, nsIMobileConnectionCallback)
-
-MobileConnectionCallback::MobileConnectionCallback(nsPIDOMWindow* aWindow,
-                                                   DOMRequest* aRequest)
-  : mWindow(aWindow)
-  , mRequest(aRequest)
-{
-}
-
-/**
- * Notify Success for Send/CancelMmi.
- */
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                                                     const nsAString& aStatusMessage)
-{
-  MozMMIResult result;
-  result.mServiceCode.Assign(aServiceCode);
-  result.mStatusMessage.Assign(aStatusMessage);
-
-  return NotifySendCancelMmiSuccess(result);
-}
-
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                                                     const nsAString& aStatusMessage,
-                                                     JS::Handle<JS::Value> aAdditionalInformation)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  RootedDictionary<MozMMIResult> result(cx);
-
-  result.mServiceCode.Assign(aServiceCode);
-  result.mStatusMessage.Assign(aStatusMessage);
-  result.mAdditionalInformation.Construct().SetAsObject() = &aAdditionalInformation.toObject();
-
-  return NotifySendCancelMmiSuccess(result);
-}
-
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                                                     const nsAString& aStatusMessage,
-                                                     uint16_t aAdditionalInformation)
-{
-  MozMMIResult result;
-  result.mServiceCode.Assign(aServiceCode);
-  result.mStatusMessage.Assign(aStatusMessage);
-  result.mAdditionalInformation.Construct().SetAsUnsignedShort() = aAdditionalInformation;
-
-  return NotifySendCancelMmiSuccess(result);
-}
-
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                                                     const nsAString& aStatusMessage,
-                                                     const nsTArray<nsString>& aAdditionalInformation)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> additionalInformation(cx);
-
-  if (!ToJSValue(cx, aAdditionalInformation, &additionalInformation)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySendCancelMmiSuccess(aServiceCode, aStatusMessage,
-                                    additionalInformation);
-}
-
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                                                     const nsAString& aStatusMessage,
-                                                     const nsTArray<IPC::MozCallForwardingOptions>& aAdditionalInformation)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> additionalInformation(cx);
-
-  if (!ToJSValue(cx, aAdditionalInformation, &additionalInformation)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySendCancelMmiSuccess(aServiceCode, aStatusMessage,
-                                    additionalInformation);
-}
-
-nsresult
-MobileConnectionCallback::NotifySendCancelMmiSuccess(const MozMMIResult& aResult)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-
-  if (!ToJSValue(cx, aResult, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-}
-
-/**
- * Notify Success for GetCallForwarding.
- */
-nsresult
-MobileConnectionCallback::NotifyGetCallForwardingSuccess(const nsTArray<IPC::MozCallForwardingOptions>& aResults)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-
-  if (!ToJSValue(cx, aResults, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-}
-
-/**
- * Notify Success.
- */
-nsresult
-MobileConnectionCallback::NotifySuccess(JS::Handle<JS::Value> aResult)
-{
-  nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
-
-  return rs->FireSuccessAsync(mRequest, aResult);
-}
-
-// nsIMobileConnectionCallback
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifySuccess()
-{
-  return NotifySuccess(JS::UndefinedHandleValue);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifySuccessWithString(const nsAString& aResult)
-{
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-
-  if (!ToJSValue(cx, aResult, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifySuccessWithBoolean(bool aResult)
-{
-  return aResult ? NotifySuccess(JS::TrueHandleValue)
-                 : NotifySuccess(JS::FalseHandleValue);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifyGetNetworksSuccess(uint32_t aCount,
-                                                   nsIMobileNetworkInfo** aNetworks)
-{
-  nsTArray<nsRefPtr<MobileNetworkInfo>> results;
-  for (uint32_t i = 0; i < aCount; i++)
-  {
-    nsRefPtr<MobileNetworkInfo> networkInfo = new MobileNetworkInfo(mWindow);
-    networkInfo->Update(aNetworks[i]);
-    results.AppendElement(networkInfo);
-  }
-
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-
-  if (!ToJSValue(cx, results, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifySendCancelMmiSuccess(JS::Handle<JS::Value> aResult)
-{
-  return NotifySuccess(aResult);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifyGetCallForwardingSuccess(JS::Handle<JS::Value> aResults)
-{
-  return NotifySuccess(aResults);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifyGetCallBarringSuccess(uint16_t aProgram,
-                                                      bool aEnabled,
-                                                      uint16_t aServiceClass)
-{
-  MozCallBarringOptions result;
-  result.mProgram.Construct().SetValue(aProgram);
-  result.mEnabled.Construct().SetValue(aEnabled);
-  result.mServiceClass.Construct().SetValue(aServiceClass);
-
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-  if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-}
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifyGetClirStatusSuccess(uint16_t aN, uint16_t aM)
-{
-  MozClirStatus result;
-  result.mN.Construct(aN);
-  result.mM.Construct(aM);
-
-  AutoJSAPI jsapi;
-  if (!NS_WARN_IF(jsapi.Init(mWindow))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> jsResult(cx);
-  if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return NotifySuccess(jsResult);
-};
-
-NS_IMETHODIMP
-MobileConnectionCallback::NotifyError(const nsAString& aName,
-                                      const nsAString& aMessage,
-                                      const nsAString& aServiceCode,
-                                      uint16_t aInfo,
-                                      uint8_t aArgc)
-{
-  nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
-
-  nsRefPtr<DOMError> error;
-  switch (aArgc) {
-    case 0:
-      return rs->FireErrorAsync(mRequest, aName);
-    case 1:
-      error = new DOMMMIError(mWindow, aName, aMessage, EmptyString(),
-                              Nullable<int16_t>());
-      return rs->FireDetailedError(mRequest, error);
-    case 2:
-      error = new DOMMMIError(mWindow, aName, aMessage, aServiceCode,
-                              Nullable<int16_t>());
-      return rs->FireDetailedError(mRequest, error);
-    case 3:
-      error = new DOMMMIError(mWindow, aName, aMessage, aServiceCode,
-                              Nullable<int16_t>(int16_t(aInfo)));
-      return rs->FireDetailedError(mRequest, error);
-  }
-
-  return NS_ERROR_FAILURE;
-}
deleted file mode 100644
--- a/dom/mobileconnection/src/MobileConnectionCallback.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_MobileConnectionCallback_h
-#define mozilla_dom_MobileConnectionCallback_h
-
-#include "mozilla/dom/DOMRequest.h"
-#include "mozilla/dom/MobileConnectionIPCSerializer.h"
-#include "nsCOMPtr.h"
-#include "nsIMobileConnectionService.h"
-
-namespace mozilla {
-namespace dom {
-
-/**
- * A callback object for handling asynchronous request/response. This object is
- * created when an asynchronous request is made and should be destroyed after
- * Notify*Success/Error is called.
- * The modules hold the reference of MobileConnectionCallback in OOP mode and
- * non-OOP mode are different.
- * - OOP mode: MobileConnectionRequestChild
- * - non-OOP mode: MobileConnectionGonkService
- * The reference should be released after Notify*Success/Error is called.
- */
-class MobileConnectionCallback MOZ_FINAL : public nsIMobileConnectionCallback
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILECONNECTIONCALLBACK
-
-  MobileConnectionCallback(nsPIDOMWindow* aWindow, DOMRequest* aRequest);
-
-  /**
-   * Notify Success for Send/CancelMmi.
-   */
-  nsresult
-  NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                             const nsAString& aStatusMessage);
-  nsresult
-  NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                             const nsAString& aStatusMessage,
-                             JS::Handle<JS::Value> aAdditionalInformation);
-  nsresult
-  NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                             const nsAString& aStatusMessage,
-                             uint16_t aAdditionalInformation);
-  nsresult
-  NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                             const nsAString& aStatusMessage,
-                             const nsTArray<nsString>& aAdditionalInformation);
-  nsresult
-  NotifySendCancelMmiSuccess(const nsAString& aServiceCode,
-                             const nsAString& aStatusMessage,
-                             const nsTArray<IPC::MozCallForwardingOptions>& aAdditionalInformation);
-  nsresult
-  NotifySendCancelMmiSuccess(const MozMMIResult& aResult);
-
-  /**
-   * Notify Success for GetCallForwarding.
-   */
-  nsresult
-  NotifyGetCallForwardingSuccess(const nsTArray<IPC::MozCallForwardingOptions>& aResults);
-
-private:
-  ~MobileConnectionCallback() {}
-
-  nsresult
-  NotifySuccess(JS::Handle<JS::Value> aResult);
-
-  nsCOMPtr<nsPIDOMWindow> mWindow;
-  nsRefPtr<DOMRequest> mRequest;
-};
-
-} // name space dom
-} // name space mozilla
-
-#endif // mozilla_dom_MobileConnectionCallback_h
--- a/dom/mobileconnection/src/MobileConnectionInfo.cpp
+++ b/dom/mobileconnection/src/MobileConnectionInfo.cpp
@@ -19,87 +19,38 @@
        entry->value;                                                    \
        ++entry, ++i) {                                                  \
     if (_string.EqualsASCII(entry->value)) {                            \
       _enum.SetValue(static_cast<_enumType>(i));                        \
     }                                                                   \
   }                                                                     \
 }
 
-#define CONVERT_NULLABLE_ENUM_TO_STRING(_enumType, _enum, _string)      \
-{                                                                       \
-  if (_enum.IsNull()) {                                                 \
-    _string.SetIsVoid(true);                                            \
-  } else {                                                              \
-    uint32_t index = uint32_t(_enum.Value());                           \
-    _string.AssignASCII(_enumType##Values::strings[index].value,        \
-                        _enumType##Values::strings[index].length);      \
-  }                                                                     \
-}
-
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MobileConnectionInfo, mWindow,
                                       mNetworkInfo, mCellInfo)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileConnectionInfo)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileConnectionInfo)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileConnectionInfo)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_INTERFACE_MAP_ENTRY(nsIMobileConnectionInfo)
 NS_INTERFACE_MAP_END
 
 MobileConnectionInfo::MobileConnectionInfo(nsPIDOMWindow* aWindow)
   : mConnected(false)
   , mEmergencyCallsOnly(false)
   , mRoaming(false)
   , mWindow(aWindow)
 {
   SetIsDOMBinding();
 }
 
-MobileConnectionInfo::MobileConnectionInfo(const nsAString& aState,
-                                           bool aConnected,
-                                           bool aEmergencyCallsOnly,
-                                           bool aRoaming,
-                                           nsIMobileNetworkInfo* aNetworkInfo,
-                                           const nsAString& aType,
-                                           const Nullable<int32_t>& aSignalStrength,
-                                           const Nullable<uint16_t>& aRelSignalStrength,
-                                           nsIMobileCellInfo* aCellInfo)
-  : mConnected(aConnected)
-  , mEmergencyCallsOnly(aEmergencyCallsOnly)
-  , mRoaming(aRoaming)
-  , mSignalStrength(aSignalStrength)
-  , mRelSignalStrength(aRelSignalStrength)
-{
-  // The instance created by this way is only used for IPC stuff. It won't be
-  // expose to JS directly, we will clone this instance to the one that is
-  // maintained in MobileConnectionChild. So we don't need SetIsDOMBinding()
-  // here.
-
-  // Update mState and mType
-  CONVERT_STRING_TO_NULLABLE_ENUM(aState, MobileConnectionState, mState);
-  CONVERT_STRING_TO_NULLABLE_ENUM(aType, MobileConnectionType, mType);
-
-  // Update mNetworkInfo
-  if (aNetworkInfo) {
-    mNetworkInfo = new MobileNetworkInfo(mWindow);
-    mNetworkInfo->Update(aNetworkInfo);
-  }
-
-  // Update mCellInfo
-  if (aCellInfo) {
-    mCellInfo = new MobileCellInfo(mWindow);
-    mCellInfo->Update(aCellInfo);
-  }
-}
-
 void
 MobileConnectionInfo::Update(nsIMobileConnectionInfo* aInfo)
 {
   if (!aInfo) {
     return;
   }
 
   aInfo->GetConnected(&mConnected);
@@ -158,84 +109,10 @@ MobileConnectionInfo::Update(nsIMobileCo
   } else {
     mCellInfo = nullptr;
   }
 }
 
 JSObject*
 MobileConnectionInfo::WrapObject(JSContext* aCx)
 {
-  MOZ_ASSERT(IsDOMBinding());
   return MozMobileConnectionInfoBinding::Wrap(aCx, this);
 }
-
-// nsIMobileConnectionInfo
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetState(nsAString& aState)
-{
-  CONVERT_NULLABLE_ENUM_TO_STRING(MobileConnectionState, mState, aState);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetConnected(bool* aConnected)
-{
-  *aConnected = Connected();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetEmergencyCallsOnly(bool* aEmergencyCallsOnly)
-{
-  *aEmergencyCallsOnly = EmergencyCallsOnly();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetRoaming(bool* aRoaming)
-{
-  *aRoaming = Roaming();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetNetwork(nsIMobileNetworkInfo** aInfo)
-{
-  NS_IF_ADDREF(*aInfo = GetNetwork());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetType(nsAString& aType)
-{
-  CONVERT_NULLABLE_ENUM_TO_STRING(MobileConnectionType, mType, aType);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetSignalStrength(JS::MutableHandle<JS::Value> aSignal)
-{
-  if (mSignalStrength.IsNull()) {
-    aSignal.setNull();
-  } else {
-    aSignal.setInt32(mSignalStrength.Value());
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetRelSignalStrength(JS::MutableHandle<JS::Value> aSignal)
-{
-  if (mRelSignalStrength.IsNull()) {
-    aSignal.setNull();
-  } else {
-    aSignal.setNumber(uint32_t(mRelSignalStrength.Value()));
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionInfo::GetCell(nsIMobileCellInfo** aInfo)
-{
-  NS_IF_ADDREF(*aInfo = GetCell());
-  return NS_OK;
-}
--- a/dom/mobileconnection/src/MobileConnectionInfo.h
+++ b/dom/mobileconnection/src/MobileConnectionInfo.h
@@ -12,34 +12,25 @@
 #include "mozilla/dom/MozMobileConnectionInfoBinding.h"
 #include "nsIMobileConnectionInfo.h"
 #include "nsPIDOMWindow.h"
 #include "nsWrapperCache.h"
 
 namespace mozilla {
 namespace dom {
 
-class MobileConnectionInfo MOZ_FINAL : public nsIMobileConnectionInfo
+class MobileConnectionInfo MOZ_FINAL : public nsISupports
                                      , public nsWrapperCache
 {
 public:
-  NS_DECL_NSIMOBILECONNECTIONINFO
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileConnectionInfo)
 
   MobileConnectionInfo(nsPIDOMWindow* aWindow);
 
-  MobileConnectionInfo(const nsAString& aState, bool aConnected,
-                       bool aEmergencyCallsOnly, bool aRoaming,
-                       nsIMobileNetworkInfo* aNetworkInfo,
-                       const nsAString& aType,
-                       const Nullable<int32_t>& aSignalStrength,
-                       const Nullable<uint16_t>& aRelSignalStrength,
-                       nsIMobileCellInfo* aCellInfo);
-
   void
   Update(nsIMobileConnectionInfo* aInfo);
 
   nsPIDOMWindow*
   GetParentObject() const
   {
     return mWindow;
   }
--- a/dom/mobileconnection/src/MobileNetworkInfo.cpp
+++ b/dom/mobileconnection/src/MobileNetworkInfo.cpp
@@ -20,32 +20,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 MobileNetworkInfo::MobileNetworkInfo(nsPIDOMWindow* aWindow)
   : mWindow(aWindow)
 {
   SetIsDOMBinding();
 }
 
-MobileNetworkInfo::MobileNetworkInfo(const nsAString& aShortName,
-                                     const nsAString& aLongName,
-                                     const nsAString& aMcc,
-                                     const nsAString& aMnc,
-                                     const nsAString& aState)
-  : mShortName(aShortName)
-  , mLongName(aLongName)
-  , mMcc(aMcc)
-  , mMnc(aMnc)
-  , mState(aState)
-{
-  // The parent object is nullptr when MobileNetworkInfo is created by this way.
-  // And it won't be exposed to web content.
-  SetIsDOMBinding();
-}
-
 void
 MobileNetworkInfo::Update(nsIMobileNetworkInfo* aInfo)
 {
   if (!aInfo) {
     return;
   }
 
   aInfo->GetShortName(mShortName);
@@ -56,16 +40,39 @@ MobileNetworkInfo::Update(nsIMobileNetwo
 }
 
 JSObject*
 MobileNetworkInfo::WrapObject(JSContext* aCx)
 {
   return MozMobileNetworkInfoBinding::Wrap(aCx, this);
 }
 
+// WebIDL interface
+
+/* static */ already_AddRefed<MobileNetworkInfo>
+MobileNetworkInfo::Constructor(const GlobalObject& aGlobal,
+                               const nsAString& aShortName,
+                               const nsAString& aLongName,
+                               const nsAString& aMcc,
+                               const nsAString& aMnc,
+                               const nsAString& aState,
+                               ErrorResult& aRv)
+{
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MobileNetworkInfo> info = new MobileNetworkInfo(window);
+
+  info->mShortName.Assign(aShortName);
+  info->mLongName.Assign(aLongName);
+  info->mMcc.Assign(aMcc);
+  info->mMnc.Assign(aMnc);
+  info->mState.Assign(aState);
+
+  return info.forget();
+}
+
 // nsIMobileNetworkInfo
 
 NS_IMETHODIMP
 MobileNetworkInfo::GetShortName(nsAString& aShortName)
 {
   aShortName = mShortName;
   return NS_OK;
 }
--- a/dom/mobileconnection/src/MobileNetworkInfo.h
+++ b/dom/mobileconnection/src/MobileNetworkInfo.h
@@ -22,33 +22,35 @@ class MobileNetworkInfo MOZ_FINAL : publ
 {
 public:
   NS_DECL_NSIMOBILENETWORKINFO
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileNetworkInfo)
 
   MobileNetworkInfo(nsPIDOMWindow* aWindow);
 
-  MobileNetworkInfo(const nsAString& aShortName, const nsAString& aLongName,
-                    const nsAString& aMcc, const nsAString& aMnc,
-                    const nsAString& aState);
-
   void
   Update(nsIMobileNetworkInfo* aInfo);
 
   nsPIDOMWindow*
   GetParentObject() const
   {
     return mWindow;
   }
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   // WebIDL interface
+  static already_AddRefed<MobileNetworkInfo>
+  Constructor(const GlobalObject& aGlobal, const nsAString& aShortName,
+              const nsAString& aLongName, const nsAString& aMcc,
+              const nsAString& aMnc, const nsAString& aState,
+              ErrorResult& aRv);
+
   Nullable<MobileNetworkState>
   GetState() const
   {
     uint32_t i = 0;
     for (const EnumEntry* entry = MobileNetworkStateValues::strings;
          entry->value;
          ++entry, ++i) {
       if (mState.EqualsASCII(entry->value)) {
deleted file mode 100644
--- a/dom/mobileconnection/src/gonk/MobileConnectionGonkService.js
+++ /dev/null
@@ -1,1548 +0,0 @@
-/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/systemlibs.js");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-var RIL = {};
-Cu.import("resource://gre/modules/ril_consts.js", RIL);
-
-const MOBILECONNECTIONGONKSERVICE_CONTRACTID =
-  "@mozilla.org/mobileconnection/mobileconnectiongonkservice;1";
-
-const MOBILECONNECTIONGONKSERVICE_CID =
-  Components.ID("{05e20430-fe65-4984-8df9-a6a504b24a91}");
-const MOBILENETWORKINFO_CID =
-  Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
-const MOBILECELLINFO_CID =
-  Components.ID("{0635d9ab-997e-4cdf-84e7-c1883752dff3}");
-
-const NS_XPCOM_SHUTDOWN_OBSERVER_ID      = "xpcom-shutdown";
-const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID  = "nsPref:changed";
-const NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID = "network-active-changed";
-
-const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
-
-XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
-                                   "@mozilla.org/system-message-internal;1",
-                                   "nsISystemMessagesInternal");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
-                                   "@mozilla.org/network/manager;1",
-                                   "nsINetworkManager");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer",
-                                   "@mozilla.org/ril;1",
-                                   "nsIRadioInterfaceLayer");
-
-let DEBUG = RIL.DEBUG_RIL;
-function debug(s) {
-  dump("MobileConnectionGonkService: " + s + "\n");
-}
-
-function MobileNetworkInfo() {
-  this.shortName = null;
-  this.longName = null;
-  this.mcc = null;
-  this.mnc = null;
-  this.stat = null;
-}
-MobileNetworkInfo.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileNetworkInfo]),
-  classID:        MOBILENETWORKINFO_CID,
-  classInfo:      XPCOMUtils.generateCI({
-    classID:          MOBILENETWORKINFO_CID,
-    classDescription: "MobileNetworkInfo",
-    interfaces:       [Ci.nsIMobileNetworkInfo]
-  })
-};
-
-function MobileCellInfo() {
-  this.gsmLocationAreaCode = -1;
-  this.gsmCellId = -1;
-  this.cdmaBaseStationId = -1;
-  this.cdmaBaseStationLatitude = -2147483648;
-  this.cdmaBaseStationLongitude = -2147483648;
-  this.cdmaSystemId = -1;
-  this.cdmaNetworkId = -1;
-}
-MobileCellInfo.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileCellInfo]),
-  classID:        MOBILECELLINFO_CID,
-  classInfo:      XPCOMUtils.generateCI({
-    classID:          MOBILECELLINFO_CID,
-    classDescription: "MobileCellInfo",
-    interfaces:       [Ci.nsIMobileCellInfo]
-  })
-};
-
-function CallForwardingOptions(aOptions) {
-  this.active = aOptions.active;
-  this.action = aOptions.action;
-  this.reason = aOptions.reason;
-  this.number = aOptions.number;
-  this.timeSeconds = aOptions.timeSeconds;
-  this.serviceClass = aOptions.serviceClass;
-}
-CallForwardingOptions.prototype = {
-  __exposedProps__ : {active: 'r',
-                      action: 'r',
-                      reason: 'r',
-                      number: 'r',
-                      timeSeconds: 'r',
-                      serviceClass: 'r'},
-};
-
-function MMIResult(aOptions) {
-  this.serviceCode = aOptions.serviceCode;
-  this.statusMessage = aOptions.statusMessage;
-  this.additionalInformation = aOptions.additionalInformation;
-}
-MMIResult.prototype = {
-  __exposedProps__ : {serviceCode: 'r',
-                      statusMessage: 'r',
-                      additionalInformation: 'r'},
-};
-
-function MobileConnectionProvider(aClientId, aRadioInterface) {
-  this._clientId = aClientId;
-  this._radioInterface = aRadioInterface;
-  this._operatorInfo = {};
-  // An array of nsIMobileConnectionListener instances.
-  this._listeners = [];
-
-  this.supportedNetworkTypes = this._getSupportedNetworkTypes();
-  // These objects implement the nsIMobileConnectionInfo interface,
-  // although the actual implementation lives in the content process. So are
-  // the child attributes `network` and `cell`, which implement
-  // nsIMobileNetworkInfo and nsIMobileCellInfo respectively.
-  this.voiceInfo = {connected: false,
-                    emergencyCallsOnly: false,
-                    roaming: false,
-                    network: null,
-                    cell: null,
-                    type: null,
-                    signalStrength: null,
-                    relSignalStrength: null};
-  this.dataInfo = {connected: false,
-                   emergencyCallsOnly: false,
-                   roaming: false,
-                   network: null,
-                   cell: null,
-                   type: null,
-                   signalStrength: null,
-                   relSignalStrength: null};
-}
-MobileConnectionProvider.prototype = {
-  _clientId: null,
-  _radioInterface: null,
-  _operatorInfo: null,
-  _listeners: null,
-
-  /**
-   * The networks that are currently trying to be selected (or "automatic").
-   * This helps ensure that only one network per client is selected at a time.
-   */
-  _selectingNetwork: null,
-
-  voiceInfo: null,
-  dataInfo: null,
-  iccId: null,
-  networkSelectMode: null,
-  radioState: null,
-  lastKnownNetwork: null,
-  lastKnownHomeNetwork: null,
-  supportedNetworkTypes: null,
-
-  /**
-   * A utility function to dump debug message.
-   */
-  _debug: function(aMessage) {
-    dump("MobileConnectionProvider[" + this._clientId + "]: " + aMessage + "\n");
-  },
-
-  /**
-   * A utility function to get supportedNetworkTypes from system property.
-   */
-  _getSupportedNetworkTypes: function() {
-    let key = "ro.moz.ril." + this._clientId + ".network_types";
-    let supportedNetworkTypes = libcutils.property_get(key, "").split(",");
-    for (let type of supportedNetworkTypes) {
-      // If the value in system property is not valid, use the default one which
-      // is defined in ril_consts.js.
-      if (RIL.GECKO_SUPPORTED_NETWORK_TYPES.indexOf(type) < 0) {
-        if (DEBUG) {
-          this._debug("Unknown network type: " + type);
-        }
-        supportedNetworkTypes =
-          RIL.GECKO_SUPPORTED_NETWORK_TYPES_DEFAULT.split(",");
-        break;
-      }
-    }
-    if (DEBUG) {
-      this._debug("Supported Network Types: " + supportedNetworkTypes);
-    }
-    return supportedNetworkTypes;
-  },
-
-  /**
-   * Helper for guarding us against invalid reason values for call forwarding.
-   */
-  _isValidCallForwardingReason: function(aReason) {
-    switch (aReason) {
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_UNCONDITIONAL:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_MOBILE_BUSY:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NO_REPLY:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NOT_REACHABLE:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
-        return true;
-      default:
-        return false;
-    }
-  },
-
-  /**
-   * Helper for guarding us against invalid action values for call forwarding.
-   */
-  _isValidCallForwardingAction: function(aAction) {
-    switch (aAction) {
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_DISABLE:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ENABLE:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_REGISTRATION:
-      case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ERASURE:
-        return true;
-      default:
-        return false;
-    }
-  },
-
-  /**
-   * Helper for guarding us against invalid program values for call barring.
-   */
-  _isValidCallBarringProgram: function(aProgram) {
-    switch (aProgram) {
-      case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_OUTGOING:
-      case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
-      case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
-      case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_INCOMING:
-      case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
-        return true;
-      default:
-        return false;
-    }
-  },
-
-  /**
-   * Helper for guarding us against invalid options for call barring.
-   */
-  _isValidCallBarringOptions: function(aOptions, aUsedForSetting) {
-    if (!aOptions || aOptions.serviceClass == null ||
-        !this._isValidCallBarringProgram(aOptions.program)) {
-      return false;
-    }
-
-    // For setting callbarring options, |enabled| and |password| are required.
-    if (aUsedForSetting &&
-        (aOptions.enabled == null || aOptions.password == null)) {
-      return false;
-    }
-
-    return true;
-  },
-
-  /**
-   * Helper for guarding us against invalid mode for clir.
-   */
-  _isValidClirMode: function(aMode) {
-    switch (aMode) {
-      case Ci.nsIMobileConnectionService.CLIR_DEFAULT:
-      case Ci.nsIMobileConnectionService.CLIR_INVOCATION:
-      case Ci.nsIMobileConnectionService.CLIR_SUPPRESSION:
-        return true;
-      default:
-        return false;
-    }
-  },
-
-  /**
-   * Fix the roaming. RIL can report roaming in some case it is not
-   * really the case. See bug 787967
-   */
-  _checkRoamingBetweenOperators: function(aNetworkInfo) {
-    // TODO: Bug 864489 - B2G RIL: use ipdl as IPC in MozIccManager
-    // Should get iccInfo from IccGonkProvider.
-    let iccInfo = this._radioInterface.rilContext.iccInfo;
-    let operator = aNetworkInfo.network;
-    let state = aNetworkInfo.state;
-
-    if (!iccInfo || !operator ||
-        state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
-      return false;
-    }
-
-    let spn = iccInfo.spn && iccInfo.spn.toLowerCase();
-    let longName = operator.longName && operator.longName.toLowerCase();
-    let shortName = operator.shortName && operator.shortName.toLowerCase();
-
-    let equalsLongName = longName && (spn == longName);
-    let equalsShortName = shortName && (spn == shortName);
-    let equalsMcc = iccInfo.mcc == operator.mcc;
-
-    let newRoaming = aNetworkInfo.roaming &&
-                     !(equalsMcc && (equalsLongName || equalsShortName));
-    if (newRoaming === aNetworkInfo.roaming) {
-      return false;
-    }
-
-    aNetworkInfo.roaming = newRoaming;
-    return true;
-  },
-
-  _updateInfo: function(aDestInfo, aSrcInfo) {
-    let isUpdated = false;
-    for (let key in aSrcInfo) {
-      // For updating MobileConnectionInfo
-      if (key === "cell" && aSrcInfo.cell) {
-        if (!aDestInfo.cell) {
-          aDestInfo.cell = new MobileCellInfo();
-        }
-        isUpdated = this._updateInfo(aDestInfo.cell, aSrcInfo.cell) || isUpdated;
-      } else if (aDestInfo[key] !== aSrcInfo[key]) {
-        isUpdated = true;
-        aDestInfo[key] = aSrcInfo[key];
-      }
-    }
-    return isUpdated;
-  },
-
-  _rulesToCallForwardingOptions: function(aRules) {
-    for (let i = 0; i < aRules.length; i++) {
-      let info = new CallForwardingOptions(aRules[i]);
-      aRules[i] = info;
-    }
-  },
-
-  _dispatchNotifyError: function(aCallback, aErrorMsg) {
-    Services.tm.currentThread.dispatch(() => aCallback.notifyError(aErrorMsg),
-                                       Ci.nsIThread.DISPATCH_NORMAL);
-  },
-
-  registerListener: function(aListener) {
-    if (this._listeners.indexOf(aListener) >= 0) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    this._listeners.push(aListener);
-  },
-
-  unregisterListener: function(aListener) {
-    let index = this._listeners.indexOf(aListener);
-    if (index >= 0) {
-      this._listeners.splice(index, 1);
-    }
-  },
-
-  deliverListenerEvent: function(aName, aArgs) {
-    let listeners = this._listeners.slice();
-    for (let listener of listeners) {
-      if (listeners.indexOf(listener) === -1) {
-        continue;
-      }
-      let handler = listener[aName];
-      if (typeof handler != "function") {
-        throw new Error("No handler for " + aName);
-      }
-      try {
-        handler.apply(listener, aArgs);
-      } catch (e) {
-        if (DEBUG) {
-          this._debug("listener for " + aName + " threw an exception: " + e);
-        }
-      }
-    }
-  },
-
-  updateVoiceInfo: function(aNewInfo, aBatch = false) {
-    let isUpdated = this._updateInfo(this.voiceInfo, aNewInfo);
-
-    // Make sure we also reset the operator and signal strength information
-    // if we drop off the network.
-    if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
-      this.voiceInfo.cell = null;
-      this.voiceInfo.network = null;
-      this.voiceInfo.signalStrength = null;
-      this.voiceInfo.relSignalStrength = null;
-    } else {
-      this.voiceInfo.network = this._operatorInfo;
-    }
-
-    // Check roaming state
-    isUpdated = this._checkRoamingBetweenOperators(this.voiceInfo) || isUpdated;
-
-    if (isUpdated && !aBatch) {
-      this.deliverListenerEvent("notifyVoiceChanged");
-    }
-  },
-
-  updateDataInfo: function(aNewInfo, aBatch = false) {
-    let isUpdated = false;
-
-    // For the data connection, the `connected` flag indicates whether
-    // there's an active data call. We get correct `connected` state here.
-    let active = gNetworkManager.active;
-    aNewInfo.connected = false;
-    if (active &&
-        active.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE &&
-        active.serviceId === this._clientId) {
-      aNewInfo.connected = true;
-    }
-
-    isUpdated = this._updateInfo(this.dataInfo, aNewInfo);
-
-    // Make sure we also reset the operator and signal strength information
-    // if we drop off the network.
-    if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
-      this.dataInfo.cell = null;
-      this.dataInfo.network = null;
-      this.dataInfo.signalStrength = null;
-      this.dataInfo.relSignalStrength = null;
-    } else {
-      this.dataInfo.network = this._operatorInfo;
-    }
-
-    // Check roaming state
-    isUpdated = this._checkRoamingBetweenOperators(this.dataInfo) || isUpdated;
-
-    if (isUpdated && !aBatch) {
-      this.deliverListenerEvent("notifyDataChanged");
-    }
-  },
-
-  updateOperatorInfo: function(aNewInfo, aBatch = false) {
-    let isUpdated = this._updateInfo(this._operatorInfo, aNewInfo);
-
-    // Update lastKnownNetwork
-    if (this._operatorInfo.mcc && this._operatorInfo.mnc) {
-      let network = this._operatorInfo.mcc + "-" + this._operatorInfo.mnc;
-      if (this.lastKnownNetwork !== network) {
-        if (DEBUG) {
-          this._debug("lastKnownNetwork now is " + network);
-        }
-
-        this.lastKnownNetwork = network;
-        this.deliverListenerEvent("notifyLastKnownNetworkChanged");
-      }
-    }
-
-    // If the voice is unregistered, no need to send notification.
-    if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
-        isUpdated && !aBatch) {
-      this.deliverListenerEvent("notifyVoiceChanged");
-    }
-
-    // If the data is unregistered, no need to send notification.
-    if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
-        isUpdated && !aBatch) {
-      this.deliverListenerEvent("notifyDataChanged");
-    }
-  },
-
-  updateSignalInfo: function(aNewInfo, aBatch = false) {
-    // If the voice is not registered, no need to update signal information.
-    if (this.voiceInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
-      if (this._updateInfo(this.voiceInfo, aNewInfo.voice) && !aBatch) {
-        this.deliverListenerEvent("notifyVoiceChanged");
-      }
-    }
-
-    // If the data is not registered, no need to update signal information.
-    if (this.dataInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
-      if (this._updateInfo(this.dataInfo, aNewInfo.data) && !aBatch) {
-        this.deliverListenerEvent("notifyDataChanged");
-      }
-    }
-  },
-
-  updateIccId: function(aIccId) {
-    if (this.iccId === aIccId) {
-      return;
-    }
-
-    this.iccId = aIccId;
-    this.deliverListenerEvent("notifyIccChanged");
-  },
-
-  updateRadioState: function(aRadioState) {
-    if (this.radioState === aRadioState) {
-      return;
-    }
-
-    this.radioState = aRadioState;
-    this.deliverListenerEvent("notifyRadioStateChanged");
-  },
-
-  getNetworks: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("getAvailableNetworks", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      let networks = aResponse.networks;
-      for (let i = 0; i < networks.length; i++) {
-        let info = new MobileNetworkInfo();
-        this._updateInfo(info, networks[i]);
-        networks[i] = info;
-      }
-
-      aCallback.notifyGetNetworksSuccess(networks.length, networks);
-      return false;
-    }).bind(this));
-  },
-
-  selectNetwork: function(aNetwork, aCallback) {
-    if (!aNetwork ||
-        isNaN(parseInt(aNetwork.mcc, 10)) ||
-        isNaN(parseInt(aNetwork.mnc, 10))) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    if (this._selectingNetwork) {
-      this._dispatchNotifyError(aCallback, "AlreadySelectingANetwork");
-      return;
-    }
-
-    let options = {mcc: aNetwork.mcc, mnc: aNetwork.mnc};
-    this._selectingNetwork = options;
-    this._radioInterface.sendWorkerMessage("selectNetwork", options,
-                                           (function(aResponse) {
-      this._selectingNetwork = null;
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  selectNetworkAutomatically: function(aCallback) {
-    if (this._selectingNetwork) {
-      this._dispatchNotifyError(aCallback, "AlreadySelectingANetwork");
-      return;
-    }
-
-    this._selectingNetwork = "automatic";
-    this._radioInterface.sendWorkerMessage("selectNetworkAuto", null,
-                                           (function(aResponse) {
-      this._selectingNetwork = null;
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  setPreferredNetworkType: function(aType, aCallback) {
-    if (this.radioState !== RIL.GECKO_RADIOSTATE_ENABLED) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
-      return;
-    }
-
-    this._radioInterface.sendWorkerMessage("setPreferredNetworkType",
-                                           {type: aType},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getPreferredNetworkType: function(aCallback) {
-    if (this.radioState !== RIL.GECKO_RADIOSTATE_ENABLED) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
-      return;
-    }
-
-    this._radioInterface.sendWorkerMessage("getPreferredNetworkType", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccessWithString(aResponse.type);
-      return false;
-    }).bind(this));
-  },
-
-  setRoamingPreference: function(aMode, aCallback) {
-    this._radioInterface.sendWorkerMessage("setRoamingPreference",
-                                           {mode: aMode},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getRoamingPreference: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("queryRoamingPreference", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccessWithString(aResponse.mode);
-      return false;
-    }).bind(this));
-  },
-
-  setVoicePrivacyMode: function(aEnabled, aCallback) {
-    this._radioInterface.sendWorkerMessage("setVoicePrivacyMode",
-                                           {enabled: aEnabled},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getVoicePrivacyMode: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("queryVoicePrivacyMode", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccessWithBoolean(aResponse.enabled);
-      return false;
-    }).bind(this));
-  },
-
-  sendMMI: function(aMmi, aCallback) {
-    this._radioInterface.sendWorkerMessage("sendMMI", {mmi: aMmi},
-                                           (function(aResponse) {
-      aResponse.serviceCode = aResponse.mmiServiceCode || "";
-      // We expect to have an IMEI at this point if the request was supposed
-      // to query for the IMEI, so getting a successful reply from the RIL
-      // without containing an actual IMEI number is considered an error.
-      if (aResponse.serviceCode === RIL.MMI_KS_SC_IMEI &&
-          !aResponse.statusMessage) {
-        aResponse.errorMsg = aResponse.errorMsg ||
-                             RIL.GECKO_ERROR_GENERIC_FAILURE;
-      }
-
-      if (aResponse.errorMsg) {
-        if (aResponse.additionalInformation) {
-          aCallback.notifyError(aResponse.errorMsg, "",
-                                aResponse.serviceCode,
-                                aResponse.additionalInformation);
-        } else {
-          aCallback.notifyError(aResponse.errorMsg, "",
-                                aResponse.serviceCode);
-        }
-        return false;
-      }
-
-      if (aResponse.isSetCallForward) {
-        this.deliverListenerEvent("notifyCFStateChanged",
-                                  [!aResponse.errorMsg, aResponse.action,
-                                   aResponse.reason, aResponse.number,
-                                   aResponse.timeSeconds, aResponse.serviceClass]);
-      }
-
-      // MMI query call forwarding options request returns a set of rules that
-      // will be exposed in the form of an array of MozCallForwardingOptions
-      // instances.
-      if (aResponse.serviceCode === RIL.MMI_KS_SC_CALL_FORWARDING &&
-          aResponse.additionalInformation) {
-        this._rulesToCallForwardingOptions(aResponse.additionalInformation);
-      }
-
-      let mmiResult = new MMIResult(aResponse);
-      aCallback.notifySendCancelMmiSuccess(mmiResult);
-      return false;
-    }).bind(this));
-  },
-
-  cancelMMI: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("cancelUSSD", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  setCallForwarding: function(aOptions, aCallback) {
-    if (!aOptions ||
-        !this._isValidCallForwardingReason(aOptions.reason) ||
-        !this._isValidCallForwardingAction(aOptions.action)){
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    let options = {
-      active: aOptions.active,
-      action: aOptions.action,
-      reason: aOptions.reason,
-      number: aOptions.number,
-      timeSeconds: aOptions.timeSeconds,
-      serviceClass: RIL.ICC_SERVICE_CLASS_VOICE
-    };
-
-    this._radioInterface.sendWorkerMessage("setCallForward", options,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      this.deliverListenerEvent("notifyCFStateChanged",
-                                [!aResponse.errorMsg, aResponse.action,
-                                 aResponse.reason, aResponse.number,
-                                 aResponse.timeSeconds, aResponse.serviceClass]);
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getCallForwarding: function(aReason, aCallback) {
-    if (!this._isValidCallForwardingReason(aReason)){
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    this._radioInterface.sendWorkerMessage("queryCallForwardStatus",
-                                           {reason: aReason},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      let infos = aResponse.rules;
-      this._rulesToCallForwardingOptions(infos);
-      aCallback.notifyGetCallForwardingSuccess(infos);
-      return false;
-    }).bind(this));
-  },
-
-  setCallBarring: function(aOptions, aCallback) {
-    if (!this._isValidCallBarringOptions(aOptions, true)) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    let options = {
-      program: aOptions.program,
-      enabled: aOptions.enabled,
-      password: aOptions.password,
-      serviceClass: aOptions.serviceClass
-    };
-
-    this._radioInterface.sendWorkerMessage("setCallBarring", options,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getCallBarring: function(aOptions, aCallback) {
-    if (!this._isValidCallBarringOptions(aOptions)) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    let options = {
-      program: aOptions.program,
-      password: aOptions.password,
-      serviceClass: aOptions.serviceClass
-    };
-
-    this._radioInterface.sendWorkerMessage("queryCallBarringStatus", options,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifyGetCallBarringSuccess(aResponse.program,
-                                            aResponse.enabled,
-                                            aResponse.serviceClass);
-      return false;
-    }).bind(this));
-  },
-
-  changeCallBarringPassword: function(aOptions, aCallback) {
-    // Checking valid PIN for supplementary services. See TS.22.004 clause 5.2.
-    if (aOptions.pin == null || !aOptions.pin.match(/^\d{4}$/) ||
-        aOptions.newPin == null || !aOptions.newPin.match(/^\d{4}$/)) {
-      this._dispatchNotifyError(aCallback, "InvalidPassword");
-      return;
-    }
-
-    let options = {
-      pin: aOptions.pin,
-      newPin: aOptions.newPin
-    };
-
-    this._radioInterface.sendWorkerMessage("changeCallBarringPassword", options,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  setCallWaiting: function(aEnabled, aCallback) {
-    this._radioInterface.sendWorkerMessage("setCallWaiting",
-                                           {enabled: aEnabled},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getCallWaiting: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("queryCallWaiting", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccessWithBoolean(aResponse.enabled);
-      return false;
-    }).bind(this));
-  },
-
-  setCallingLineIdRestriction: function(aMode, aCallback) {
-    if (!this._isValidClirMode(aMode)) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_INVALID_PARAMETER);
-      return;
-    }
-
-    if (this.radioState !== RIL.GECKO_RADIOSTATE_ENABLED) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
-      return;
-    }
-
-    this._radioInterface.sendWorkerMessage("setCLIR", {clirMode: aMode},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      this.deliverListenerEvent("notifyClirModeChanged", [aResponse.mode]);
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  getCallingLineIdRestriction: function(aCallback) {
-    if (this.radioState !== RIL.GECKO_RADIOSTATE_ENABLED) {
-      this._dispatchNotifyError(aCallback, RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
-      return;
-    }
-
-    this._radioInterface.sendWorkerMessage("getCLIR", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifyGetClirStatusSuccess(aResponse.n, aResponse.m);
-      return false;
-    }).bind(this));
-  },
-
-  exitEmergencyCbMode: function(aCallback) {
-    this._radioInterface.sendWorkerMessage("exitEmergencyCbMode", null,
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return false;
-      }
-
-      aCallback.notifySuccess();
-      return false;
-    }).bind(this));
-  },
-
-  setRadioEnabled: function(aEnabled, aCallback) {
-    this._radioInterface.sendWorkerMessage("setRadioEnabled",
-                                           {enabled: aEnabled},
-                                           (function(aResponse) {
-      if (aResponse.errorMsg) {
-        aCallback.notifyError(aResponse.errorMsg);
-        return true;
-      }
-
-      aCallback.notifySuccess();
-      return true;
-    }).bind(this));
-  },
-};
-
-function MobileConnectionGonkService() {
-  this._providers = [];
-
-  let numClients = gRadioInterfaceLayer.numRadioInterfaces;
-  for (let i = 0; i < numClients; i++) {
-    let radioInterface = gRadioInterfaceLayer.getRadioInterface(i);
-    let provider = new MobileConnectionProvider(i, radioInterface);
-    this._providers.push(provider);
-  }
-
-  Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
-  Services.obs.addObserver(this, NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID, false);
-  Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-
-  debug("init complete");
-}
-MobileConnectionGonkService.prototype = {
-  classID: MOBILECONNECTIONGONKSERVICE_CID,
-  classInfo: XPCOMUtils.generateCI({classID: MOBILECONNECTIONGONKSERVICE_CID,
-                                    contractID: MOBILECONNECTIONGONKSERVICE_CONTRACTID,
-                                    classDescription: "MobileConnectionGonkService",
-                                    interfaces: [Ci.nsIMobileConnectionGonkService,
-                                                 Ci.nsIMobileConnectionService],
-                                    flags: Ci.nsIClassInfo.SINGLETON}),
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionGonkService,
-                                         Ci.nsIMobileConnectionService,
-                                         Ci.nsIObserver]),
-
-  // An array of MobileConnectionProvider instances.
-  _providers: null,
-
-  _shutdown: function() {
-    Services.prefs.removeObserver(kPrefRilDebuggingEnabled, this);
-    Services.obs.removeObserver(this, NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID);
-    Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-  },
-
-  _updateDebugFlag: function() {
-    try {
-      DEBUG = RIL.DEBUG_RIL ||
-              Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
-    } catch (e) {}
-  },
-
-  /**
-   * nsIMobileConnectionService interface.
-   */
-  registerListener: function(aClientId, aListener) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.registerListener(aListener);
-  },
-
-  unregisterListener: function(aClientId, aListener) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.unregisterListener(aListener);
-  },
-
-  getVoiceConnectionInfo: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.voiceInfo;
-  },
-
-  getDataConnectionInfo: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.dataInfo;
-  },
-
-  getIccId: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.iccId;
-  },
-
-  getNetworkSelectionMode: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.networkSelectMode;
-  },
-
-  getRadioState: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.radioState;
-  },
-
-  getLastKnownNetwork: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.lastKnownNetwork;
-  },
-
-  getLastKnownHomeNetwork: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.lastKnownHomeNetwork;
-  },
-
-  getSupportedNetworkTypes: function(aClientId) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    return provider.supportedNetworkTypes;
-  },
-
-  getNetworks: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getNetworks(aCallback);
-  },
-
-  selectNetwork: function(aClientId, aNetwork, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.selectNetwork(aNetwork, aCallback);
-  },
-
-  selectNetworkAutomatically: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.selectNetworkAutomatically(aCallback);
-  },
-
-  setPreferredNetworkType: function(aClientId, aType, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setPreferredNetworkType(aType, aCallback);
-  },
-
-  getPreferredNetworkType: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getPreferredNetworkType(aCallback);
-  },
-
-  setRoamingPreference: function(aClientId, aMode, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setRoamingPreference(aMode, aCallback);
-  },
-
-  getRoamingPreference: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getRoamingPreference(aCallback);
-  },
-
-  setVoicePrivacyMode: function(aClientId, aEnabled, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setVoicePrivacyMode(aEnabled, aCallback);
-  },
-
-  getVoicePrivacyMode: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getVoicePrivacyMode(aCallback);
-  },
-
-  sendMMI: function(aClientId, aMmi, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.sendMMI(aMmi, aCallback);
-  },
-
-  cancelMMI: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.cancelMMI(aCallback);
-  },
-
-  setCallForwarding: function(aClientId, aOptions, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setCallForwarding(aOptions, aCallback);
-  },
-
-  getCallForwarding: function(aClientId, aReason, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getCallForwarding(aReason, aCallback);
-  },
-
-  setCallBarring: function(aClientId, aOptions, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setCallBarring(aOptions, aCallback);
-  },
-
-  getCallBarring: function(aClientId, aOptions, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getCallBarring(aOptions, aCallback);
-  },
-
-  changeCallBarringPassword: function(aClientId, aOptions, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.changeCallBarringPassword(aOptions, aCallback);
-  },
-
-  setCallWaiting: function(aClientId, aEnabled, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setCallWaiting(aEnabled, aCallback);
-  },
-
-  getCallWaiting: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getCallWaiting(aCallback);
-  },
-
-  setCallingLineIdRestriction: function(aClientId, aMode, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setCallingLineIdRestriction(aMode, aCallback);
-  },
-
-  getCallingLineIdRestriction: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.getCallingLineIdRestriction(aCallback);
-  },
-
-  exitEmergencyCbMode: function(aClientId, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.exitEmergencyCbMode(aCallback);
-  },
-
-  setRadioEnabled: function(aClientId, aEnabled, aCallback) {
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.setRadioEnabled(aEnabled, aCallback);
-  },
-
-  /**
-   * nsIMobileConnectionGonkService interface.
-   */
-  notifyVoiceInfoChanged: function(aClientId, aVoiceInfo) {
-    if (DEBUG) {
-      debug("notifyVoiceInfoChanged for " + aClientId + ": " +
-            JSON.stringify(aVoiceInfo));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateVoiceInfo(aVoiceInfo);
-  },
-
-  notifyDataInfoChanged: function(aClientId, aDataInfo) {
-    if (DEBUG) {
-      debug("notifyDataInfoChanged for " + aClientId + ": " +
-            JSON.stringify(aDataInfo));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateDataInfo(aDataInfo);
-  },
-
-  notifyUssdReceived: function(aClientId, aMessage, aSessionEnded) {
-    if (DEBUG) {
-      debug("notifyUssdReceived for " + aClientId + ": " +
-            JSON.stringify(ussd));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.deliverListenerEvent("notifyUssdReceived",
-                                [aMessage, aSessionEnded]);
-
-    let info = {
-      message: aMessage,
-      sessionEnded: aSessionEnded,
-      serviceId: aClientId
-    };
-
-    gSystemMessenger.broadcastMessage("ussd-received", info);
-  },
-
-  notifyDataError: function(aClientId, aMessage) {
-    if (DEBUG) {
-      debug("notifyDataError for " + aClientId + ": " + aMessage);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.deliverListenerEvent("notifyDataError", [aMessage]);
-  },
-
-  notifyEmergencyCallbackModeChanged: function(aClientId, aActive, aTimeoutMs) {
-    if (DEBUG) {
-      debug("notifyEmergencyCbModeChanged for " + aClientId + ": " +
-            JSON.stringify({active: aActive, timeoutMs: aTimeoutMs}));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.deliverListenerEvent("notifyEmergencyCbModeChanged",
-                                [aActive, aTimeoutMs]);
-  },
-
-  notifyOtaStatusChanged: function(aClientId, aStatus) {
-    if (DEBUG) {
-      debug("notifyOtaStatusChanged for " + aClientId + ": " + aStatus);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.deliverListenerEvent("notifyOtaStatusChanged", [aStatus]);
-  },
-
-  notifyIccChanged: function(aClientId, aIccId) {
-    if (DEBUG) {
-      debug("notifyIccChanged for " + aClientId + ": " + aIccId);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateIccId(aIccId);
-  },
-
-  notifyRadioStateChanged: function(aClientId, aRadioState) {
-    if (DEBUG) {
-      debug("notifyRadioStateChanged for " + aClientId + ": " + aRadioState);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateRadioState(aRadioState);
-  },
-
-  notifyNetworkInfoChanged: function(aClientId, aNetworkInfo) {
-    if (DEBUG) {
-      debug("notifyNetworkInfoChanged for " + aClientId + ": " +
-            JSON.stringify(aNetworkInfo));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    let isVoiceUpdated = false;
-    let isDataUpdated = false;
-    let operatorMessage = aNetworkInfo[RIL.NETWORK_INFO_OPERATOR];
-    let voiceMessage = aNetworkInfo[RIL.NETWORK_INFO_VOICE_REGISTRATION_STATE];
-    let dataMessage = aNetworkInfo[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE];
-    let signalMessage = aNetworkInfo[RIL.NETWORK_INFO_SIGNAL];
-    let selectionMessage = aNetworkInfo[RIL.NETWORK_INFO_NETWORK_SELECTION_MODE];
-
-    // Batch the *InfoChanged messages together
-    if (operatorMessage) {
-      provider.updateOperatorInfo(operatorMessage, true);
-    }
-
-    if (voiceMessage) {
-      provider.updateVoiceInfo(voiceMessage, true);
-    }
-
-    if (dataMessage) {
-      provider.updateDataInfo(dataMessage, true);
-    }
-
-    if (signalMessage) {
-      provider.updateSignalInfo(signalMessage, true);
-    }
-
-    if (selectionMessage) {
-      this.notifyNetworkSelectModeChanged(aClientId, selectionMessage.mode);
-    }
-
-    if (voiceMessage || operatorMessage || signalMessage) {
-      provider.deliverListenerEvent("notifyVoiceChanged");
-    }
-
-    if (dataMessage || operatorMessage || signalMessage) {
-      provider.deliverListenerEvent("notifyDataChanged");
-    }
-  },
-
-  notifySignalStrengthChanged: function(aClientId, aSignal) {
-    if (DEBUG) {
-      debug("notifySignalStrengthChanged for " + aClientId + ": " +
-            JSON.stringify(aSignal));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateSignalInfo(aSignal);
-  },
-
-  notifyOperatorChanged: function(aClientId, aOperator) {
-    if (DEBUG) {
-      debug("notifyOperatorChanged for " + aClientId + ": " +
-            JSON.stringify(aOperator));
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    provider.updateOperatorInfo(aOperator);
-  },
-
-  notifyNetworkSelectModeChanged: function(aClientId, aMode) {
-    if (DEBUG) {
-      debug("notifyNetworkSelectModeChanged for " + aClientId + ": " + aMode);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    if (provider.networkSelectMode === aMode) {
-      return;
-    }
-
-    provider.networkSelectMode = aMode;
-    provider.deliverListenerEvent("notifyNetworkSelectionModeChanged");
-  },
-
-  notifySpnAvailable: function(aClientId) {
-    if (DEBUG) {
-      debug("notifySpnAvailable for " + aClientId);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    // Update voice roaming state
-    provider.updateVoiceInfo({});
-
-    // Update data roaming state
-    provider.updateDataInfo({});
-  },
-
-  notifyLastHomeNetworkChanged: function(aClientId, aNetwork) {
-    if (DEBUG) {
-      debug("notifyLastHomeNetworkChanged for " + aClientId + ": " + aNetwork);
-    }
-
-    let provider = this._providers[aClientId];
-    if (!provider) {
-      throw Cr.NS_ERROR_UNEXPECTED;
-    }
-
-    if (provider.lastKnownHomeNetwork === aNetwork) {
-      return;
-    }
-
-    provider.lastKnownHomeNetwork = aNetwork;
-    provider.deliverListenerEvent("notifyLastKnownHomeNetworkChanged");
-  },
-
-  /**
-   * nsIObserver interface.
-   */
-  observe: function(aSubject, aTopic, aData) {
-    switch (aTopic) {
-      case NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID:
-        for (let i = 0; i < this._providers.length; i++) {
-          let provider = this._providers[i];
-          // Update connected flag only.
-          provider.updateDataInfo({});
-        }
-        break;
-      case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
-        if (aData === kPrefRilDebuggingEnabled) {
-          this._updateDebugFlag();
-        }
-        break;
-      case NS_XPCOM_SHUTDOWN_OBSERVER_ID:
-        this._shutdown();
-        break;
-    }
-  }
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileConnectionGonkService]);
deleted file mode 100644
--- a/dom/mobileconnection/src/gonk/MobileConnectionGonkService.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-component {05e20430-fe65-4984-8df9-a6a504b24a91} MobileConnectionGonkService.js
-contract @mozilla.org/mobileconnection/mobileconnectiongonkservice;1 {05e20430-fe65-4984-8df9-a6a504b24a91}
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionChild.cpp
+++ /dev/null
@@ -1,484 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MobileConnectionChild.h"
-
-#include "MobileConnectionCallback.h"
-#include "mozilla/dom/MozMobileConnectionBinding.h"
-#include "nsComponentManagerUtils.h"
-
-using namespace mozilla::dom;
-using namespace mozilla::dom::mobileconnection;
-
-void
-MobileConnectionChild::Init()
-{
-  nsIMobileConnectionInfo* rawVoice;
-  nsIMobileConnectionInfo* rawData;
-  nsTArray<nsString> types;
-
-  SendInit(&rawVoice, &rawData, &mLastNetwork, &mLastHomeNetwork, &mIccId,
-           &mNetworkSelectionMode, &mRadioState, &types);
-
-  // Use dont_AddRef here because this instances is already AddRef-ed in
-  // MobileConnectionIPCSerializer.h
-  nsCOMPtr<nsIMobileConnectionInfo> voice = dont_AddRef(rawVoice);
-  mVoice = new MobileConnectionInfo(nullptr);
-  mVoice->Update(voice);
-
-  // Use dont_AddRef here because this instances is already AddRef-ed in
-  // MobileConnectionIPCSerializer.h
-  nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(rawData);
-  mData = new MobileConnectionInfo(nullptr);
-  mData->Update(data);
-
-
-  // Initial SupportedNetworkTypes
-  nsresult rv;
-  mSupportedNetworkTypes = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
-
-  if (NS_FAILED(rv)) {
-    return;
-  }
-
-  uint32_t arrayLen = types.Length();
-  if (arrayLen == 0) {
-    mSupportedNetworkTypes->SetAsEmptyArray();
-  } else {
-    // Note: The resulting nsIVariant dupes both the array and its elements.
-    const char16_t** array = reinterpret_cast<const char16_t**>
-                               (NS_Alloc(arrayLen * sizeof(const char16_t***)));
-    if (array) {
-      for (uint32_t i = 0; i < arrayLen; ++i) {
-        array[i] = types[i].get();
-      }
-
-      mSupportedNetworkTypes->SetAsArray(nsIDataType::VTYPE_WCHAR_STR,
-                                         nullptr,
-                                         arrayLen,
-                                         reinterpret_cast<void*>(array));
-      NS_Free(array);
-    }
-  }
-}
-
-void
-MobileConnectionChild::Shutdown()
-{
-  if (mLive) {
-    mLive = false;
-    Send__delete__(this);
-  }
-
-  mListeners.Clear();
-  mVoice = nullptr;
-  mData = nullptr;
-  mSupportedNetworkTypes = nullptr;
-}
-
-void
-MobileConnectionChild::RegisterListener(nsIMobileConnectionListener* aListener)
-{
-  if (!mListeners.Contains(aListener)) {
-    mListeners.AppendObject(aListener);
-  }
-}
-
-void
-MobileConnectionChild::UnregisterListener(nsIMobileConnectionListener* aListener)
-{
-  mListeners.RemoveObject(aListener);
-}
-
-MobileConnectionInfo*
-MobileConnectionChild::GetVoiceInfo()
-{
-  return mVoice;
-}
-
-MobileConnectionInfo*
-MobileConnectionChild::GetDataInfo()
-{
-  return mData;
-}
-
-void
-MobileConnectionChild::GetIccId(nsAString& aIccId)
-{
-  aIccId = mIccId;
-}
-
-void
-MobileConnectionChild::GetRadioState(nsAString& aRadioState)
-{
-  aRadioState = mRadioState;
-}
-
-nsIVariant*
-MobileConnectionChild::GetSupportedNetworkTypes()
-{
-  return mSupportedNetworkTypes;
-}
-
-void
-MobileConnectionChild::GetLastNetwork(nsAString& aNetwork)
-{
-  aNetwork = mLastNetwork;
-}
-
-void
-MobileConnectionChild::GetLastHomeNetwork(nsAString& aNetwork)
-{
-  aNetwork = mLastHomeNetwork;
-}
-
-void
-MobileConnectionChild::GetNetworkSelectionMode(nsAString& aMode)
-{
-  aMode = mNetworkSelectionMode;
-}
-
-bool
-MobileConnectionChild::SendRequest(MobileConnectionRequest aRequest,
-                                   nsIMobileConnectionCallback* aRequestCallback)
-{
-  NS_ENSURE_TRUE(mLive, false);
-
-  // Deallocated in MobileConnectionChild::DeallocPMobileConnectionRequestChild().
-  MobileConnectionRequestChild* actor = new MobileConnectionRequestChild(aRequestCallback);
-  SendPMobileConnectionRequestConstructor(actor, aRequest);
-
-  return true;
-}
-
-void
-MobileConnectionChild::ActorDestroy(ActorDestroyReason why)
-{
-  mLive = false;
-}
-
-PMobileConnectionRequestChild*
-MobileConnectionChild::AllocPMobileConnectionRequestChild(const MobileConnectionRequest& request)
-{
-  MOZ_CRASH("Caller is supposed to manually construct a request!");
-}
-
-bool
-MobileConnectionChild::DeallocPMobileConnectionRequestChild(PMobileConnectionRequestChild* aActor)
-{
-  delete aActor;
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyVoiceInfoChanged(nsIMobileConnectionInfo* const& aInfo)
-{
-  // Use dont_AddRef here because this instances is already AddRef-ed in
-  // MobileConnectionIPCSerializer.h
-  nsCOMPtr<nsIMobileConnectionInfo> voice = dont_AddRef(aInfo);
-  mVoice->Update(voice);
-
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyVoiceChanged();
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyDataInfoChanged(nsIMobileConnectionInfo* const& aInfo)
-{
-  // Use dont_AddRef here because this instances is already AddRef-ed in
-  // MobileConnectionIPCSerializer.h
-  nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(aInfo);
-  mData->Update(data);
-
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyDataChanged();
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyUssdReceived(const nsString& aMessage,
-                                              const bool& aSessionEnd)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyUssdReceived(aMessage, aSessionEnd);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyDataError(const nsString& aMessage)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyDataError(aMessage);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyCFStateChanged(const bool& aSuccess,
-                                                const uint16_t& aAction,
-                                                const uint16_t& aReason,
-                                                const nsString& aNumber,
-                                                const uint16_t& aTimeSeconds,
-                                                const uint16_t& aServiceClass)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyCFStateChanged(aSuccess, aAction, aReason, aNumber,
-                                        aTimeSeconds, aServiceClass);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyEmergencyCbModeChanged(const bool& aActive,
-                                                        const uint32_t& aTimeoutMs)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyEmergencyCbModeChanged(aActive, aTimeoutMs);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyOtaStatusChanged(const nsString& aStatus)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyOtaStatusChanged(aStatus);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyIccChanged(const nsString& aIccId)
-{
-  mIccId.Assign(aIccId);
-
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyIccChanged();
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyRadioStateChanged(const nsString& aRadioState)
-{
-  mRadioState.Assign(aRadioState);
-
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyRadioStateChanged();
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyClirModeChanged(const uint32_t& aMode)
-{
-  for (int32_t i = 0; i < mListeners.Count(); i++) {
-    mListeners[i]->NotifyClirModeChanged(aMode);
-  }
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyLastNetworkChanged(const nsString& aNetwork)
-{
-  mLastNetwork.Assign(aNetwork);
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyLastHomeNetworkChanged(const nsString& aNetwork)
-{
-  mLastHomeNetwork.Assign(aNetwork);
-
-  return true;
-}
-
-bool
-MobileConnectionChild::RecvNotifyNetworkSelectionModeChanged(const nsString& aMode)
-{
-  mNetworkSelectionMode.Assign(aMode);
-
-  return true;
-}
-
-/******************************************************************************
- * MobileConnectionRequestChild
- ******************************************************************************/
-
-void
-MobileConnectionRequestChild::ActorDestroy(ActorDestroyReason why)
-{
-  mRequestCallback = nullptr;
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccess& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifySuccess());
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessString& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifySuccessWithString(aReply.result()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessBoolean& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifySuccessWithBoolean(aReply.result()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessNetworks& aReply)
-{
-  uint32_t count = aReply.results().Length();
-  nsTArray<nsCOMPtr<nsIMobileNetworkInfo>> results;
-  for (uint32_t i = 0; i < count; i++) {
-    // Use dont_AddRef here because these instances are already AddRef-ed in
-    // MobileConnectionIPCSerializer.h
-    nsCOMPtr<nsIMobileNetworkInfo> item = dont_AddRef(aReply.results()[i]);
-    results.AppendElement(item);
-  }
-
-  return NS_SUCCEEDED(mRequestCallback->NotifyGetNetworksSuccess(count,
-                                                                 const_cast<nsIMobileNetworkInfo**>(aReply.results().Elements())));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessMmi& aReply)
-{
-  nsAutoString serviceCode(aReply.serviceCode());
-  nsAutoString statusMessage(aReply.statusMessage());
-  AdditionalInformation info(aReply.additionalInformation());
-
-  nsRefPtr<MobileConnectionCallback> callback = static_cast<MobileConnectionCallback*>(mRequestCallback.get());
-
-
-  // Handle union types
-  switch (info.type()) {
-    case AdditionalInformation::Tvoid_t:
-      return NS_SUCCEEDED(callback->NotifySendCancelMmiSuccess(serviceCode,
-                                                               statusMessage));
-    case AdditionalInformation::Tuint16_t:
-      return NS_SUCCEEDED(callback->NotifySendCancelMmiSuccess(serviceCode,
-                                                               statusMessage,
-                                                               info.get_uint16_t()));
-    case AdditionalInformation::TArrayOfnsString:
-      return NS_SUCCEEDED(callback->NotifySendCancelMmiSuccess(serviceCode,
-                                                               statusMessage,
-                                                               info.get_ArrayOfnsString()));
-    case AdditionalInformation::TArrayOfMozCallForwardingOptions:
-      return NS_SUCCEEDED(callback->NotifySendCancelMmiSuccess(serviceCode,
-                                                               statusMessage,
-                                                               info.get_ArrayOfMozCallForwardingOptions()));
-
-    default:
-      MOZ_CRASH("Received invalid type!");
-  }
-
-  return false;
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallForwarding& aReply)
-{
-  nsRefPtr<MobileConnectionCallback> callback = static_cast<MobileConnectionCallback*>(mRequestCallback.get());
-  return NS_SUCCEEDED(callback->NotifyGetCallForwardingSuccess(aReply.results()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessCallBarring& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifyGetCallBarringSuccess(aReply.program(),
-                                                                    aReply.enabled(),
-                                                                    aReply.serviceClass()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplySuccessClirStatus& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifyGetClirStatusSuccess(aReply.n(),
-                                                                   aReply.m()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplyError& aReply)
-{
-  return NS_SUCCEEDED(mRequestCallback->NotifyError(aReply.message()));
-}
-
-bool
-MobileConnectionRequestChild::DoReply(const MobileConnectionReplyErrorMmi& aReply)
-{
-  nsAutoString name(aReply.name());
-  nsAutoString message(aReply.message());
-  nsAutoString serviceCode(aReply.serviceCode());
-  AdditionalInformation info(aReply.additionalInformation());
-
-  // Handle union types
-  switch (info.type()) {
-    case AdditionalInformation::Tuint16_t:
-      return NS_SUCCEEDED(mRequestCallback->NotifyError(name,
-                                                        message,
-                                                        serviceCode,
-                                                        info.get_uint16_t()));
-    case AdditionalInformation::Tvoid_t:
-    default:
-      // If additionInfomation is not uint16_t, handle it as void_t.
-      return NS_SUCCEEDED(mRequestCallback->NotifyError(name,
-                                                        message,
-                                                        serviceCode));
-  }
-
-  return false;
-}
-
-bool
-MobileConnectionRequestChild::Recv__delete__(const MobileConnectionReply& aReply)
-{
-  MOZ_ASSERT(mRequestCallback);
-
-  switch (aReply.type()) {
-    case MobileConnectionReply::TMobileConnectionReplySuccess:
-      return DoReply(aReply.get_MobileConnectionReplySuccess());
-    case MobileConnectionReply::TMobileConnectionReplySuccessString:
-      return DoReply(aReply.get_MobileConnectionReplySuccessString());
-    case MobileConnectionReply::TMobileConnectionReplySuccessBoolean:
-      return DoReply(aReply.get_MobileConnectionReplySuccessBoolean());
-    case MobileConnectionReply::TMobileConnectionReplySuccessNetworks:
-      return DoReply(aReply.get_MobileConnectionReplySuccessNetworks());
-    case MobileConnectionReply::TMobileConnectionReplySuccessMmi:
-      return DoReply(aReply.get_MobileConnectionReplySuccessMmi());
-    case MobileConnectionReply::TMobileConnectionReplySuccessCallForwarding:
-      return DoReply(aReply.get_MobileConnectionReplySuccessCallForwarding());
-    case MobileConnectionReply::TMobileConnectionReplySuccessCallBarring:
-      return DoReply(aReply.get_MobileConnectionReplySuccessCallBarring());
-    case MobileConnectionReply::TMobileConnectionReplySuccessClirStatus:
-      return DoReply(aReply.get_MobileConnectionReplySuccessClirStatus());
-    case MobileConnectionReply::TMobileConnectionReplyError:
-      return DoReply(aReply.get_MobileConnectionReplyError());
-    case MobileConnectionReply::TMobileConnectionReplyErrorMmi:
-      return DoReply(aReply.get_MobileConnectionReplyErrorMmi());
-    default:
-      MOZ_CRASH("Received invalid response type!");
-  }
-
-  return false;
-}
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionChild.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_mobileconnection_MobileConnectionChild_h
-#define mozilla_dom_mobileconnection_MobileConnectionChild_h
-
-#include "mozilla/dom/MobileConnectionCallback.h"
-#include "mozilla/dom/MobileConnectionInfo.h"
-#include "mozilla/dom/PMobileConnectionChild.h"
-#include "mozilla/dom/PMobileConnectionRequestChild.h"
-#include "nsCOMArray.h"
-#include "nsCOMPtr.h"
-#include "nsIMobileConnectionService.h"
-#include "nsIVariant.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobileconnection {
-
-/**
- * Child actor of PMobileConnection. The object is created by
- * MobileConnectionIPCService and destroyed after MobileConnectionIPCService is
- * shutdown. For multi-sim device, more than one instance will
- * be created and each instance represents a sim slot.
- */
-class MobileConnectionChild : public PMobileConnectionChild
-{
-  NS_INLINE_DECL_REFCOUNTING(MobileConnectionChild)
-
-public:
-  MobileConnectionChild()
-    : mLive(true)
-  {
-    MOZ_COUNT_CTOR(MobileConnectionChild);
-  }
-
-  void
-  Init();
-
-  void
-  Shutdown();
-
-  void
-  RegisterListener(nsIMobileConnectionListener* aListener);
-
-  void
-  UnregisterListener(nsIMobileConnectionListener* aListener);
-
-  MobileConnectionInfo*
-  GetVoiceInfo();
-
-  MobileConnectionInfo*
-  GetDataInfo();
-
-  void
-  GetIccId(nsAString& aIccId);
-
-  void
-  GetRadioState(nsAString& aRadioState);
-
-  nsIVariant*
-  GetSupportedNetworkTypes();
-
-  void
-  GetLastNetwork(nsAString& aNetwork);
-
-  void
-  GetLastHomeNetwork(nsAString& aNetwork);
-
-  void
-  GetNetworkSelectionMode(nsAString& aMode);
-
-  bool
-  SendRequest(MobileConnectionRequest aRequest,
-              nsIMobileConnectionCallback* aRequestCallback);
-
-protected:
-  virtual
-  ~MobileConnectionChild()
-  {
-    MOZ_COUNT_DTOR(MobileConnectionChild);
-    Shutdown();
-  }
-
-  virtual void
-  ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
-
-  virtual PMobileConnectionRequestChild*
-  AllocPMobileConnectionRequestChild(const MobileConnectionRequest& request) MOZ_OVERRIDE;
-
-  virtual bool
-  DeallocPMobileConnectionRequestChild(PMobileConnectionRequestChild* aActor) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyVoiceInfoChanged(nsIMobileConnectionInfo* const& aInfo) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyDataInfoChanged(nsIMobileConnectionInfo* const& aInfo) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyUssdReceived(const nsString& aMessage,
-                         const bool& aSessionEnd) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyDataError(const nsString& aMessage) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyCFStateChanged(const bool& aSuccess, const uint16_t& aAction,
-                           const uint16_t& aReason, const nsString& aNumber,
-                           const uint16_t& aTimeSeconds, const uint16_t& aServiceClass) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyEmergencyCbModeChanged(const bool& aActive,
-                                   const uint32_t& aTimeoutMs) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyOtaStatusChanged(const nsString& aStatus) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyIccChanged(const nsString& aIccId) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyRadioStateChanged(const nsString& aRadioState) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyClirModeChanged(const uint32_t& aMode) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyLastNetworkChanged(const nsString& aNetwork) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyLastHomeNetworkChanged(const nsString& aNetwork) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvNotifyNetworkSelectionModeChanged(const nsString& aMode) MOZ_OVERRIDE;
-
-private:
-  bool mLive;
-  nsCOMArray<nsIMobileConnectionListener> mListeners;
-  nsCOMPtr<nsIWritableVariant> mSupportedNetworkTypes;
-  nsRefPtr<MobileConnectionInfo> mVoice;
-  nsRefPtr<MobileConnectionInfo> mData;
-  nsString mIccId;
-  nsString mRadioState;
-  nsString mLastNetwork;
-  nsString mLastHomeNetwork;
-  nsString mNetworkSelectionMode;
-};
-
-/******************************************************************************
- * PMobileConnectionRequestChild
- ******************************************************************************/
-
-/**
- * Child actor of PMobileConnectionRequest. The object is created when an
- * asynchronous request is made and destroyed after receiving the response sent
- * by parent actor.
- */
-class MobileConnectionRequestChild : public PMobileConnectionRequestChild
-{
-public:
-  MobileConnectionRequestChild(nsIMobileConnectionCallback* aRequestCallback)
-    : mRequestCallback(aRequestCallback)
-  {
-    MOZ_COUNT_CTOR(MobileConnectionRequestChild);
-    MOZ_ASSERT(mRequestCallback);
-  }
-
-  bool
-  DoReply(const MobileConnectionReplySuccess& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessString& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessBoolean& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessNetworks& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessMmi& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessCallForwarding& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessCallBarring& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplySuccessClirStatus& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplyError& aReply);
-
-  bool
-  DoReply(const MobileConnectionReplyErrorMmi& aReply);
-
-protected:
-  virtual
-  ~MobileConnectionRequestChild()
-  {
-    MOZ_COUNT_DTOR(MobileConnectionRequestChild);
-  }
-
-  virtual void
-  ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
-
-  virtual bool
-  Recv__delete__(const MobileConnectionReply& aReply) MOZ_OVERRIDE;
-
-private:
-  nsCOMPtr<nsIMobileConnectionCallback> mRequestCallback;
-};
-
-} // namespace mobileconnection
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobileconnection_MobileConnectionChild_h
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionIPCSerializer.h
+++ /dev/null
@@ -1,749 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
-#define dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
-
-#include "ipc/IPCMessageUtils.h"
-#include "mozilla/dom/MobileCellInfo.h"
-#include "mozilla/dom/MobileConnectionInfo.h"
-#include "mozilla/dom/MobileNetworkInfo.h"
-#include "MozMobileConnectionBinding.h"
-
-using mozilla::AutoSafeJSContext;
-using mozilla::dom::MobileNetworkInfo;
-using mozilla::dom::MobileCellInfo;
-using mozilla::dom::MobileConnectionInfo;
-
-typedef nsIMobileCellInfo* nsMobileCellInfo;
-typedef nsIMobileConnectionInfo* nsMobileConnectionInfo;
-typedef nsIMobileNetworkInfo* nsMobileNetworkInfo;
-
-namespace IPC {
-
-struct MozCallForwardingOptions : public mozilla::dom::MozCallForwardingOptions
-{
-  bool operator==(const MozCallForwardingOptions& aOther) const
-  {
-    return // Compare mActive
-           ((!mActive.WasPassed() && !aOther.mActive.WasPassed()) ||
-            (mActive.WasPassed() && aOther.mActive.WasPassed() &&
-             mActive.Value() == aOther.mActive.Value())) &&
-           // Compare mAction
-           ((!mAction.WasPassed() && !aOther.mAction.WasPassed()) ||
-            (mAction.WasPassed() && aOther.mAction.WasPassed() &&
-             mAction.Value() == aOther.mAction.Value())) &&
-           // Compare mReason
-           ((!mReason.WasPassed() && !aOther.mReason.WasPassed()) ||
-            (mReason.WasPassed() && aOther.mReason.WasPassed() &&
-             mReason.Value() == aOther.mReason.Value())) &&
-           // Compare mNumber
-           ((!mNumber.WasPassed() && !aOther.mNumber.WasPassed()) ||
-            (mNumber.WasPassed() && aOther.mNumber.WasPassed() &&
-             mNumber.Value() == aOther.mNumber.Value())) &&
-           // Compare mTimeSeconds
-           ((!mTimeSeconds.WasPassed() && !aOther.mTimeSeconds.WasPassed()) ||
-            (mTimeSeconds.WasPassed() && aOther.mTimeSeconds.WasPassed() &&
-             mTimeSeconds.Value() == aOther.mTimeSeconds.Value())) &&
-           // Compare mServiceClass
-           ((!mServiceClass.WasPassed() && !aOther.mServiceClass.WasPassed()) ||
-            (mServiceClass.WasPassed() && aOther.mServiceClass.WasPassed() &&
-             mServiceClass.Value() == aOther.mServiceClass.Value()));
-  };
-};
-
-struct MozCallBarringOptions : mozilla::dom::MozCallBarringOptions
-{
-  bool operator==(const MozCallBarringOptions& aOther) const
-  {
-    return // Compare mEnabled
-           ((!mEnabled.WasPassed() && !aOther.mEnabled.WasPassed()) ||
-            (mEnabled.WasPassed() && aOther.mEnabled.WasPassed() &&
-             mEnabled.Value() == aOther.mEnabled.Value())) &&
-           // Compare mPassword
-           ((!mPassword.WasPassed() && !aOther.mPassword.WasPassed()) ||
-            (mPassword.WasPassed() && aOther.mPassword.WasPassed() &&
-             mPassword.Value() == aOther.mPassword.Value())) &&
-           // Compare mProgram
-           ((!mProgram.WasPassed() && !aOther.mProgram.WasPassed()) ||
-            (mProgram.WasPassed() && aOther.mProgram.WasPassed() &&
-             mProgram.Value() == aOther.mProgram.Value())) &&
-           // Compare mServiceClass
-           ((!mServiceClass.WasPassed() && !aOther.mServiceClass.WasPassed()) ||
-            (mServiceClass.WasPassed() && aOther.mServiceClass.WasPassed() &&
-             mServiceClass.Value() == aOther.mServiceClass.Value()));
-  };
-};
-
-/**
- * nsIMobileNetworkInfo Serialize/De-serialize.
- */
-template <>
-struct ParamTraits<nsIMobileNetworkInfo*>
-{
-  typedef nsIMobileNetworkInfo* paramType;
-
-  // Function to serialize a MobileNetworkInfo.
-  static void Write(Message *aMsg, const paramType& aParam)
-  {
-    bool isNull = !aParam;
-    WriteParam(aMsg, isNull);
-    // If it is a null object, then we are done.
-    if (isNull) {
-      return;
-    }
-
-    nsString pString;
-    aParam->GetShortName(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetLongName(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetMcc(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetMnc(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetState(pString);
-    WriteParam(aMsg, pString);
-
-    // We release the ref here given that ipdl won't handle reference counting.
-    aParam->Release();
-  }
-
-  // Function to de-serialize a MobileNetworkInfo.
-  static bool Read(const Message *aMsg, void **aIter, paramType* aResult)
-  {
-    // Check if is the null pointer we have transfered.
-    bool isNull;
-    if (!ReadParam(aMsg, aIter, &isNull)) {
-      return false;
-    }
-
-    if (isNull) {
-      *aResult = nullptr;
-      return true;
-    }
-
-    nsString shortName;
-    nsString longName;
-    nsString mcc;
-    nsString mnc;
-    nsString state;
-
-    // It's not important to us where it fails, but rather if it fails
-    if (!(ReadParam(aMsg, aIter, &shortName) &&
-          ReadParam(aMsg, aIter, &longName) &&
-          ReadParam(aMsg, aIter, &mcc) &&
-          ReadParam(aMsg, aIter, &mnc) &&
-          ReadParam(aMsg, aIter, &state))) {
-      return false;
-    }
-
-    *aResult = new MobileNetworkInfo(shortName,
-                                     longName,
-                                     mcc,
-                                     mnc,
-                                     state);
-    // We release this ref after receiver finishes processing.
-    NS_ADDREF(*aResult);
-
-    return true;
-  }
-};
-
-/**
- * nsIMobileCellInfo Serialize/De-serialize.
- */
-template <>
-struct ParamTraits<nsIMobileCellInfo*>
-{
-  typedef nsIMobileCellInfo* paramType;
-
-  // Function to serialize a MobileCellInfo.
-  static void Write(Message *aMsg, const paramType& aParam)
-  {
-    bool isNull = !aParam;
-    WriteParam(aMsg, isNull);
-    // If it is a null object, then we are done.
-    if (isNull) {
-      return;
-    }
-
-    int32_t pLong;
-    int64_t pLongLong;
-
-    aParam->GetGsmLocationAreaCode(&pLong);
-    WriteParam(aMsg, pLong);
-
-    aParam->GetGsmCellId(&pLongLong);
-    WriteParam(aMsg, pLongLong);
-
-    aParam->GetCdmaBaseStationId(&pLong);
-    WriteParam(aMsg, pLong);
-
-    aParam->GetCdmaBaseStationLatitude(&pLong);
-    WriteParam(aMsg, pLong);
-
-    aParam->GetCdmaBaseStationLongitude(&pLong);
-    WriteParam(aMsg, pLong);
-
-    aParam->GetCdmaSystemId(&pLong);
-    WriteParam(aMsg, pLong);
-
-    aParam->GetCdmaNetworkId(&pLong);
-    WriteParam(aMsg, pLong);
-
-    // We release the ref here given that ipdl won't handle reference counting.
-    aParam->Release();
-  }
-
-  // Function to de-serialize a MobileCellInfo.
-  static bool Read(const Message *aMsg, void **aIter, paramType* aResult)
-  {
-    // Check if is the null pointer we have transfered.
-    bool isNull;
-    if (!ReadParam(aMsg, aIter, &isNull)) {
-      return false;
-    }
-
-    if (isNull) {
-      *aResult = nullptr;
-      return true;
-    }
-
-    int32_t gsmLac;
-    int64_t gsmCellId;
-    int32_t cdmaBsId;
-    int32_t cdmaBsLat;
-    int32_t cdmaBsLong;
-    int32_t cdmaSystemId;
-    int32_t cdmaNetworkId;
-
-    // It's not important to us where it fails, but rather if it fails
-    if (!(ReadParam(aMsg, aIter, &gsmLac) &&
-          ReadParam(aMsg, aIter, &gsmCellId) &&
-          ReadParam(aMsg, aIter, &cdmaBsId) &&
-          ReadParam(aMsg, aIter, &cdmaBsLat) &&
-          ReadParam(aMsg, aIter, &cdmaBsLong) &&
-          ReadParam(aMsg, aIter, &cdmaSystemId) &&
-          ReadParam(aMsg, aIter, &cdmaNetworkId))) {
-      return false;
-    }
-
-    *aResult = new MobileCellInfo(gsmLac, gsmCellId, cdmaBsId, cdmaBsLat,
-                                  cdmaBsLong, cdmaSystemId, cdmaNetworkId);
-    // We release this ref after receiver finishes processing.
-    NS_ADDREF(*aResult);
-
-    return true;
-  }
-};
-
-/**
- * nsIMobileConnectionInfo Serialize/De-serialize.
- */
-template <>
-struct ParamTraits<nsIMobileConnectionInfo*>
-{
-  typedef nsIMobileConnectionInfo* paramType;
-
-  // Function to serialize a MobileConnectionInfo.
-  static void Write(Message *aMsg, const paramType& aParam)
-  {
-    bool isNull = !aParam;
-    WriteParam(aMsg, isNull);
-    // If it is a null object, then we are done.
-    if (isNull) {
-      return;
-    }
-
-    AutoSafeJSContext cx;
-    nsString pString;
-    bool pBool;
-    nsCOMPtr<nsIMobileNetworkInfo> pNetworkInfo;
-    nsCOMPtr<nsIMobileCellInfo> pCellInfo;
-    JS::Rooted<JS::Value> pJsval(cx);
-    int32_t pInt32;
-
-    aParam->GetState(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetConnected(&pBool);
-    WriteParam(aMsg, pBool);
-
-    aParam->GetEmergencyCallsOnly(&pBool);
-    WriteParam(aMsg, pBool);
-
-    aParam->GetRoaming(&pBool);
-    WriteParam(aMsg, pBool);
-
-    aParam->GetType(pString);
-    WriteParam(aMsg, pString);
-
-    aParam->GetNetwork(getter_AddRefs(pNetworkInfo));
-    // Release ref when WriteParam is finished.
-    WriteParam(aMsg, pNetworkInfo.forget().take());
-
-    aParam->GetCell(getter_AddRefs(pCellInfo));
-    // Release ref when WriteParam is finished.
-    WriteParam(aMsg, pCellInfo.forget().take());
-
-    // Serialize jsval signalStrength
-    aParam->GetSignalStrength(&pJsval);
-    isNull = !pJsval.isInt32();
-    WriteParam(aMsg, isNull);
-
-    if (!isNull) {
-      pInt32 = pJsval.toInt32();
-      WriteParam(aMsg, pInt32);
-    }
-
-    // Serialize jsval relSignalStrength
-    aParam->GetRelSignalStrength(&pJsval);
-    isNull = !pJsval.isInt32();
-    WriteParam(aMsg, isNull);
-
-    if (!isNull) {
-      pInt32 = pJsval.toInt32();
-      WriteParam(aMsg, pInt32);
-    }
-
-    // We release the ref here given that ipdl won't handle reference counting.
-    aParam->Release();
-  }
-
-  // Function to de-serialize a MobileConectionInfo.
-  static bool Read(const Message* aMsg, void **aIter, paramType* aResult)
-  {
-    // Check if is the null pointer we have transfered.
-    bool isNull;
-    if (!ReadParam(aMsg, aIter, &isNull)) {
-      return false;
-    }
-
-    if (isNull) {
-      *aResult = nullptr;
-      return true;
-    }
-
-    AutoSafeJSContext cx;
-    nsString state;
-    bool connected;
-    bool emergencyOnly;
-    bool roaming;
-    nsString type;
-    nsIMobileNetworkInfo* networkInfo = nullptr;
-    nsIMobileCellInfo* cellInfo = nullptr;
-    Nullable<int32_t> signalStrength;
-    Nullable<uint16_t> relSignalStrength;
-
-    // It's not important to us where it fails, but rather if it fails
-    if (!(ReadParam(aMsg, aIter, &state) &&
-          ReadParam(aMsg, aIter, &connected) &&
-          ReadParam(aMsg, aIter, &emergencyOnly) &&
-          ReadParam(aMsg, aIter, &roaming) &&
-          ReadParam(aMsg, aIter, &type) &&
-          ReadParam(aMsg, aIter, &networkInfo) &&
-          ReadParam(aMsg, aIter, &cellInfo))) {
-      return false;
-    }
-
-    // De-serialize jsval signalStrength
-    if (!ReadParam(aMsg, aIter, &isNull)) {
-      return false;
-    }
-
-    if (!isNull) {
-      int32_t value;
-
-      if (!ReadParam(aMsg, aIter, &value)) {
-        return false;
-      }
-
-      signalStrength.SetValue(value);
-    }
-
-    // De-serialize jsval relSignalStrength
-    if (!ReadParam(aMsg, aIter, &isNull)) {
-      return false;
-    }
-
-    if (!isNull) {
-      int32_t value;
-
-      if (!ReadParam(aMsg, aIter, &value)) {
-        return false;
-      }
-
-      relSignalStrength.SetValue(uint16_t(value));
-    }
-
-    *aResult = new MobileConnectionInfo(state,
-                                        connected,
-                                        emergencyOnly,
-                                        roaming,
-                                        networkInfo,
-                                        type,
-                                        signalStrength,
-                                        relSignalStrength,
-                                        cellInfo);
-    // We release this ref after receiver finishes processing.
-    NS_ADDREF(*aResult);
-    // We already clone the data into MobileConnectionInfo, so release the ref
-    // of networkInfo and cellInfo here.
-    NS_IF_RELEASE(networkInfo);
-    NS_IF_RELEASE(cellInfo);
-
-    return true;
-  }
-};
-
-/**
- * MozCallForwardingOptions Serialize/De-serialize.
- */
-template <>
-struct ParamTraits<MozCallForwardingOptions>
-{
-  typedef MozCallForwardingOptions paramType;
-
-  // Function to serialize a MozCallForwardingOptions.
-  static void Write(Message *aMsg, const paramType& aParam)
-  {
-    bool wasPassed = false;
-    bool isNull = false;
-
-    // Write mActive
-    wasPassed = aParam.mActive.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mActive.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mActive.Value().Value());
-      }
-    }
-
-    // Write mAction
-    wasPassed = aParam.mAction.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mAction.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mAction.Value().Value());
-      }
-    }
-
-    // Write mReason
-    wasPassed = aParam.mReason.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mReason.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mReason.Value().Value());
-      }
-    }
-
-    // Write mNumber
-    wasPassed = aParam.mNumber.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      WriteParam(aMsg, aParam.mNumber.Value());
-    }
-
-    // Write mTimeSeconds
-    wasPassed = aParam.mTimeSeconds.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mTimeSeconds.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mTimeSeconds.Value().Value());
-      }
-    }
-
-    // Write mServiceClass
-    wasPassed = aParam.mServiceClass.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mServiceClass.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mServiceClass.Value().Value());
-      }
-    }
-  }
-
-  // Function to de-serialize a MozCallForwardingOptions.
-  static bool Read(const Message *aMsg, void **aIter, paramType* aResult)
-  {
-    bool wasPassed = false;
-    bool isNull = false;
-
-    // Read mActive
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mActive.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mActive.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mAction
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mAction.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mAction.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mReason
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mReason.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mReason.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mNumber
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      if (!ReadParam(aMsg, aIter, &aResult->mNumber.Construct())) {
-        return false;
-      }
-    }
-
-    // Read mTimeSeconds
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mTimeSeconds.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mTimeSeconds.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mServiceClass
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mServiceClass.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mServiceClass.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    return true;
-  }
-};
-
-/**
- * MozCallBarringOptions Serialize/De-serialize.
- */
-template <>
-struct ParamTraits<MozCallBarringOptions>
-{
-  typedef MozCallBarringOptions paramType;
-
-  // Function to serialize a MozCallBarringOptions.
-  static void Write(Message *aMsg, const paramType& aParam)
-  {
-    bool wasPassed = false;
-    bool isNull = false;
-
-    // Write mProgram
-    wasPassed = aParam.mProgram.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mProgram.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mProgram.Value().Value());
-      }
-    }
-
-    // Write mEnabled
-    wasPassed = aParam.mEnabled.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mEnabled.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mEnabled.Value().Value());
-      }
-    }
-
-    // Write mPassword
-    wasPassed = aParam.mPassword.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      WriteParam(aMsg, aParam.mPassword.Value());
-    }
-
-    // Write mServiceClass
-    wasPassed = aParam.mServiceClass.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      isNull = aParam.mServiceClass.Value().IsNull();
-      WriteParam(aMsg, isNull);
-      if (!isNull) {
-        WriteParam(aMsg, aParam.mServiceClass.Value().Value());
-      }
-    }
-
-    // Write mPin
-    wasPassed = aParam.mPin.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      WriteParam(aMsg, aParam.mPin.Value());
-    }
-
-    // Write mNewPin
-    wasPassed = aParam.mNewPin.WasPassed();
-    WriteParam(aMsg, wasPassed);
-    if (wasPassed) {
-      WriteParam(aMsg, aParam.mNewPin.Value());
-    }
-  }
-
-  // Function to de-serialize a MozCallBarringOptions.
-  static bool Read(const Message *aMsg, void **aIter, paramType* aResult)
-  {
-    bool wasPassed = false;
-    bool isNull = false;
-
-    // Read mProgram
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mProgram.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mProgram.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mEnabled
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mEnabled.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mEnabled.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mPassword
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      if (!ReadParam(aMsg, aIter, &aResult->mPassword.Construct())) {
-        return false;
-      }
-    }
-
-    // Read mServiceClass
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      aResult->mServiceClass.Construct();
-      if (!ReadParam(aMsg, aIter, &isNull)) {
-        return false;
-      }
-
-      if (!isNull) {
-        if (!ReadParam(aMsg, aIter, &aResult->mServiceClass.Value().SetValue())) {
-          return false;
-        }
-      }
-    }
-
-    // Read mPin
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      if (!ReadParam(aMsg, aIter, &aResult->mPin.Construct())) {
-        return false;
-      }
-    }
-
-    // Read mNewPin
-    if (!ReadParam(aMsg, aIter, &wasPassed)) {
-      return false;
-    }
-    if (wasPassed) {
-      if (!ReadParam(aMsg, aIter, &aResult->mNewPin.Construct())) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-};
-
-} // namespace IPC
-
-#endif // dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionIPCService.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MobileConnectionIPCService.h"
-
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/StaticPtr.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::dom::mobileconnection;
-
-NS_IMPL_ISUPPORTS(MobileConnectionIPCService, nsIMobileConnectionService)
-
-StaticRefPtr<MobileConnectionIPCService> sService;
-
-/* static */MobileConnectionIPCService*
-MobileConnectionIPCService::GetSingleton()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (sService) {
-    return sService;
-  }
-
-  sService = new MobileConnectionIPCService();
-  return sService;
-}
-
-MobileConnectionIPCService::MobileConnectionIPCService()
-{
-  int32_t numRil = Preferences::GetInt("ril.numRadioInterfaces", 1);
-  for (int32_t i = 0; i < numRil; i++) {
-    // Deallocated in ContentChild::DeallocPMobileConnectionChild().
-    nsRefPtr<MobileConnectionChild> client = new MobileConnectionChild();
-    NS_ASSERTION(client, "This shouldn't fail!");
-
-    ContentChild::GetSingleton()->SendPMobileConnectionConstructor(client, i);
-    client->Init();
-
-    mClients.AppendElement(client);
-  }
-}
-
-MobileConnectionIPCService::~MobileConnectionIPCService()
-{
-  uint32_t count = mClients.Length();
-  for (uint32_t i = 0; i < count; i++) {
-    mClients[i]->Shutdown();
-  }
-
-  mClients.Clear();
-}
-
-nsresult
-MobileConnectionIPCService::SendRequest(uint32_t aClientId,
-                                        MobileConnectionRequest aRequest,
-                                        nsIMobileConnectionCallback* aRequestCallback)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->SendRequest(aRequest, aRequestCallback);
-  return NS_OK;
-}
-
-// nsIMobileConnectionService
-
-NS_IMETHODIMP
-MobileConnectionIPCService::RegisterListener(uint32_t aClientId,
-                                             nsIMobileConnectionListener* aListener)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->RegisterListener(aListener);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::UnregisterListener(uint32_t aClientId,
-                                               nsIMobileConnectionListener* aListener)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->UnregisterListener(aListener);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetLastKnownNetwork(uint32_t aClientId,
-                                                nsAString& aLastNetwork)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->GetLastNetwork(aLastNetwork);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetLastKnownHomeNetwork(uint32_t aClientId,
-                                                    nsAString& aLastNetwork)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->GetLastHomeNetwork(aLastNetwork);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetVoiceConnectionInfo(uint32_t aClientId,
-                                                   nsIMobileConnectionInfo** aInfo)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetVoiceInfo();
-  info.forget(aInfo);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetDataConnectionInfo(uint32_t aClientId,
-                                                  nsIMobileConnectionInfo** aInfo)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetDataInfo();
-  info.forget(aInfo);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetIccId(uint32_t aClientId, nsAString& aIccId)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->GetIccId(aIccId);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetNetworkSelectionMode(uint32_t aClientId,
-                                                    nsAString& aNetworkSelectionMode)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->GetNetworkSelectionMode(aNetworkSelectionMode);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetRadioState(uint32_t aClientId,
-                                          nsAString& aRadioState)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mClients[aClientId]->GetRadioState(aRadioState);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetSupportedNetworkTypes(uint32_t aClientId,
-                                                     nsIVariant** aSupportedTypes)
-{
-  if (aClientId >= mClients.Length()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsIVariant> supportedTypes = mClients[aClientId]->GetSupportedNetworkTypes();
-  supportedTypes.forget(aSupportedTypes);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetNetworks(uint32_t aClientId,
-                                        nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetNetworksRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SelectNetwork(uint32_t aClientId,
-                                          nsIMobileNetworkInfo* aNetwork,
-                                          nsIMobileConnectionCallback* aRequest)
-{
-  nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
-  // We release the ref after serializing process is finished in
-  // MobileConnectionIPCSerializer.
-  return SendRequest(aClientId, SelectNetworkRequest(network.forget().take()), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SelectNetworkAutomatically(uint32_t aClientId,
-                                                       nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SelectNetworkAutoRequest(), aRequest);
-}
-
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetPreferredNetworkType(uint32_t aClientId,
-                                                    const nsAString& aType,
-                                                    nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId,
-                     SetPreferredNetworkTypeRequest(nsAutoString(aType)),
-                     aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetPreferredNetworkType(uint32_t aClientId,
-                                                    nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetPreferredNetworkTypeRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetRoamingPreference(uint32_t aClientId,
-                                                 const nsAString& aMode,
-                                                 nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId,
-                     SetRoamingPreferenceRequest(nsAutoString(aMode)),
-                     aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetRoamingPreference(uint32_t aClientId,
-                                                 nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetRoamingPreferenceRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetVoicePrivacyMode(uint32_t aClientId,
-                                                bool aEnabled,
-                                                nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SetVoicePrivacyModeRequest(aEnabled), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetVoicePrivacyMode(uint32_t aClientId,
-                                                nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetVoicePrivacyModeRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SendMMI(uint32_t aClientId,
-                                    const nsAString& aMmi,
-                                    nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SendMmiRequest(nsAutoString(aMmi)), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::CancelMMI(uint32_t aClientId,
-                                      nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, CancelMmiRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetCallForwarding(uint32_t aClientId,
-                                              JS::Handle<JS::Value> aOptions,
-                                              nsIMobileConnectionCallback* aRequest)
-{
-  AutoSafeJSContext cx;
-  IPC::MozCallForwardingOptions options;
-  if(!options.Init(cx, aOptions)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return SendRequest(aClientId, SetCallForwardingRequest(options), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetCallForwarding(uint32_t aClientId,
-                                              uint16_t aReason,
-                                              nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetCallForwardingRequest(aReason), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetCallBarring(uint32_t aClientId,
-                                           JS::Handle<JS::Value> aOptions,
-                                           nsIMobileConnectionCallback* aRequest)
-{
-  AutoSafeJSContext cx;
-  IPC::MozCallBarringOptions options;
-  if(!options.Init(cx, aOptions)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return SendRequest(aClientId, SetCallBarringRequest(options), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetCallBarring(uint32_t aClientId,
-                                           JS::Handle<JS::Value> aOptions,
-                                           nsIMobileConnectionCallback* aRequest)
-{
-  AutoSafeJSContext cx;
-  IPC::MozCallBarringOptions options;
-  if(!options.Init(cx, aOptions)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return SendRequest(aClientId, GetCallBarringRequest(options), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::ChangeCallBarringPassword(uint32_t aClientId,
-                                                      JS::Handle<JS::Value> aOptions,
-                                                      nsIMobileConnectionCallback* aRequest)
-{
-  AutoSafeJSContext cx;
-  IPC::MozCallBarringOptions options;
-  if(!options.Init(cx, aOptions)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  return SendRequest(aClientId, ChangeCallBarringPasswordRequest(options), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetCallWaiting(uint32_t aClientId,
-                                           bool aEnabled,
-                                           nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SetCallWaitingRequest(aEnabled), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetCallWaiting(uint32_t aClientId,
-                                           nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetCallWaitingRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetCallingLineIdRestriction(uint32_t aClientId,
-                                                        uint16_t aMode,
-                                                        nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SetCallingLineIdRestrictionRequest(aMode), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::GetCallingLineIdRestriction(uint32_t aClientId,
-                                                        nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, GetCallingLineIdRestrictionRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::ExitEmergencyCbMode(uint32_t aClientId,
-                                                nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, ExitEmergencyCbModeRequest(), aRequest);
-}
-
-NS_IMETHODIMP
-MobileConnectionIPCService::SetRadioEnabled(uint32_t aClientId,
-                                            bool aEnabled,
-                                            nsIMobileConnectionCallback* aRequest)
-{
-  return SendRequest(aClientId, SetRadioEnabledRequest(aEnabled), aRequest);
-}
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionIPCService.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_mobileconnection_MobileConnectionIPCService_h
-#define mozilla_dom_mobileconnection_MobileConnectionIPCService_h
-
-#include "nsCOMPtr.h"
-#include "MobileConnectionChild.h"
-#include "nsIMobileConnectionService.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobileconnection {
-
-class MobileConnectionIPCService MOZ_FINAL : public nsIMobileConnectionService
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILECONNECTIONSERVICE
-
-  static MobileConnectionIPCService*
-  GetSingleton();
-
-private:
-  MobileConnectionIPCService();
-
-  ~MobileConnectionIPCService();
-
-  /** Send request */
-  nsresult
-  SendRequest(uint32_t aClientId, MobileConnectionRequest aRequest,
-              nsIMobileConnectionCallback* aRequestCallback);
-
-  nsTArray<nsRefPtr<MobileConnectionChild>> mClients;
-};
-
-} // name space mobileconnection
-} // name space dom
-} // name space mozilla
-
-#endif // mozilla_dom_mobileconnection_MobileConnectionIPCService_h
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionParent.cpp
+++ /dev/null
@@ -1,729 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MobileConnectionParent.h"
-
-#include "mozilla/AppProcessChecker.h"
-#include "mozilla/dom/BindingUtils.h"
-#include "mozilla/dom/MobileConnectionIPCSerializer.h"
-#include "mozilla/dom/MozMobileConnectionBinding.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "nsIVariant.h"
-#include "nsJSUtils.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::dom::mobileconnection;
-
-MobileConnectionParent::MobileConnectionParent(uint32_t aClientId)
-  : mClientId(aClientId)
-  , mLive(true)
-{
-  MOZ_COUNT_CTOR(MobileConnectionParent);
-
-  mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-  NS_ASSERTION(mService, "This shouldn't fail!");
-
-  if (mService) {
-    mService->RegisterListener(mClientId, this);
-  }
-}
-
-void
-MobileConnectionParent::ActorDestroy(ActorDestroyReason why)
-{
-  mLive = false;
-  if (mService) {
-    mService->UnregisterListener(mClientId, this);
-    mService = nullptr;
-  }
-}
-
-bool
-MobileConnectionParent::RecvPMobileConnectionRequestConstructor(PMobileConnectionRequestParent* aActor,
-                                                                const MobileConnectionRequest& aRequest)
-{
-  MobileConnectionRequestParent* actor = static_cast<MobileConnectionRequestParent*>(aActor);
-
-  switch (aRequest.type()) {
-    case MobileConnectionRequest::TGetNetworksRequest:
-      return actor->DoRequest(aRequest.get_GetNetworksRequest());
-    case MobileConnectionRequest::TSelectNetworkRequest:
-      return actor->DoRequest(aRequest.get_SelectNetworkRequest());
-    case MobileConnectionRequest::TSelectNetworkAutoRequest:
-      return actor->DoRequest(aRequest.get_SelectNetworkAutoRequest());
-    case MobileConnectionRequest::TSetPreferredNetworkTypeRequest:
-      return actor->DoRequest(aRequest.get_SetPreferredNetworkTypeRequest());
-    case MobileConnectionRequest::TGetPreferredNetworkTypeRequest:
-      return actor->DoRequest(aRequest.get_GetPreferredNetworkTypeRequest());
-    case MobileConnectionRequest::TSetRoamingPreferenceRequest:
-      return actor->DoRequest(aRequest.get_SetRoamingPreferenceRequest());
-    case MobileConnectionRequest::TGetRoamingPreferenceRequest:
-      return actor->DoRequest(aRequest.get_GetRoamingPreferenceRequest());
-    case MobileConnectionRequest::TSetVoicePrivacyModeRequest:
-      return actor->DoRequest(aRequest.get_SetVoicePrivacyModeRequest());
-    case MobileConnectionRequest::TGetVoicePrivacyModeRequest:
-      return actor->DoRequest(aRequest.get_GetVoicePrivacyModeRequest());
-    case MobileConnectionRequest::TSendMmiRequest:
-      return actor->DoRequest(aRequest.get_SendMmiRequest());
-    case MobileConnectionRequest::TCancelMmiRequest:
-      return actor->DoRequest(aRequest.get_CancelMmiRequest());
-    case MobileConnectionRequest::TSetCallForwardingRequest:
-      return actor->DoRequest(aRequest.get_SetCallForwardingRequest());
-    case MobileConnectionRequest::TGetCallForwardingRequest:
-      return actor->DoRequest(aRequest.get_GetCallForwardingRequest());
-    case MobileConnectionRequest::TSetCallBarringRequest:
-      return actor->DoRequest(aRequest.get_SetCallBarringRequest());
-    case MobileConnectionRequest::TGetCallBarringRequest:
-      return actor->DoRequest(aRequest.get_GetCallBarringRequest());
-    case MobileConnectionRequest::TChangeCallBarringPasswordRequest:
-      return actor->DoRequest(aRequest.get_ChangeCallBarringPasswordRequest());
-    case MobileConnectionRequest::TSetCallWaitingRequest:
-      return actor->DoRequest(aRequest.get_SetCallWaitingRequest());
-    case MobileConnectionRequest::TGetCallWaitingRequest:
-      return actor->DoRequest(aRequest.get_GetCallWaitingRequest());
-    case MobileConnectionRequest::TSetCallingLineIdRestrictionRequest:
-      return actor->DoRequest(aRequest.get_SetCallingLineIdRestrictionRequest());
-    case MobileConnectionRequest::TGetCallingLineIdRestrictionRequest:
-      return actor->DoRequest(aRequest.get_GetCallingLineIdRestrictionRequest());
-    case MobileConnectionRequest::TExitEmergencyCbModeRequest:
-      return actor->DoRequest(aRequest.get_ExitEmergencyCbModeRequest());
-    case MobileConnectionRequest::TSetRadioEnabledRequest:
-      return actor->DoRequest(aRequest.get_SetRadioEnabledRequest());
-    default:
-      MOZ_CRASH("Received invalid request type!");
-  }
-
-  return false;
-}
-
-PMobileConnectionRequestParent*
-MobileConnectionParent::AllocPMobileConnectionRequestParent(const MobileConnectionRequest& request)
-{
-  if (!AssertAppProcessPermission(Manager(), "mobileconnection")) {
-    return nullptr;
-  }
-
-  MobileConnectionRequestParent* actor = new MobileConnectionRequestParent(mClientId);
-  // Add an extra ref for IPDL. Will be released in
-  // MobileConnectionParent::DeallocPMobileConnectionRequestParent().
-  actor->AddRef();
-  return actor;
-}
-
-bool
-MobileConnectionParent::DeallocPMobileConnectionRequestParent(PMobileConnectionRequestParent* aActor)
-{
-  // MobileConnectionRequestParent is refcounted, must not be freed manually.
-  static_cast<MobileConnectionRequestParent*>(aActor)->Release();
-  return true;
-}
-
-bool
-MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
-                                 nsMobileConnectionInfo* aData,
-                                 nsString* aLastKnownNetwork,
-                                 nsString* aLastKnownHomeNetwork,
-                                 nsString* aIccId,
-                                 nsString* aNetworkSelectionMode,
-                                 nsString* aRadioState,
-                                 nsTArray<nsString>* aSupportedNetworkTypes)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  NS_ENSURE_SUCCESS(mService->GetVoiceConnectionInfo(mClientId, aVoice), false);
-  NS_ENSURE_SUCCESS(mService->GetDataConnectionInfo(mClientId, aData), false);
-  NS_ENSURE_SUCCESS(mService->GetLastKnownNetwork(mClientId, *aLastKnownNetwork), false);
-  NS_ENSURE_SUCCESS(mService->GetLastKnownHomeNetwork(mClientId, *aLastKnownHomeNetwork), false);
-  NS_ENSURE_SUCCESS(mService->GetIccId(mClientId, *aIccId), false);
-  NS_ENSURE_SUCCESS(mService->GetNetworkSelectionMode(mClientId, *aNetworkSelectionMode), false);
-  NS_ENSURE_SUCCESS(mService->GetRadioState(mClientId, *aRadioState), false);
-
-  nsCOMPtr<nsIVariant> variant;
-  mService->GetSupportedNetworkTypes(mClientId, getter_AddRefs(variant));
-
-  uint16_t type;
-  nsIID iid;
-  uint32_t count;
-  void* data;
-  if (NS_FAILED(variant->GetAsArray(&type, &iid, &count, &data))) {
-    return false;
-  }
-
-  // We expect the element type is wstring.
-  if (type == nsIDataType::VTYPE_WCHAR_STR) {
-    char16_t** rawArray = reinterpret_cast<char16_t**>(data);
-    for (uint32_t i = 0; i < count; ++i) {
-      nsDependentString networkType(rawArray[i]);
-      aSupportedNetworkTypes->AppendElement(networkType);
-    }
-  }
-  NS_Free(data);
-
-  return true;
-}
-
-// nsIMobileConnectionListener
-
-NS_IMPL_ISUPPORTS(MobileConnectionParent, nsIMobileConnectionListener)
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyVoiceChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsCOMPtr<nsIMobileConnectionInfo> info;
-  rv = mService->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // We release the ref after serializing process is finished in
-  // MobileConnectionIPCSerializer.
-  return SendNotifyVoiceInfoChanged(info.forget().take()) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyDataChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsCOMPtr<nsIMobileConnectionInfo> info;
-  rv = mService->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // We release the ref after serializing process is finished in
-  // MobileConnectionIPCSerializer.
-  return SendNotifyDataInfoChanged(info.forget().take()) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyUssdReceived(const nsAString& aMessage,
-                                           bool aSessionEnded)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyUssdReceived(nsAutoString(aMessage), aSessionEnded)
-         ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyDataError(const nsAString& aMessage)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyDataError(nsAutoString(aMessage)) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyCFStateChanged(bool aSuccess,
-                                             uint16_t aAction,
-                                             uint16_t aReason,
-                                             const nsAString &aNumber,
-                                             uint16_t aTimeSeconds,
-                                             uint16_t aServiceClass)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyCFStateChanged(aSuccess, aAction, aReason,
-                                  nsAutoString(aNumber), aTimeSeconds,
-                                  aServiceClass) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyEmergencyCbModeChanged(bool aActive,
-                                                     uint32_t aTimeoutMs)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyEmergencyCbModeChanged(aActive, aTimeoutMs)
-         ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyOtaStatusChanged(const nsAString& aStatus)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyOtaStatusChanged(nsAutoString(aStatus))
-         ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyIccChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsAutoString iccId;
-  mService->GetIccId(mClientId, iccId);
-
-  return SendNotifyIccChanged(iccId) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyRadioStateChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsAutoString radioState;
-  rv = mService->GetRadioState(mClientId, radioState);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return SendNotifyRadioStateChanged(radioState) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyClirModeChanged(uint32_t aMode)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return SendNotifyClirModeChanged(aMode) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyLastKnownNetworkChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsAutoString network;
-  rv = mService->GetLastKnownNetwork(mClientId, network);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return SendNotifyLastNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyLastKnownHomeNetworkChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsAutoString network;
-  rv = mService->GetLastKnownHomeNetwork(mClientId, network);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return SendNotifyLastHomeNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
-MobileConnectionParent::NotifyNetworkSelectionModeChanged()
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  nsresult rv;
-  nsAutoString mode;
-  rv = mService->GetNetworkSelectionMode(mClientId, mode);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-/******************************************************************************
- * PMobileConnectionRequestParent
- ******************************************************************************/
-
-void
-MobileConnectionRequestParent::ActorDestroy(ActorDestroyReason why)
-{
-  mLive = false;
-  mService = nullptr;
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetNetworksRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetNetworks(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SelectNetworkRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  // Use dont_AddRef here because this instances is already AddRef-ed in
-  // MobileConnectionIPCSerializer.h
-  nsCOMPtr<nsIMobileNetworkInfo> network = dont_AddRef(aRequest.network());
-  return NS_SUCCEEDED(mService->SelectNetwork(mClientId, network, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SelectNetworkAutoRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SelectNetworkAutomatically(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetPreferredNetworkTypeRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetPreferredNetworkType(mClientId, aRequest.type(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetPreferredNetworkTypeRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetPreferredNetworkType(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetRoamingPreferenceRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetRoamingPreference(mClientId, aRequest.mode(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetRoamingPreferenceRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetRoamingPreference(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetVoicePrivacyModeRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetVoicePrivacyMode(mClientId, aRequest.enabled(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetVoicePrivacyModeRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetVoicePrivacyMode(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SendMmiRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SendMMI(mClientId, aRequest.mmi(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const CancelMmiRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->CancelMMI(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetCallForwardingRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  AutoSafeJSContext cx;
-  JS::Rooted<JS::Value> options(cx);
-  if (!ToJSValue(cx, aRequest.options(), &options)) {
-    JS_ClearPendingException(cx);
-    return false;
-  }
-
-  return NS_SUCCEEDED(mService->SetCallForwarding(mClientId, options, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetCallForwardingRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetCallForwarding(mClientId, aRequest.reason(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetCallBarringRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  AutoSafeJSContext cx;
-  JS::Rooted<JS::Value> options(cx);
-  if (!ToJSValue(cx, aRequest.options(), &options)) {
-    JS_ClearPendingException(cx);
-    return false;
-  }
-
-  return NS_SUCCEEDED(mService->SetCallBarring(mClientId, options, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetCallBarringRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  AutoSafeJSContext cx;
-  JS::Rooted<JS::Value> options(cx);
-  if (!ToJSValue(cx, aRequest.options(), &options)) {
-    JS_ClearPendingException(cx);
-    return false;
-  }
-
-  return NS_SUCCEEDED(mService->GetCallBarring(mClientId, options, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const ChangeCallBarringPasswordRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  AutoSafeJSContext cx;
-  JS::Rooted<JS::Value> options(cx);
-  if (!ToJSValue(cx, aRequest.options(), &options)) {
-    JS_ClearPendingException(cx);
-    return false;
-  }
-
-  return NS_SUCCEEDED(mService->ChangeCallBarringPassword(mClientId, options, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetCallWaitingRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetCallWaiting(mClientId, aRequest.enabled(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetCallWaitingRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetCallWaiting(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetCallingLineIdRestrictionRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetCallingLineIdRestriction(mClientId, aRequest.mode(), this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const GetCallingLineIdRestrictionRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->GetCallingLineIdRestriction(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const ExitEmergencyCbModeRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->ExitEmergencyCbMode(mClientId, this));
-}
-
-bool
-MobileConnectionRequestParent::DoRequest(const SetRadioEnabledRequest& aRequest)
-{
-  NS_ENSURE_TRUE(mService, false);
-
-  return NS_SUCCEEDED(mService->SetRadioEnabled(mClientId, aRequest.enabled(), this));
-}
-
-nsresult
-MobileConnectionRequestParent::SendReply(const MobileConnectionReply& aReply)
-{
-  NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
-
-  return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
-}
-
-// nsIMobileConnectionListener
-
-NS_IMPL_ISUPPORTS(MobileConnectionRequestParent, nsIMobileConnectionCallback);
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifySuccess()
-{
-  return SendReply(MobileConnectionReplySuccess());
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifySuccessWithString(const nsAString& aResult)
-{
-  return SendReply(MobileConnectionReplySuccessString(nsAutoString(aResult)));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifySuccessWithBoolean(bool aResult)
-{
-  return SendReply(MobileConnectionReplySuccessBoolean(aResult));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifyGetNetworksSuccess(uint32_t aCount,
-                                                        nsIMobileNetworkInfo** aNetworks)
-{
-  nsTArray<nsIMobileNetworkInfo*> networks;
-  for (uint32_t i = 0; i < aCount; i++) {
-    nsCOMPtr<nsIMobileNetworkInfo> network = aNetworks[i];
-    // We release the ref after serializing process is finished in
-    // MobileConnectionIPCSerializer.
-    networks.AppendElement(network.forget().take());
-  }
-  return SendReply(MobileConnectionReplySuccessNetworks(networks));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifySendCancelMmiSuccess(JS::Handle<JS::Value> aResult)
-{
-  AutoSafeJSContext cx;
-  RootedDictionary<MozMMIResult> result(cx);
-
-  if (!result.Init(cx, aResult)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  // No additionInformation passed
-  if (!result.mAdditionalInformation.WasPassed()) {
-    return SendReply(MobileConnectionReplySuccessMmi(result.mServiceCode,
-                                                     result.mStatusMessage,
-                                                     AdditionalInformation(mozilla::void_t())));
-  }
-
-  OwningUnsignedShortOrObject& additionInformation = result.mAdditionalInformation.Value();
-
-  if (additionInformation.IsUnsignedShort()) {
-    return SendReply(MobileConnectionReplySuccessMmi(result.mServiceCode,
-                                                     result.mStatusMessage,
-                                                     AdditionalInformation(uint16_t(additionInformation.GetAsUnsignedShort()))));
-  }
-
-  if (additionInformation.IsObject()) {
-    uint32_t length;
-    JS::Rooted<JS::Value> value(cx);
-    JS::Rooted<JSObject*> object(cx, additionInformation.GetAsObject());
-
-    if (!JS_IsArrayObject(cx, object) ||
-        !JS_GetArrayLength(cx, object, &length) || length <= 0 ||
-        // Check first element to decide the format of array.
-        !JS_GetElement(cx, object, 0, &value)) {
-      return NS_ERROR_TYPE_ERR;
-    }
-
-    // Check first element to decide the format of array.
-    if (value.isString()) {
-      // String[]
-      nsTArray<nsString> infos;
-      for (uint32_t i = 0; i < length; i++) {
-        if (!JS_GetElement(cx, object, i, &value) || !value.isString()) {
-          return NS_ERROR_TYPE_ERR;
-        }
-
-        nsAutoJSString str;
-        if (!str.init(cx, value.toString())) {
-          return NS_ERROR_FAILURE;
-        }
-        infos.AppendElement(str);
-      }
-
-      return SendReply(MobileConnectionReplySuccessMmi(result.mServiceCode,
-                                                       result.mStatusMessage,
-                                                       AdditionalInformation(infos)));
-    } else {
-      // IPC::MozCallForwardingOptions[]
-      nsTArray<IPC::MozCallForwardingOptions> infos;
-      for (uint32_t i = 0; i < length; i++) {
-        IPC::MozCallForwardingOptions info;
-        if (!JS_GetElement(cx, object, i, &value) || !info.Init(cx, value)) {
-          return NS_ERROR_TYPE_ERR;
-        }
-
-        infos.AppendElement(info);
-      }
-
-      return SendReply(MobileConnectionReplySuccessMmi(result.mServiceCode,
-                                                       result.mStatusMessage,
-                                                       AdditionalInformation(infos)));
-    }
-  }
-
-  return NS_ERROR_TYPE_ERR;
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifyGetCallForwardingSuccess(JS::Handle<JS::Value> aResults)
-{
-  uint32_t length;
-  AutoSafeJSContext cx;
-  JS::Rooted<JSObject*> object(cx, &aResults.toObject());
-  nsTArray<IPC::MozCallForwardingOptions> results;
-
-  if (!JS_IsArrayObject(cx, object) ||
-      !JS_GetArrayLength(cx, object, &length)) {
-    return NS_ERROR_TYPE_ERR;
-  }
-
-  for (uint32_t i = 0; i < length; i++) {
-    JS::Rooted<JS::Value> entry(cx);
-    IPC::MozCallForwardingOptions info;
-
-    if (!JS_GetElement(cx, object, i, &entry) || !info.Init(cx, entry)) {
-      return NS_ERROR_TYPE_ERR;
-    }
-
-    results.AppendElement(info);
-  }
-
-  return SendReply(MobileConnectionReplySuccessCallForwarding(results));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifyGetCallBarringSuccess(uint16_t aProgram,
-                                                           bool aEnabled,
-                                                           uint16_t aServiceClass)
-{
-  return SendReply(MobileConnectionReplySuccessCallBarring(aProgram, aEnabled,
-                                                           aServiceClass));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifyGetClirStatusSuccess(uint16_t aN,
-                                                          uint16_t aM)
-{
-  return SendReply(MobileConnectionReplySuccessClirStatus(aN, aM));
-}
-
-NS_IMETHODIMP
-MobileConnectionRequestParent::NotifyError(const nsAString& aName,
-                                           const nsAString& aMessage,
-                                           const nsAString& aServiceCode,
-                                           uint16_t aInfo,
-                                           uint8_t aArgc)
-{
-  if (aArgc == 0) {
-    nsAutoString error(aName);
-    return SendReply(MobileConnectionReplyError(error));
-  }
-
-  nsAutoString name(aName);
-  nsAutoString message(aMessage);
-  nsAutoString serviceCode(aServiceCode);
-
-  if (aArgc < 3) {
-    return SendReply(MobileConnectionReplyErrorMmi(name, message, serviceCode,
-                                                   AdditionalInformation(mozilla::void_t())));
-  }
-
-  return SendReply(MobileConnectionReplyErrorMmi(name, message, serviceCode,
-                                                 AdditionalInformation(aInfo)));
-}
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/MobileConnectionParent.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_mobileconnection_MobileConnectionParent_h
-#define mozilla_dom_mobileconnection_MobileConnectionParent_h
-
-#include "mozilla/dom/PMobileConnectionParent.h"
-#include "mozilla/dom/PMobileConnectionRequestParent.h"
-#include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
-#include "nsServiceManagerUtils.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobileconnection {
-
-/**
- * Parent actor of PMobileConnection. This object is created/destroyed along
- * with child actor.
- */
-class MobileConnectionParent : public PMobileConnectionParent
-                             , public nsIMobileConnectionListener
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILECONNECTIONLISTENER
-
-  MobileConnectionParent(uint32_t aClientId);
-
-protected:
-  virtual
-  ~MobileConnectionParent()
-  {
-    MOZ_COUNT_DTOR(MobileConnectionParent);
-  }
-
-  virtual void
-  ActorDestroy(ActorDestroyReason why);
-
-  virtual bool
-  RecvPMobileConnectionRequestConstructor(PMobileConnectionRequestParent* aActor,
-                                          const MobileConnectionRequest& aRequest) MOZ_OVERRIDE;
-
-  virtual PMobileConnectionRequestParent*
-  AllocPMobileConnectionRequestParent(const MobileConnectionRequest& request) MOZ_OVERRIDE;
-
-  virtual bool
-  DeallocPMobileConnectionRequestParent(PMobileConnectionRequestParent* aActor) MOZ_OVERRIDE;
-
-  virtual bool
-  RecvInit(nsMobileConnectionInfo* aVoice, nsMobileConnectionInfo* aData,
-           nsString* aLastKnownNetwork, nsString* aLastKnownHomeNetwork,
-           nsString* aIccId, nsString* aNetworkSelectionMode,
-           nsString* aRadioState, nsTArray<nsString>* aSupportedNetworkTypes) MOZ_OVERRIDE;
-
-private:
-  uint32_t mClientId;
-  bool mLive;
-  nsCOMPtr<nsIMobileConnectionService> mService;
-};
-
-/******************************************************************************
- * PMobileConnectionRequestParent
- ******************************************************************************/
-
-/**
- * Parent actor of PMobileConnectionRequestParent. The object is created along
- * with child actor and destroyed after the callback function of
- * nsIMobileConnectionCallback is called. Child actor might be destroyed before
- * any callback is triggered. So we use mLive to maintain the status of child
- * actor in order to present sending data to a dead one.
- */
-class MobileConnectionRequestParent : public PMobileConnectionRequestParent
-                                    , public nsIMobileConnectionCallback
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILECONNECTIONCALLBACK
-
-  MobileConnectionRequestParent(uint32_t aClientId)
-    : mClientId(aClientId)
-    , mLive(true)
-  {
-    MOZ_COUNT_CTOR(MobileConnectionRequestParent);
-
-    mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-    NS_ASSERTION(mService, "This shouldn't fail!");
-  }
-
-  bool
-  DoRequest(const GetNetworksRequest& aRequest);
-
-  bool
-  DoRequest(const SelectNetworkRequest& aRequest);
-
-  bool
-  DoRequest(const SelectNetworkAutoRequest& aRequest);
-
-  bool
-  DoRequest(const SetPreferredNetworkTypeRequest& aRequest);
-
-  bool
-  DoRequest(const GetPreferredNetworkTypeRequest& aRequest);
-
-  bool
-  DoRequest(const SetRoamingPreferenceRequest& aRequest);
-
-  bool
-  DoRequest(const GetRoamingPreferenceRequest& aRequest);
-
-  bool
-  DoRequest(const SetVoicePrivacyModeRequest& aRequest);
-
-  bool
-  DoRequest(const GetVoicePrivacyModeRequest& aRequest);
-
-  bool
-  DoRequest(const SendMmiRequest& aRequest);
-
-  bool
-  DoRequest(const CancelMmiRequest& aRequest);
-
-  bool
-  DoRequest(const SetCallForwardingRequest& aRequest);
-
-  bool
-  DoRequest(const GetCallForwardingRequest& aRequest);
-
-  bool
-  DoRequest(const SetCallBarringRequest& aRequest);
-
-  bool
-  DoRequest(const GetCallBarringRequest& aRequest);
-
-  bool
-  DoRequest(const ChangeCallBarringPasswordRequest& aRequest);
-
-  bool
-  DoRequest(const SetCallWaitingRequest& aRequest);
-
-  bool
-  DoRequest(const GetCallWaitingRequest& aRequest);
-
-  bool
-  DoRequest(const SetCallingLineIdRestrictionRequest& aRequest);
-
-  bool
-  DoRequest(const GetCallingLineIdRestrictionRequest& aRequest);
-
-  bool
-  DoRequest(const ExitEmergencyCbModeRequest& aRequest);
-
-  bool
-  DoRequest(const SetRadioEnabledRequest& aRequest);
-
-protected:
-  virtual
-  ~MobileConnectionRequestParent()
-  {
-    MOZ_COUNT_DTOR(MobileConnectionRequestParent);
-  }
-
-  virtual void
-  ActorDestroy(ActorDestroyReason why);
-
-  nsresult
-  SendReply(const MobileConnectionReply& aReply);
-
-private:
-  uint32_t mClientId;
-  bool mLive;
-  nsCOMPtr<nsIMobileConnectionService> mService;
-};
-
-} // namespace mobileconnection
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobileconnection_MobileConnectionParent_h
\ No newline at end of file
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/PMobileConnection.ipdl
+++ /dev/null
@@ -1,188 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PContent;
-include protocol PMobileConnectionRequest;
-include PMobileConnectionTypes;
-
-namespace mozilla {
-namespace dom {
-
-sync protocol PMobileConnection
-{
-  manager PContent;
-  manages PMobileConnectionRequest;
-
-child:
-  NotifyVoiceInfoChanged(nsMobileConnectionInfo aInfo);
-  NotifyDataInfoChanged(nsMobileConnectionInfo aInfo);
-  NotifyUssdReceived(nsString aMessage, bool aSessionEnd);
-  NotifyDataError(nsString aMessage);
-  NotifyCFStateChanged(bool aSuccess, uint16_t aAction, uint16_t aReason,
-                       nsString aNumber, uint16_t aTimeSeconds,
-                       uint16_t aServiceClass);
-  NotifyEmergencyCbModeChanged(bool aActive, uint32_t aTimeoutMs);
-  NotifyOtaStatusChanged(nsString aStatus);
-  NotifyIccChanged(nsString aIccId);
-  NotifyRadioStateChanged(nsString aRadioState);
-  NotifyClirModeChanged(uint32_t aMode);
-  NotifyLastNetworkChanged(nsString aNetwork);
-  NotifyLastHomeNetworkChanged(nsString aNetwork);
-  NotifyNetworkSelectionModeChanged(nsString aMode);
-
-parent:
-  /**
-   * Send when child no longer needs to use PMobileConnection.
-   */
-  __delete__();
-
-  /**
-   * Sent when the child makes an asynchronous request to the parent.
-   */
-  PMobileConnectionRequest(MobileConnectionRequest aRequest);
-
-  /**
-   * Sync call only be called once per child actor for initialization.
-   */
-  sync Init()
-    returns (nsMobileConnectionInfo aVoice, nsMobileConnectionInfo aData,
-             nsString aLastKnownNetwork, nsString aLastKnownHomeNetwork,
-             nsString aIccId, nsString aNetworkSelectionMode,
-             nsString aRadioState, nsString[] aSupportedNetworkTypes);
-};
-
-/**
- * MobileConnectionRequest
- */
-struct GetNetworksRequest
-{
-};
-
-struct SelectNetworkRequest
-{
-  nsMobileNetworkInfo network;
-};
-
-struct SelectNetworkAutoRequest
-{
-};
-
-struct SetPreferredNetworkTypeRequest
-{
-  nsString type;
-};
-
-struct GetPreferredNetworkTypeRequest
-{
-};
-
-struct SetRoamingPreferenceRequest
-{
-  nsString mode;
-};
-
-struct GetRoamingPreferenceRequest
-{
-};
-
-struct SetVoicePrivacyModeRequest
-{
-  bool enabled;
-};
-
-struct GetVoicePrivacyModeRequest
-{
-};
-
-struct SendMmiRequest
-{
-  nsString mmi;
-};
-
-struct CancelMmiRequest
-{
-};
-
-struct SetCallForwardingRequest
-{
-  MozCallForwardingOptions options;
-};
-
-struct GetCallForwardingRequest
-{
-  int16_t reason;
-};
-
-struct SetCallBarringRequest
-{
-  MozCallBarringOptions options;
-};
-
-struct GetCallBarringRequest
-{
-  MozCallBarringOptions options;
-};
-
-struct ChangeCallBarringPasswordRequest
-{
-  MozCallBarringOptions options;
-};
-
-struct SetCallWaitingRequest
-{
-  bool enabled;
-};
-
-struct GetCallWaitingRequest
-{
-};
-
-struct SetCallingLineIdRestrictionRequest
-{
-  uint16_t mode;
-};
-
-struct GetCallingLineIdRestrictionRequest
-{
-};
-
-struct ExitEmergencyCbModeRequest
-{
-};
-
-struct SetRadioEnabledRequest
-{
-  bool enabled;
-};
-
-union MobileConnectionRequest
-{
-  GetNetworksRequest;
-  SelectNetworkRequest;
-  SelectNetworkAutoRequest;
-  SetPreferredNetworkTypeRequest;
-  GetPreferredNetworkTypeRequest;
-  SetRoamingPreferenceRequest;
-  GetRoamingPreferenceRequest;
-  SetVoicePrivacyModeRequest;
-  GetVoicePrivacyModeRequest;
-  SendMmiRequest;
-  CancelMmiRequest;
-  SetCallForwardingRequest;
-  GetCallForwardingRequest;
-  SetCallBarringRequest;
-  GetCallBarringRequest;
-  ChangeCallBarringPasswordRequest;
-  SetCallWaitingRequest;
-  GetCallWaitingRequest;
-  SetCallingLineIdRestrictionRequest;
-  GetCallingLineIdRestrictionRequest;
-  ExitEmergencyCbModeRequest;
-  SetRadioEnabledRequest;
-};
-
-} // namespace mozilla
-} // namespace dom
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/PMobileConnectionRequest.ipdl
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PMobileConnection;
-include PMobileConnectionTypes;
-
-namespace mozilla {
-namespace dom {
-
-protocol PMobileConnectionRequest
-{
-  manager PMobileConnection;
-
-child:
-  /**
-   * Send when asynchronous request has completed.
-   */
-  __delete__(MobileConnectionReply aResponse);
-};
-
-/**
- * MobileConnectionReply
- */
-// Success
-struct MobileConnectionReplySuccess
-{
-};
-
-struct MobileConnectionReplySuccessString
-{
-  nsString result;
-};
-
-struct MobileConnectionReplySuccessBoolean
-{
-  bool result;
-};
-
-struct MobileConnectionReplySuccessNetworks
-{
-  nsMobileNetworkInfo[] results;
-};
-
-struct MobileConnectionReplySuccessMmi
-{
-  nsString serviceCode;
-  nsString statusMessage;
-  AdditionalInformation additionalInformation;
-};
-
-struct MobileConnectionReplySuccessCallForwarding
-{
-  MozCallForwardingOptions[] results;
-};
-
-struct MobileConnectionReplySuccessCallBarring
-{
-  uint16_t program;
-  bool enabled;
-  uint16_t serviceClass;
-};
-
-struct MobileConnectionReplySuccessClirStatus
-{
-  uint16_t n;
-  uint16_t m;
-};
-
-// Error
-struct MobileConnectionReplyError
-{
-  nsString message;
-};
-
-struct MobileConnectionReplyErrorMmi
-{
-  nsString name;
-  nsString message;
-  nsString serviceCode;
-  AdditionalInformation additionalInformation;
-};
-
-union MobileConnectionReply
-{
-  // Success
-  MobileConnectionReplySuccess;
-  MobileConnectionReplySuccessString;
-  MobileConnectionReplySuccessBoolean;
-  MobileConnectionReplySuccessNetworks;
-  MobileConnectionReplySuccessMmi;
-  MobileConnectionReplySuccessCallForwarding;
-  MobileConnectionReplySuccessCallBarring;
-  MobileConnectionReplySuccessClirStatus;
-  // Error
-  MobileConnectionReplyError;
-  MobileConnectionReplyErrorMmi;
-};
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobileconnection/src/ipc/PMobileConnectionTypes.ipdlh
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-using nsMobileConnectionInfo from "mozilla/dom/MobileConnectionIPCSerializer.h";
-using nsMobileNetworkInfo from "mozilla/dom/MobileConnectionIPCSerializer.h";
-using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
-using struct IPC::MozCallForwardingOptions from "mozilla/dom/MobileConnectionIPCSerializer.h";
-using struct IPC::MozCallBarringOptions from "mozilla/dom/MobileConnectionIPCSerializer.h";
-
-namespace mozilla {
-namespace dom {
-
-union AdditionalInformation {
-  void_t;
-  uint16_t;
-  nsString[];
-  MozCallForwardingOptions[];
-};
-
-} // namespace dom
-} // namespace mozilla
--- a/dom/mobileconnection/src/moz.build
+++ b/dom/mobileconnection/src/moz.build
@@ -1,53 +1,29 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXPORTS.mozilla.dom += [
     'DOMMMIError.h',
-    'ipc/MobileConnectionIPCSerializer.h',
     'MobileCellInfo.h',
     'MobileConnection.h',
     'MobileConnectionArray.h',
-    'MobileConnectionCallback.h',
     'MobileConnectionInfo.h',
     'MobileNetworkInfo.h',
 ]
 
-EXPORTS.mozilla.dom.mobileconnection += [
-    'ipc/MobileConnectionChild.h',
-    'ipc/MobileConnectionIPCService.h',
-    'ipc/MobileConnectionParent.h',
-]
-
 SOURCES += [
     'DOMMMIError.cpp',
-    'ipc/MobileConnectionChild.cpp',
-    'ipc/MobileConnectionIPCService.cpp',
-    'ipc/MobileConnectionParent.cpp',
     'MobileCellInfo.cpp',
     'MobileConnection.cpp',
     'MobileConnectionArray.cpp',
-    'MobileConnectionCallback.cpp',
     'MobileConnectionInfo.cpp',
     'MobileNetworkInfo.cpp',
 ]
 
-IPDL_SOURCES += [
-    'ipc/PMobileConnection.ipdl',
-    'ipc/PMobileConnectionRequest.ipdl',
-    'ipc/PMobileConnectionTypes.ipdlh',
-]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
-    EXTRA_COMPONENTS += [
-        'gonk/MobileConnectionGonkService.js',
-        'gonk/MobileConnectionGonkService.manifest',
-    ]
-
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/dom/mobilemessage/src/gonk/MmsService.js
+++ b/dom/mobilemessage/src/gonk/MmsService.js
@@ -158,20 +158,16 @@ XPCOMUtils.defineLazyServiceGetter(this,
 XPCOMUtils.defineLazyServiceGetter(this, "gRil",
                                    "@mozilla.org/ril;1",
                                    "nsIRadioInterfaceLayer");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
                                    "@mozilla.org/network/manager;1",
                                    "nsINetworkManager");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
-                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
-                                   "nsIMobileConnectionService");
-
 XPCOMUtils.defineLazyGetter(this, "MMS", function() {
   let MMS = {};
   Cu.import("resource://gre/modules/MmsPduHelper.jsm", MMS);
   return MMS;
 });
 
 // Internal Utilities
 
@@ -323,18 +319,17 @@ MmsConnection.prototype = {
   },
 
   /**
    * Return the roaming status of voice call.
    *
    * @return true if voice call is roaming.
    */
   isVoiceRoaming: function() {
-    let voice = gMobileConnectionService.getVoiceConnectionInfo(this.serviceId);
-    let isRoaming = voice.roaming;
+    let isRoaming = this.radioInterface.rilContext.voice.roaming;
     if (DEBUG) debug("isVoiceRoaming = " + isRoaming);
     return isRoaming;
   },
 
   /**
    * Get phone number from iccInfo.
    *
    * If the icc card is gsm card, the phone number is in msisdn.
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -55,17 +55,16 @@ DIRS += [
     'fetch',
     'filehandle',
     'filesystem',
     'fmradio',
     'asmjscache',
     'mathml',
     'media',
     'messages',
-    'mobileconnection',
     'power',
     'push',
     'quota',
     'settings',
     'mobilemessage',
     'src',
     'time',
     'locales',
@@ -100,16 +99,17 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
         'tethering',
         'wifi',
     ]
 
 if CONFIG['MOZ_B2G_RIL']:
     DIRS += [
         'icc',
         'cellbroadcast',
+        'mobileconnection',
         'voicemail',
         'wappush',
     ]
 
 if CONFIG['MOZ_PAY']:
     DIRS += ['payment']
 
 if CONFIG['MOZ_GAMEPAD']:
--- a/dom/phonenumberutils/PhoneNumberUtils.jsm
+++ b/dom/phonenumberutils/PhoneNumberUtils.jsm
@@ -16,18 +16,18 @@ Cu.import("resource://gre/modules/Servic
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 XPCOMUtils.defineLazyModuleGetter(this, "PhoneNumberNormalizer",
                                   "resource://gre/modules/PhoneNumberNormalizer.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MCC_ISO3166_TABLE",
                                   "resource://gre/modules/mcc_iso3166_table.jsm");
 
 #ifdef MOZ_B2G_RIL
 XPCOMUtils.defineLazyServiceGetter(this, "mobileConnection",
-                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
-                                   "nsIMobileConnectionService");
+                                   "@mozilla.org/ril/content-helper;1",
+                                   "nsIMobileConnectionProvider");
 XPCOMUtils.defineLazyServiceGetter(this, "icc",
                                    "@mozilla.org/ril/content-helper;1",
                                    "nsIIccProvider");
 #endif
 
 this.PhoneNumberUtils = {
   init: function() {
     ppmm.addMessageListener(["PhoneNumberService:FuzzyMatch"], this);
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -31,17 +31,16 @@
 #include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "prtime.h"
 
 #ifdef MOZ_B2G_RIL
 #include "nsIDOMIccInfo.h"
 #include "nsIMobileConnectionInfo.h"
-#include "nsIMobileConnectionService.h"
 #include "nsIMobileCellInfo.h"
 #include "nsIRadioInterfaceLayer.h"
 #endif
 
 #define SETTING_DEBUG_ENABLED "geolocation.debugging.enabled"
 
 #ifdef AGPS_TYPE_INVALID
 #define AGPS_HAVE_DUAL_APN
@@ -505,28 +504,18 @@ GonkGPSGeolocationProvider::SetReference
       }
 
       location.u.cellID.mnc = mnc.ToInteger(&result);
       if (result != NS_OK) {
         NS_WARNING("Cannot parse mnc to integer");
         location.u.cellID.mnc = 0;
       }
     }
-
-    nsCOMPtr<nsIMobileConnectionService> service =
-      do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-    if (!service) {
-      NS_WARNING("Cannot get MobileConnectionService");
-      return;
-    }
-
     nsCOMPtr<nsIMobileConnectionInfo> voice;
-    // TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
-    // MultiSIM configuration
-    service->GetVoiceConnectionInfo(0 /* Client Id */, getter_AddRefs(voice));
+    rilCtx->GetVoice(getter_AddRefs(voice));
     if (voice) {
       nsCOMPtr<nsIMobileCellInfo> cell;
       voice->GetCell(getter_AddRefs(cell));
       if (cell) {
         int32_t lac;
         int64_t cid;
 
         cell->GetGsmLocationAreaCode(&lac);
@@ -926,25 +915,25 @@ GonkGPSGeolocationProvider::Observe(nsIS
       int32_t state;
       int32_t type;
       iface->GetState(&state);
       iface->GetType(&type);
       bool connected = (state == nsINetworkInterface::NETWORK_STATE_CONNECTED);
       bool roaming = false;
       int gpsNetworkType = ConvertToGpsNetworkType(type);
       if (gpsNetworkType >= 0) {
-        nsCOMPtr<nsIMobileConnectionService> service =
-          do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
-        if (rilface && service) {
-          nsCOMPtr<nsIMobileConnectionInfo> voice;
-          // TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
-          // MultiSIM configuration
-          service->GetVoiceConnectionInfo(0 /* Client Id */, getter_AddRefs(voice));
-          if (voice) {
-            voice->GetRoaming(&roaming);
+        if (rilface && mRadioInterface) {
+          nsCOMPtr<nsIRilContext> rilCtx;
+          mRadioInterface->GetRilContext(getter_AddRefs(rilCtx));
+          if (rilCtx) {
+            nsCOMPtr<nsIMobileConnectionInfo> voice;
+            rilCtx->GetVoice(getter_AddRefs(voice));
+            if (voice) {
+              voice->GetRoaming(&roaming);
+            }
           }
         }
         mAGpsRilInterface->update_network_state(
           connected,
           gpsNetworkType,
           roaming,
           /* extra_info = */ nullptr);
       }
--- a/dom/system/gonk/NetworkManager.js
+++ b/dom/system/gonk/NetworkManager.js
@@ -29,20 +29,16 @@ XPCOMUtils.defineLazyGetter(this, "ppmm"
 XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
                                    "@mozilla.org/network/dns-service;1",
                                    "nsIDNSService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
                                    "@mozilla.org/network/service;1",
                                    "nsINetworkService");
 
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
-                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
-                                   "nsIMobileConnectionService");
-
 const TOPIC_INTERFACE_REGISTERED     = "network-interface-registered";
 const TOPIC_INTERFACE_UNREGISTERED   = "network-interface-unregistered";
 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";
@@ -854,18 +850,20 @@ NetworkManager.prototype = {
       }
     }
   },
 
   dunRetryTimes: 0,
   dunRetryTimer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
   setupDunConnection: function() {
     this.dunRetryTimer.cancel();
-    let data = gMobileConnectionService.getDataConnectionInfo(this._dataDefaultServiceId);
-    if (data && data.state === "registered") {
+    let ril = this.mRil.getRadioInterface(this._dataDefaultServiceId);
+
+    if (ril.rilContext && ril.rilContext.data &&
+        ril.rilContext.data.state === "registered") {
       this.dunRetryTimes = 0;
       ril.setupDataCallByType("dun");
       this.dunConnectTimer.cancel();
       this.dunConnectTimer.
         initWithCallback(this.onDunConnectTimerTimeout.bind(this),
                          MOBILE_DUN_CONNECT_TIMEOUT, Ci.nsITimer.TYPE_ONE_SHOT);
       return;
     }
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -36,46 +36,86 @@ const kPrefRilDebuggingEnabled = "ril.de
 const kPrefVoicemailDefaultServiceId = "dom.voicemail.defaultServiceId";
 
 let DEBUG;
 function debug(s) {
   dump("-*- RILContentHelper: " + s + "\n");
 }
 
 const RILCONTENTHELPER_CID =
-  Components.ID("{41effd45-9246-4e66-b464-cfa272ed8b54}");
+  Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
 const GSMICCINFO_CID =
   Components.ID("{e0fa785b-ad3f-46ed-bc56-fcb0d6fe4fa8}");
 const CDMAICCINFO_CID =
   Components.ID("{3d1f844f-9ec5-48fb-8907-aed2e5421709}");
+const MOBILECONNECTIONINFO_CID =
+  Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
+const MOBILENETWORKINFO_CID =
+  Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
+const MOBILECELLINFO_CID =
+  Components.ID("{ae724dd4-ccaf-4006-98f1-6ce66a092464}");
 const VOICEMAILSTATUS_CID=
   Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
+const MOBILECFINFO_CID=
+  Components.ID("{a4756f16-e728-4d9f-8baa-8464f894888a}");
 const CELLBROADCASTMESSAGE_CID =
   Components.ID("{29474c96-3099-486f-bb4a-3c9a1da834e4}");
 const CELLBROADCASTETWSINFO_CID =
   Components.ID("{59f176ee-9dcd-4005-9d47-f6be0cd08e17}");
 const ICCCARDLOCKERROR_CID =
   Components.ID("{08a71987-408c-44ff-93fd-177c0a85c3dd}");
 
 const RIL_IPC_MSG_NAMES = [
   "RIL:CardStateChanged",
   "RIL:IccInfoChanged",
+  "RIL:VoiceInfoChanged",
+  "RIL:DataInfoChanged",
+  "RIL:GetAvailableNetworks",
+  "RIL:NetworkSelectionModeChanged",
+  "RIL:SelectNetwork",
+  "RIL:SelectNetworkAuto",
+  "RIL:SetPreferredNetworkType",
+  "RIL:GetPreferredNetworkType",
+  "RIL:EmergencyCbModeChanged",
   "RIL:VoicemailNotification",
   "RIL:VoicemailInfoChanged",
   "RIL:CardLockResult",
   "RIL:CardLockRetryCount",
+  "RIL:USSDReceived",
+  "RIL:SendMMI",
+  "RIL:CancelMMI",
   "RIL:StkCommand",
   "RIL:StkSessionEnd",
+  "RIL:DataError",
+  "RIL:SetCallForwardingOptions",
+  "RIL:GetCallForwardingOptions",
+  "RIL:SetCallBarringOptions",
+  "RIL:GetCallBarringOptions",
+  "RIL:ChangeCallBarringPassword",
+  "RIL:SetCallWaitingOptions",
+  "RIL:GetCallWaitingOptions",
+  "RIL:SetCallingLineIdRestriction",
+  "RIL:GetCallingLineIdRestriction",
   "RIL:CellBroadcastReceived",
+  "RIL:CfStateChanged",
   "RIL:IccOpenChannel",
   "RIL:IccCloseChannel",
   "RIL:IccExchangeAPDU",
   "RIL:ReadIccContacts",
   "RIL:UpdateIccContact",
-  "RIL:MatchMvno"
+  "RIL:SetRoamingPreference",
+  "RIL:GetRoamingPreference",
+  "RIL:ExitEmergencyCbMode",
+  "RIL:SetRadioEnabled",
+  "RIL:RadioStateChanged",
+  "RIL:SetVoicePrivacyMode",
+  "RIL:GetVoicePrivacyMode",
+  "RIL:OtaStatusChanged",
+  "RIL:MatchMvno",
+  "RIL:ClirModeChanged"
 ];
 
 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
                                    "@mozilla.org/childprocessmessagemanager;1",
                                    "nsISyncMessageSender");
 
 XPCOMUtils.defineLazyGetter(this, "gNumRadioInterfaces", function() {
   let appInfo = Cc["@mozilla.org/xre/app-info;1"];
@@ -161,31 +201,111 @@ CdmaIccInfo.prototype = {
 };
 
 function VoicemailInfo() {}
 VoicemailInfo.prototype = {
   number: null,
   displayName: null
 };
 
+function MobileConnectionInfo() {}
+MobileConnectionInfo.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionInfo]),
+  classID:        MOBILECONNECTIONINFO_CID,
+  classInfo:      XPCOMUtils.generateCI({
+    classID:          MOBILECONNECTIONINFO_CID,
+    classDescription: "MobileConnectionInfo",
+    interfaces:       [Ci.nsIMobileConnectionInfo]
+  }),
+
+  // nsIMobileConnectionInfo
+
+  connected: false,
+  state: null,
+  emergencyCallsOnly: false,
+  roaming: false,
+  network: null,
+  cell: null,
+  type: null,
+  signalStrength: null,
+  relSignalStrength: null
+};
+
+function MobileNetworkInfo() {}
+MobileNetworkInfo.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileNetworkInfo]),
+  classID:        MOBILENETWORKINFO_CID,
+  classInfo:      XPCOMUtils.generateCI({
+    classID:          MOBILENETWORKINFO_CID,
+    classDescription: "MobileNetworkInfo",
+    interfaces:       [Ci.nsIMobileNetworkInfo]
+  }),
+
+  // nsIMobileNetworkInfo
+
+  shortName: null,
+  longName: null,
+  mcc: null,
+  mnc: null,
+  state: null
+};
+
+function MobileCellInfo() {}
+MobileCellInfo.prototype = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileCellInfo]),
+  classID:        MOBILECELLINFO_CID,
+  classInfo:      XPCOMUtils.generateCI({
+    classID:          MOBILECELLINFO_CID,
+    classDescription: "MobileCellInfo",
+    interfaces:       [Ci.nsIMobileCellInfo]
+  }),
+
+  // nsIMobileCellInfo
+
+  gsmLocationAreaCode: -1,
+  gsmCellId: -1,
+  cdmaBaseStationId: -1,
+  cdmaBaseStationLatitude: -2147483648,
+  cdmaBaseStationLongitude: -2147483648,
+  cdmaSystemId: -1,
+  cdmaNetworkId: -1
+};
+
 function VoicemailStatus(clientId) {
   this.serviceId = clientId;
 }
 VoicemailStatus.prototype = {
   QueryInterface: XPCOMUtils.generateQI([]),
   classID:        VOICEMAILSTATUS_CID,
   contractID:     "@mozilla.org/voicemailstatus;1",
 
   serviceId: -1,
   hasMessages: false,
   messageCount: -1, // Count unknown.
   returnNumber: null,
   returnMessage: null
 };
 
+function MobileCallForwardingInfo(options) {
+  this.active = options.active;
+  this.action = options.action;
+  this.reason = options.reason;
+  this.number = options.number;
+  this.timeSeconds = options.timeSeconds;
+  this.serviceClass = options.serviceClass;
+}
+MobileCallForwardingInfo.prototype = {
+  __exposedProps__ : {active: 'r',
+                      action: 'r',
+                      reason: 'r',
+                      number: 'r',
+                      timeSeconds: 'r',
+                      serviceClass: 'r'}
+};
+
 function CellBroadcastMessage(clientId, pdu) {
   this.serviceId = clientId;
   this.gsmGeographicalScope = RIL.CB_GSM_GEOGRAPHICAL_SCOPE_NAMES[pdu.geographicalScope];
   this.messageCode = pdu.messageCode;
   this.messageId = pdu.messageId;
   this.language = pdu.language;
   this.body = pdu.fullBody;
   this.messageClass = pdu.messageClass;
@@ -241,16 +361,49 @@ CellBroadcastEtwsInfo.prototype = {
 
   // nsIDOMMozCellBroadcastEtwsInfo
 
   warningType: null,
   emergencyUserAlert: null,
   popup: null
 };
 
+function CallBarringOptions(options) {
+  this.program = options.program;
+  this.enabled = options.enabled;
+  this.password = options.password;
+  this.serviceClass = options.serviceClass;
+}
+CallBarringOptions.prototype = {
+  __exposedProps__ : {program: 'r',
+                      enabled: 'r',
+                      password: 'r',
+                      serviceClass: 'r'}
+};
+
+function DOMMMIResult(result) {
+  this.serviceCode = result.serviceCode;
+  this.statusMessage = result.statusMessage;
+  this.additionalInformation = result.additionalInformation;
+}
+DOMMMIResult.prototype = {
+  __exposedProps__: {serviceCode: 'r',
+                     statusMessage: 'r',
+                     additionalInformation: 'r'}
+};
+
+function DOMCLIRStatus(option) {
+  this.n = option.n;
+  this.m = option.m;
+}
+DOMCLIRStatus.prototype = {
+  __exposedProps__ : {n: 'r',
+                      m: 'r'}
+};
+
 function IccCardLockError() {
 }
 IccCardLockError.prototype = {
   classDescription: "IccCardLockError",
   classID:          ICCCARDLOCKERROR_CID,
   contractID:       "@mozilla.org/dom/icccardlock-error;1",
   QueryInterface:   XPCOMUtils.generateQI([Ci.nsISupports]),
   __init: function(lockType, errorMsg, retryCount) {
@@ -267,48 +420,56 @@ function RILContentHelper() {
   if (DEBUG) debug("Number of clients: " + this.numClients);
 
   this.rilContexts = [];
   this.voicemailInfos = [];
   this.voicemailStatuses = [];
   for (let clientId = 0; clientId < this.numClients; clientId++) {
     this.rilContexts[clientId] = {
       cardState:            RIL.GECKO_CARDSTATE_UNKNOWN,
-      iccInfo:              null
+      networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
+      radioState:           null,
+      iccInfo:              null,
+      voiceConnectionInfo:  new MobileConnectionInfo(),
+      dataConnectionInfo:   new MobileConnectionInfo()
     };
 
     this.voicemailInfos[clientId] = new VoicemailInfo();
   }
 
   this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
 
   this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
   this._windowsMap = [];
+  this._mobileConnectionListeners = [];
   this._cellBroadcastListeners = [];
   this._voicemailListeners = [];
   this._iccListeners = [];
 
   Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
 
   Services.prefs.addObserver(kPrefRilDebuggingEnabled, this, false);
   Services.prefs.addObserver(kPrefVoicemailDefaultServiceId, this, false);
 }
 
 RILContentHelper.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsICellBroadcastProvider,
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
+                                         Ci.nsICellBroadcastProvider,
                                          Ci.nsIVoicemailProvider,
                                          Ci.nsIIccProvider,
                                          Ci.nsIObserver,
-                                         Ci.nsISupportsWeakReference]),
+                                         Ci.nsISupportsWeakReference,
+                                         Ci.nsIObserver]),
   classID:   RILCONTENTHELPER_CID,
   classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
                                     classDescription: "RILContentHelper",
-                                    interfaces: [Ci.nsICellBroadcastProvider,
+                                    interfaces: [Ci.nsIMobileConnectionProvider,
+                                                 Ci.nsICellBroadcastProvider,
                                                  Ci.nsIVoicemailProvider,
                                                  Ci.nsIIccProvider]}),
 
   updateDebugFlag: function() {
     try {
       DEBUG = RIL.DEBUG_CONTENT_HELPER ||
               Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
     } catch (e) {}
@@ -316,44 +477,89 @@ RILContentHelper.prototype = {
 
   // An utility function to copy objects.
   updateInfo: function(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
     }
   },
 
+  updateConnectionInfo: function(srcInfo, destInfo) {
+    for (let key in srcInfo) {
+      if ((key != "network") && (key != "cell")) {
+        destInfo[key] = srcInfo[key];
+      }
+    }
+
+    let srcCell = srcInfo.cell;
+    if (!srcCell) {
+      destInfo.cell = null;
+    } else {
+      let cell = destInfo.cell;
+      if (!cell) {
+        cell = destInfo.cell = new MobileCellInfo();
+      }
+
+      this.updateInfo(srcCell, cell);
+    }
+
+    let srcNetwork = srcInfo.network;
+    if (!srcNetwork) {
+      destInfo.network= null;
+      return;
+    }
+
+    let network = destInfo.network;
+    if (!network) {
+      network = destInfo.network = new MobileNetworkInfo();
+    }
+
+    this.updateInfo(srcNetwork, network);
+  },
+
   /**
    * We need to consider below cases when update iccInfo:
    * 1. Should clear iccInfo to null if there is no card detected.
    * 2. Need to create corresponding object based on iccType.
    */
   updateIccInfo: function(clientId, newInfo) {
     let rilContext = this.rilContexts[clientId];
 
     // Card is not detected, clear iccInfo to null.
     if (!newInfo || !newInfo.iccType || !newInfo.iccid) {
       if (rilContext.iccInfo) {
         rilContext.iccInfo = null;
+        this._deliverEvent(clientId,
+                           "_mobileConnectionListeners",
+                           "notifyIccChanged",
+                           null);
       }
       return;
     }
 
     // If iccInfo is null, new corresponding object based on iccType.
     if (!rilContext.iccInfo) {
       if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") {
         rilContext.iccInfo = new CdmaIccInfo();
       } else {
         rilContext.iccInfo = new GsmIccInfo();
       }
     }
     let changed = (rilContext.iccInfo.iccid != newInfo.iccid) ?
       true : false;
 
     this.updateInfo(newInfo, rilContext.iccInfo);
+
+    // Deliver event after info is updated.
+    if (changed) {
+      this._deliverEvent(clientId,
+                         "_mobileConnectionListeners",
+                         "notifyIccChanged",
+                         null);
+    }
   },
 
   _windowsMap: null,
 
   rilContexts: null,
 
   getRilContext: function(clientId) {
     // Update ril contexts by sending IPC message to chrome only when the first
@@ -366,17 +572,21 @@ RILContentHelper.prototype = {
     for (let cId = 0; cId < this.numClients; cId++) {
       let rilContext =
         cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: cId})[0];
       if (!rilContext) {
         if (DEBUG) debug("Received null rilContext from chrome process.");
         continue;
       }
       this.rilContexts[cId].cardState = rilContext.cardState;
+      this.rilContexts[cId].networkSelectionMode = rilContext.networkSelectionMode;
+      this.rilContexts[cId].radioState = rilContext.detailedRadioState;
       this.updateIccInfo(cId, rilContext.iccInfo);
+      this.updateConnectionInfo(rilContext.voice, this.rilContexts[cId].voiceConnectionInfo);
+      this.updateConnectionInfo(rilContext.data, this.rilContexts[cId].dataConnectionInfo);
     }
 
     return this.rilContexts[clientId];
   },
 
   /**
    * nsIIccProvider
    */
@@ -406,16 +616,275 @@ RILContentHelper.prototype = {
         requestId: requestId,
         mvnoType: mvnoType,
         mvnoData: mvnoData
       }
     });
     return request;
   },
 
+  /**
+   * nsIMobileConnectionProvider
+   */
+
+  getLastKnownNetwork: function(clientId) {
+    return cpmm.sendSyncMessage("RIL:GetLastKnownNetwork", {
+      clientId: clientId
+    })[0];
+  },
+
+  getLastKnownHomeNetwork: function(clientId) {
+    return cpmm.sendSyncMessage("RIL:GetLastKnownHomeNetwork", {
+      clientId: clientId
+    })[0];
+  },
+
+  getVoiceConnectionInfo: function(clientId) {
+    let context = this.getRilContext(clientId);
+    return context && context.voiceConnectionInfo;
+  },
+
+  getDataConnectionInfo: function(clientId) {
+    let context = this.getRilContext(clientId);
+    return context && context.dataConnectionInfo;
+  },
+
+  getIccId: function(clientId) {
+    let context = this.getRilContext(clientId);
+    return context && context.iccInfo && context.iccInfo.iccid;
+  },
+
+  getNetworkSelectionMode: function(clientId) {
+    let context = this.getRilContext(clientId);
+    return context && context.networkSelectionMode;
+  },
+
+  getRadioState: function(clientId) {
+    let context = this.getRilContext(clientId);
+    return context && context.radioState;
+  },
+
+  getSupportedNetworkTypes: function(clientId) {
+    return cpmm.sendSyncMessage("RIL:GetSupportedNetworkTypes", {
+      clientId: clientId
+    })[0];
+  },
+
+  getNetworks: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+    // We need to save the global window to get the proper MobileNetworkInfo
+    // constructor once we get the reply from the parent process.
+    this._windowsMap[requestId] = window;
+
+    cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
+  selectNetwork: function(clientId, window, network) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (!network ||
+        isNaN(parseInt(network.mcc, 10)) || isNaN(parseInt(network.mnc, 10))) {
+      this.dispatchFireRequestError(RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL &&
+        this.rilContexts[clientId].voiceConnectionInfo.network === network) {
+      // Already manually selected this network, so schedule
+      // onsuccess to be fired on the next tick
+      this.dispatchFireRequestSuccess(requestId, null);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SelectNetwork", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        mnc: network.mnc,
+        mcc: network.mcc
+      }
+    });
+
+    return request;
+  },
+
+  selectNetworkAutomatically: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) {
+      // Already using automatic selection mode, so schedule
+      // onsuccess to be be fired on the next tick
+      this.dispatchFireRequestSuccess(requestId, null);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
+  setPreferredNetworkType: function(clientId, window, type) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    let radioState = this.rilContexts[clientId].radioState;
+    if (radioState !== RIL.GECKO_DETAILED_RADIOSTATE_ENABLED) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SetPreferredNetworkType", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        type: type
+      }
+    });
+    return request;
+  },
+
+  getPreferredNetworkType: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    let radioState = this.rilContexts[clientId].radioState;
+    if (radioState !== RIL.GECKO_DETAILED_RADIOSTATE_ENABLED) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:GetPreferredNetworkType", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
+  setRoamingPreference: function(clientId, window, mode) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (!mode) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SetRoamingPreference", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        mode: mode
+      }
+    });
+    return request;
+  },
+
+  getRoamingPreference: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:GetRoamingPreference", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
+  setVoicePrivacyMode: function(clientId, window, enabled) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:SetVoicePrivacyMode", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        enabled: enabled
+      }
+    });
+    return request;
+  },
+
+  getVoicePrivacyMode: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:GetVoicePrivacyMode", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
   getCardLockState: function(clientId, window, lockType) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     let request = Services.DOMRequest.createRequest(window);
     let requestId = this.getRequestId(request);
     this._windowsMap[requestId] = window;
@@ -474,16 +943,55 @@ RILContentHelper.prototype = {
       data: {
         lockType: lockType,
         requestId: requestId
       }
     });
     return request;
   },
 
+  sendMMI: function(clientId, window, mmi) {
+    if (DEBUG) debug("Sending MMI " + mmi);
+    if (!window) {
+      throw Components.Exception("Can't get window object",
+                                 Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+    // We need to save the global window to get the proper MMIError
+    // constructor once we get the reply from the parent process.
+    this._windowsMap[requestId] = window;
+
+    cpmm.sendAsyncMessage("RIL:SendMMI", {
+      clientId: clientId,
+      data: {
+        mmi: mmi,
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
+  cancelMMI: function(clientId, window) {
+    if (DEBUG) debug("Cancel MMI");
+    if (!window) {
+      throw Components.Exception("Can't get window object",
+                                 Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+    cpmm.sendAsyncMessage("RIL:CancelMMI", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+    return request;
+  },
+
   sendStkResponse: function(clientId, window, command, response) {
     if (window == null) {
       throw Components.Exception("Can't get window object",
                                   Cr.NS_ERROR_UNEXPECTED);
     }
     response.command = command;
     cpmm.sendAsyncMessage("RIL:SendStkResponse", {
       clientId: clientId,
@@ -654,16 +1162,283 @@ RILContentHelper.prototype = {
         contact: iccContact,
         pin2: pin2
       }
     });
 
     return request;
   },
 
+  getCallForwarding: function(clientId, window, reason) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (!this._isValidCallForwardingReason(reason)) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:GetCallForwardingOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        reason: reason
+      }
+    });
+
+    return request;
+  },
+
+  setCallForwarding: function(clientId, window, options) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (!options ||
+        !this._isValidCallForwardingReason(options.reason) ||
+        !this._isValidCallForwardingAction(options.action)) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SetCallForwardingOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        action: options.action,
+        reason: options.reason,
+        number: options.number,
+        timeSeconds: options.timeSeconds
+      }
+    });
+
+    return request;
+  },
+
+  getCallBarring: function(clientId, window, options) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (DEBUG) debug("getCallBarring: " + JSON.stringify(options));
+    if (!this._isValidCallBarringOptions(options)) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:GetCallBarringOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        program: options.program,
+        password: options.password,
+        serviceClass: options.serviceClass
+      }
+    });
+    return request;
+  },
+
+  setCallBarring: function(clientId, window, options) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    if (DEBUG) debug("setCallBarringOptions: " + JSON.stringify(options));
+    if (!this._isValidCallBarringOptions(options, true)) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SetCallBarringOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        program: options.program,
+        enabled: options.enabled,
+        password: options.password,
+        serviceClass: options.serviceClass
+      }
+    });
+    return request;
+  },
+
+  changeCallBarringPassword: function(clientId, window, info) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    // Checking valid PIN for supplementary services. See TS.22.004 clause 5.2.
+    if (info.pin == null || !info.pin.match(/^\d{4}$/) ||
+        info.newPin == null || !info.newPin.match(/^\d{4}$/)) {
+      this.dispatchFireRequestError(requestId, "InvalidPassword");
+      return request;
+    }
+
+    if (DEBUG) debug("changeCallBarringPassword: " + JSON.stringify(info));
+    info.requestId = requestId;
+    cpmm.sendAsyncMessage("RIL:ChangeCallBarringPassword", {
+      clientId: clientId,
+      data: info
+    });
+
+    return request;
+  },
+
+  getCallWaiting: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:GetCallWaitingOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+
+    return request;
+  },
+
+  setCallWaiting: function(clientId, window, enabled) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:SetCallWaitingOptions", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        enabled: enabled
+      }
+    });
+
+    return request;
+  },
+
+  getCallingLineIdRestriction: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    let radioState = this.rilContexts[clientId].radioState;
+    if (radioState !== RIL.GECKO_DETAILED_RADIOSTATE_ENABLED) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", {
+      clientId: clientId,
+      data: {
+        requestId: requestId
+      }
+    });
+
+    return request;
+  },
+
+  setCallingLineIdRestriction: function(clientId, window, clirMode) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    let radioState = this.rilContexts[clientId].radioState;
+    if (radioState !== RIL.GECKO_DETAILED_RADIOSTATE_ENABLED) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_RADIO_NOT_AVAILABLE);
+      return request;
+    }
+
+    if (!this._isValidClirMode(clirMode)) {
+      this.dispatchFireRequestError(requestId,
+                                    RIL.GECKO_ERROR_INVALID_PARAMETER);
+      return request;
+    }
+
+    cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        clirMode: clirMode
+      }
+    });
+
+    return request;
+  },
+
+  exitEmergencyCbMode: function(clientId, window) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:ExitEmergencyCbMode", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+      }
+    });
+
+    return request;
+  },
+
+  setRadioEnabled: function(clientId, window, enabled) {
+    if (window == null) {
+      throw Components.Exception("Can't get window object",
+                                  Cr.NS_ERROR_UNEXPECTED);
+    }
+    let request = Services.DOMRequest.createRequest(window);
+    let requestId = this.getRequestId(request);
+
+    cpmm.sendAsyncMessage("RIL:SetRadioEnabled", {
+      clientId: clientId,
+      data: {
+        requestId: requestId,
+        enabled: enabled,
+      }
+    });
+
+    return request;
+  },
+
+  _mobileConnectionListeners: null,
   _cellBroadcastListeners: null,
   _voicemailListeners: null,
   _iccListeners: null,
 
   voicemailInfos: null,
   voicemailStatuses: null,
 
   voicemailDefaultServiceId: 0,
@@ -734,16 +1509,26 @@ RILContentHelper.prototype = {
 
     let index = listeners.indexOf(listener);
     if (index != -1) {
       listeners.splice(index, 1);
       if (DEBUG) debug("Unregistered listener: " + listener);
     }
   },
 
+  registerMobileConnectionMsg: function(clientId, listener) {
+    if (DEBUG) debug("Registering for mobile connection related messages");
+    this.registerListener("_mobileConnectionListeners", clientId, listener);
+    cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg");
+  },
+
+  unregisterMobileConnectionMsg: function(clientId, listener) {
+    this.unregisterListener("_mobileConnectionListeners", clientId, listener);
+  },
+
   registerVoicemailMsg: function(listener) {
     if (DEBUG) debug("Registering for voicemail-related messages");
     // To follow the listener registration scheme, we add a dummy clientId 0.
     // All voicemail events are routed to listener for client id 0.
     // See |handleVoicemailNotification|.
     this.registerListener("_voicemailListeners", 0, listener);
     cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
   },
@@ -883,16 +1668,56 @@ RILContentHelper.prototype = {
         break;
       case "RIL:IccInfoChanged":
         this.updateIccInfo(clientId, data);
         this._deliverEvent(clientId,
                            "_iccListeners",
                            "notifyIccInfoChanged",
                            null);
         break;
+      case "RIL:VoiceInfoChanged":
+        this.updateConnectionInfo(data,
+                                  this.rilContexts[clientId].voiceConnectionInfo);
+        this._deliverEvent(clientId,
+                           "_mobileConnectionListeners",
+                           "notifyVoiceChanged",
+                           null);
+        break;
+      case "RIL:DataInfoChanged":
+        this.updateConnectionInfo(data,
+                                  this.rilContexts[clientId].dataConnectionInfo);
+        this._deliverEvent(clientId,
+                           "_mobileConnectionListeners",
+                           "notifyDataChanged",
+                           null);
+        break;
+      case "RIL:OtaStatusChanged":
+        this._deliverEvent(clientId,
+                           "_mobileConnectionListeners",
+                           "notifyOtaStatusChanged",
+                           [data]);
+        break;
+      case "RIL:GetAvailableNetworks":
+        this.handleGetAvailableNetworks(data);
+        break;
+      case "RIL:NetworkSelectionModeChanged":
+        this.rilContexts[clientId].networkSelectionMode = data.mode;
+        break;
+      case "RIL:SelectNetwork":
+        this.handleSimpleRequest(data.requestId, data.errorMsg, null);
+        break;
+      case "RIL:SelectNetworkAuto":
+        this.handleSimpleRequest(data.requestId, data.errorMsg, null);
+        break;
+      case "RIL:SetPreferredNetworkType":
+        this.handleSimpleRequest(data.requestId, data.errorMsg, null);
+        break;
+      case "RIL:GetPreferredNetworkType":
+        this.handleSimpleRequest(data.requestId, data.errorMsg, data.type);
+        break;
       case "RIL:VoicemailNotification":
         this.handleVoicemailNotification(clientId, data);
         break;
       case "RIL:VoicemailInfoChanged":
         this.updateInfo(data, this.voicemailInfos[clientId]);
         break;
       case "RIL:CardLockResult": {
         let requestId = data.requestId;
@@ -918,16 +1743,26 @@ RILContentHelper.prototype = {
       case "RIL:CardLockRetryCount":
         if (data.success) {
           let result = new MobileIccCardLockRetryCount(data);
           this.fireRequestSuccess(data.requestId, result);
         } else {
           this.fireRequestError(data.requestId, data.errorMsg);
         }
         break;
+      case "RIL:USSDReceived":
+        this._deliverEvent(clientId,
+                           "_mobileConnectionListeners",
+                           "notifyUssdReceived",
+                           [data.message, data.sessionEnded]);
+        break;
+      case "RIL:SendMMI":
+      case "RIL:CancelMMI":
+        this.handleSendCancelMMI(data);
+        break;
       case "RIL:StkCommand":
         this._deliverEvent(clientId, "_iccListeners", "notifyStkCommand",
                            [JSON.stringify(data)]);
         break;
       case "RIL:StkSessionEnd":
         this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null);
         break;
       case "RIL:IccOpenChannel":
@@ -944,37 +1779,145 @@ RILContentHelper.prototype = {
         this.handleReadIccContacts(data);
         break;
       case "RIL:UpdateIccContact":
         this.handleUpdateIccContact(data);
         break;
       case "RIL:MatchMvno":
         this.handleSimpleRequest(data.requestId,