Bug 900880 - Remove unused system messages, r=echou
authorGina Yeh <gyeh@mozilla.com>
Wed, 11 Sep 2013 14:56:48 +0200
changeset 146621 2f896264f9690850bf95c6ce511a07295aa5acd8
parent 146620 45cc2a754f496af026eaf623380bba606d246123
child 146622 7b7a30d10bda8ce1bd87556e6ca1a126f8d4f4e7
push id25267
push userryanvm@gmail.com
push dateThu, 12 Sep 2013 00:58:25 +0000
treeherdermozilla-central@2f11fad2f307 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs900880
milestone26.0a1
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
Bug 900880 - Remove unused system messages, r=echou
dom/bluetooth/BluetoothA2dpManager.cpp
dom/bluetooth/BluetoothA2dpManager.h
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/messages/SystemMessagePermissionsChecker.jsm
--- a/dom/bluetooth/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/BluetoothA2dpManager.cpp
@@ -294,17 +294,16 @@ BluetoothA2dpManager::HandleSinkProperty
       }
       
       // case 3: Successfully connected
       MOZ_ASSERT(prevState == SinkState::SINK_CONNECTING);
 
       mA2dpConnected = true;
       mDeviceAddress = address;
       NotifyConnectionStatusChanged();
-      DispatchConnectionStatusChanged();
 
       OnConnect(EmptyString());
       break;
     case SinkState::SINK_DISCONNECTED:
       // XXX
       // case 2: Connection attempt failed
       if (prevState == SinkState::SINK_CONNECTING) {  
         OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
@@ -314,67 +313,45 @@ BluetoothA2dpManager::HandleSinkProperty
       // case 6: Disconnected from the remote device
       // case 7: Disconnected from local
       MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
                  prevState == SinkState::SINK_PLAYING ||
                  prevState == SinkState::SINK_DISCONNECTING);
   
       mA2dpConnected = false;
       NotifyConnectionStatusChanged();
-      DispatchConnectionStatusChanged();
       mDeviceAddress.Truncate();
 
       // case 7 only
       if (prevState == SinkState::SINK_DISCONNECTING) {
         OnDisconnect(EmptyString());
       }
       break;
   }
 }
 
 void
-BluetoothA2dpManager::DispatchConnectionStatusChanged()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  DispatchStatusChangedEvent(
-    NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
-}
-
-void
 BluetoothA2dpManager::NotifyConnectionStatusChanged()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  // Broadcast system message to Gaia
-  NS_NAMED_LITERAL_STRING(type, BLUETOOTH_A2DP_STATUS_CHANGED_ID);
-  InfallibleTArray<BluetoothNamedValue> parameters;
-
-  BluetoothValue v = mA2dpConnected;
-  parameters.AppendElement(
-    BluetoothNamedValue(NS_LITERAL_STRING("connected"), v));
-
-  v = mDeviceAddress;
-  parameters.AppendElement(
-    BluetoothNamedValue(NS_LITERAL_STRING("address"), v));
-
-  if (!BroadcastSystemMessage(type, parameters)) {
-    NS_WARNING("Failed to broadcast system message to settings");
-  }
-
   // Notify Gecko observers
   nsCOMPtr<nsIObserverService> obs =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->NotifyObservers(this,
                                      BLUETOOTH_A2DP_STATUS_CHANGED_ID,
                                      mDeviceAddress.get()))) {
     NS_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
   }
+
+  // Dispatch an event of status change
+  DispatchStatusChangedEvent(
+    NS_LITERAL_STRING(A2DP_STATUS_CHANGED_ID), mDeviceAddress, mA2dpConnected);
 }
 
 void
 BluetoothA2dpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
                                           const nsAString& aServiceUuid,
                                           int aChannel)
 {
 }
--- a/dom/bluetooth/BluetoothA2dpManager.h
+++ b/dom/bluetooth/BluetoothA2dpManager.h
@@ -66,18 +66,16 @@ public:
   uint32_t GetMediaNumber();
   void GetTitle(nsAString& aTitle);
 
 private:
   BluetoothA2dpManager();
   bool Init();
 
   void HandleShutdown();
