From 11d305c274a579e1dedf6e0451ca636df7de6919 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Fri, 24 Apr 2015 18:10:37 +0800 Subject: [PATCH] Bug 1155063 - Part 4: CallStateChanged accepts an array (ipc). r=hsinyi --- dom/telephony/ipc/PTelephony.ipdl | 2 +- dom/telephony/ipc/TelephonyChild.cpp | 15 ++++++++++----- dom/telephony/ipc/TelephonyChild.h | 2 +- dom/telephony/ipc/TelephonyIPCService.cpp | 4 ++-- dom/telephony/ipc/TelephonyParent.cpp | 11 ++++++++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dom/telephony/ipc/PTelephony.ipdl b/dom/telephony/ipc/PTelephony.ipdl index cd7255396f3..60a83537f57 100644 --- a/dom/telephony/ipc/PTelephony.ipdl +++ b/dom/telephony/ipc/PTelephony.ipdl @@ -127,7 +127,7 @@ sync protocol PTelephony { child: NotifyCallError(uint32_t aClientId, int32_t aCallIndex, nsString aError); - NotifyCallStateChanged(nsTelephonyCallInfo aInfo); + NotifyCallStateChanged(nsTelephonyCallInfo[] aAllInfo); NotifyCdmaCallWaiting(uint32_t aClientId, IPCCdmaWaitingCallData aData); diff --git a/dom/telephony/ipc/TelephonyChild.cpp b/dom/telephony/ipc/TelephonyChild.cpp index e5b1d9a7b27..3b3809c3729 100644 --- a/dom/telephony/ipc/TelephonyChild.cpp +++ b/dom/telephony/ipc/TelephonyChild.cpp @@ -58,15 +58,20 @@ TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, } bool -TelephonyChild::RecvNotifyCallStateChanged(nsITelephonyCallInfo* const& aInfo) +TelephonyChild::RecvNotifyCallStateChanged(nsTArray&& aAllInfo) { - // Use dont_AddRef here because this instances has already been AddRef-ed in - // TelephonyIPCSerializer.h - nsCOMPtr info = dont_AddRef(aInfo); + uint32_t length = aAllInfo.Length(); + nsTArray> results; + for (uint32_t i = 0; i < length; ++i) { + // Use dont_AddRef here because this instance has already been AddRef-ed in + // TelephonyIPCSerializer.h + nsCOMPtr info = dont_AddRef(aAllInfo[i]); + results.AppendElement(info); + } MOZ_ASSERT(mService); - mService->CallStateChanged(aInfo); + mService->CallStateChanged(length, const_cast(aAllInfo.Elements())); return true; } diff --git a/dom/telephony/ipc/TelephonyChild.h b/dom/telephony/ipc/TelephonyChild.h index 2c6f128581e..73574e5b2f8 100644 --- a/dom/telephony/ipc/TelephonyChild.h +++ b/dom/telephony/ipc/TelephonyChild.h @@ -38,7 +38,7 @@ protected: const nsString& aError) override; virtual bool - RecvNotifyCallStateChanged(nsITelephonyCallInfo* const& aInfo) override; + RecvNotifyCallStateChanged(nsTArray&& aAllInfo) override; virtual bool RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, diff --git a/dom/telephony/ipc/TelephonyIPCService.cpp b/dom/telephony/ipc/TelephonyIPCService.cpp index c32e9579824..406eb4ed8ea 100644 --- a/dom/telephony/ipc/TelephonyIPCService.cpp +++ b/dom/telephony/ipc/TelephonyIPCService.cpp @@ -367,10 +367,10 @@ TelephonyIPCService::SetSpeakerEnabled(bool aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyIPCService::CallStateChanged(nsITelephonyCallInfo* aInfo) +TelephonyIPCService::CallStateChanged(uint32_t aLength, nsITelephonyCallInfo** aAllInfo) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->CallStateChanged(aInfo); + mListeners[i]->CallStateChanged(aLength, aAllInfo); } return NS_OK; } diff --git a/dom/telephony/ipc/TelephonyParent.cpp b/dom/telephony/ipc/TelephonyParent.cpp index 7b5ddc6b043..845f2b6d0fe 100644 --- a/dom/telephony/ipc/TelephonyParent.cpp +++ b/dom/telephony/ipc/TelephonyParent.cpp @@ -273,11 +273,16 @@ TelephonyParent::RecvSetSpeakerEnabled(const bool& aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyParent::CallStateChanged(nsITelephonyCallInfo* aInfo) +TelephonyParent::CallStateChanged(uint32_t aLength, nsITelephonyCallInfo** aAllInfo) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCallStateChanged(aInfo) ? NS_OK : NS_ERROR_FAILURE; + nsTArray allInfo; + for (uint32_t i = 0; i < aLength; i++) { + allInfo.AppendElement(aAllInfo[i]); + } + + return SendNotifyCallStateChanged(allInfo) ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -381,7 +386,7 @@ TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse) // nsITelephonyListener NS_IMETHODIMP -TelephonyRequestParent::CallStateChanged(nsITelephonyCallInfo* aInfo) +TelephonyRequestParent::CallStateChanged(uint32_t aLength, nsITelephonyCallInfo** aAllInfo) { MOZ_CRASH("Not a TelephonyParent!"); }