-
-  void DispatchConnectionStatusChanged();
   void NotifyConnectionStatusChanged();
 
   nsString mDeviceAddress;
   BluetoothProfileController* mController;
 
   // A2DP data member
   bool mA2dpConnected;
   SinkState mSinkState;
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -438,68 +438,45 @@ BluetoothHfpManager::Get()
   BluetoothHfpManager* manager = new BluetoothHfpManager();
   NS_ENSURE_TRUE(manager->Init(), nullptr);
 
   sBluetoothHfpManager = manager;
   return sBluetoothHfpManager;
 }
 
 void
-BluetoothHfpManager::DispatchConnectionStatusChanged(const nsAString& aType)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  bool status = false;
-  if (aType.EqualsLiteral(HFP_STATUS_CHANGED_ID)) {
-    status = IsConnected();
-  } else if (aType.EqualsLiteral(SCO_STATUS_CHANGED_ID)) {
-    status = IsScoConnected();
-  } else {
-    BT_WARNING("Wrong type for DispatchConnectionStatusChanged");
-    return;
-  }
-
-  DispatchStatusChangedEvent(aType, mDeviceAddress, status);
-}
-
-void
 BluetoothHfpManager::NotifyConnectionStatusChanged(const nsAString& aType)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  BluetoothValue v;
-  InfallibleTArray<BluetoothNamedValue> parameters;
-  nsString name = NS_LITERAL_STRING("connected");
-  if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
-    v = IsConnected();
-  } else if (aType.EqualsLiteral(BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
-    v = IsScoConnected();
-  } else {
-    BT_WARNING("Wrong type for NotifyConnectionStatusChanged");
-    return;
-  }
-  parameters.AppendElement(BluetoothNamedValue(name, v));
-
-  name.AssignLiteral("address");
-  v = mDeviceAddress;
-  parameters.AppendElement(BluetoothNamedValue(name, v));
-
-  if (!BroadcastSystemMessage(aType, parameters)) {
-    NS_WARNING("Failed to broadcast system message to settings");
-  }
-
   // Notify Gecko observers
   nsCOMPtr<nsIObserverService> obs =
     do_GetService("@mozilla.org/observer-service;1");
   NS_ENSURE_TRUE_VOID(obs);
 
   if (NS_FAILED(obs->NotifyObservers(this, NS_ConvertUTF16toUTF8(aType).get(),
                                      mDeviceAddress.get()))) {
     NS_WARNING("Failed to notify observsers!");
   }
+
+  // Dispatch an event of status change
+  bool status;
+  nsAutoString eventName;
+  if (aType.EqualsLiteral(BLUETOOTH_HFP_STATUS_CHANGED_ID)) {
+    status = IsConnected();
+    eventName.AssignLiteral(HFP_STATUS_CHANGED_ID);
+  } else if (aType.EqualsLiteral(BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
+    status = IsScoConnected();
+    eventName.AssignLiteral(SCO_STATUS_CHANGED_ID);
+  } else {
+    MOZ_ASSERT(false);
+    return;
+  }
+
+  DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
 }
 
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   nsString type, name;
   BluetoothValue v;
   InfallibleTArray<BluetoothNamedValue> parameters;
@@ -1476,18 +1453,18 @@ BluetoothHfpManager::OnSocketConnectSucc
   // Enumerate current calls
   mListener->EnumerateCalls();
 
   mFirstCKPD = true;
 
   // Cache device path for NotifySettings() since we can't get socket address
   // when a headset disconnect with us
   mSocket->GetAddress(mDeviceAddress);
-  NotifyConnectionStatusChanged(NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
-  DispatchConnectionStatusChanged(NS_LITERAL_STRING(HFP_STATUS_CHANGED_ID));
+  NotifyConnectionStatusChanged(
+    NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
 
   ListenSco();
 
   OnConnect(EmptyString());
 }
 
 void
 BluetoothHfpManager::OnSocketConnectError(BluetoothSocket* aSocket)
@@ -1517,18 +1494,18 @@ BluetoothHfpManager::OnSocketDisconnect(
 
   if (aSocket != mSocket) {
     // Do nothing when a listening server socket is closed.
     return;
   }
 
   DisconnectSco();
 
-  NotifyConnectionStatusChanged(NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
-  DispatchConnectionStatusChanged(NS_LITERAL_STRING(HFP_STATUS_CHANGED_ID));
+  NotifyConnectionStatusChanged(
+    NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
   OnDisconnect(EmptyString());
 
   Reset();
 }
 
 void
 BluetoothHfpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
 {
@@ -1587,18 +1564,18 @@ BluetoothHfpManager::OnScoConnectSuccess
 {
   // For active connection request, we need to reply the DOMRequest
   if (mScoRunnable) {
     DispatchBluetoothReply(mScoRunnable,
                            BluetoothValue(true), EmptyString());
     mScoRunnable = nullptr;
   }
 
-  NotifyConnectionStatusChanged(NS_LITERAL_STRING(BLUETOOTH_SCO_STATUS_CHANGED_ID));
-  DispatchConnectionStatusChanged(NS_LITERAL_STRING(SCO_STATUS_CHANGED_ID));
+  NotifyConnectionStatusChanged(
+    NS_LITERAL_STRING(BLUETOOTH_SCO_STATUS_CHANGED_ID));
 
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
 }
 
 void
 BluetoothHfpManager::OnScoConnectError()
 {
   if (mScoRunnable) {
@@ -1611,18 +1588,18 @@ BluetoothHfpManager::OnScoConnectError()
   ListenSco();
 }
 
 void
 BluetoothHfpManager::OnScoDisconnect()
 {
   if (mScoSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
     ListenSco();
-    NotifyConnectionStatusChanged(NS_LITERAL_STRING(BLUETOOTH_SCO_STATUS_CHANGED_ID));
-    DispatchConnectionStatusChanged(NS_LITERAL_STRING(SCO_STATUS_CHANGED_ID));
+    NotifyConnectionStatusChanged(
+      NS_LITERAL_STRING(BLUETOOTH_SCO_STATUS_CHANGED_ID));
   }
 }
 
 bool
 BluetoothHfpManager::IsConnected()
 {
   if (mSocket) {
     return mSocket->GetConnectionStatus() ==
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -116,19 +116,18 @@ private:
 
   bool Init();
   void Notify(const hal::BatteryInformation& aBatteryInfo);
   void Reset();
   void ResetCallArray();
   uint32_t FindFirstCall(uint16_t aState);
   uint32_t GetNumberOfCalls(uint16_t aState);
 
-  void DispatchConnectionStatusChanged(const nsAString& aType);
+  void NotifyConnectionStatusChanged(const nsAString& aType);
   void NotifyDialer(const nsAString& aCommand);
-  void NotifyConnectionStatusChanged(const nsAString& aType);
 
   bool SendCommand(const char* aCommand, uint32_t aValue = 0);
   bool SendLine(const char* aMessage);
   void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true);
   void OnScoConnectSuccess();
   void OnScoConnectError();
   void OnScoDisconnect();
 
--- a/dom/messages/SystemMessagePermissionsChecker.jsm
+++ b/dom/messages/SystemMessagePermissionsChecker.jsm
@@ -32,31 +32,19 @@ this.SystemMessagePermissionsTable = {
     "alarms": []
   },
   "bluetooth-dialer-command": {
     "telephony": []
   },
   "bluetooth-cancel": {
     "bluetooth": []
   },
-  "bluetooth-pairedstatuschanged": {
-    "bluetooth": []
-  },
-  "bluetooth-a2dp-status-changed": {
-    "bluetooth": []
-  },
-  "bluetooth-hfp-status-changed": {
-    "bluetooth": []
-  },
   "bluetooth-hid-status-changed": {
     "bluetooth": []
   },
-  "bluetooth-sco-status-changed": {
-    "bluetooth": []
-  },
   "bluetooth-pairing-request": {
     "bluetooth": []
   },
   "bluetooth-opp-transfer-complete": {
     "bluetooth": []
   },
   "bluetooth-opp-update-progress": {
     "bluetooth": []