mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 889737 - Part 05: Refactoring: Embed the response in delete. r=vicamo
This commit is contained in:
parent
d51907bc80
commit
49f63eb2ff
@ -16,15 +16,23 @@ struct EnumerateCallsResponse
|
||||
// empty.
|
||||
};
|
||||
|
||||
struct DialResponse
|
||||
struct DialResponseError
|
||||
{
|
||||
// empty.
|
||||
nsString name;
|
||||
};
|
||||
|
||||
struct DialResponseCallSuccess
|
||||
{
|
||||
uint32_t callIndex;
|
||||
nsString number;
|
||||
};
|
||||
|
||||
union IPCTelephonyResponse
|
||||
{
|
||||
EnumerateCallsResponse;
|
||||
DialResponse;
|
||||
// dial
|
||||
DialResponseError;
|
||||
DialResponseCallSuccess;
|
||||
};
|
||||
|
||||
protocol PTelephonyRequest
|
||||
@ -34,10 +42,6 @@ protocol PTelephonyRequest
|
||||
child:
|
||||
NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData);
|
||||
|
||||
NotifyDialError(nsString aError);
|
||||
|
||||
NotifyDialCallSuccess(uint32_t aCallIndex, nsString aNumber);
|
||||
|
||||
/**
|
||||
* Sent when the asynchronous request has completed.
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "TelephonyChild.h"
|
||||
|
||||
#include "TelephonyIPCService.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
@ -145,9 +146,10 @@ TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
|
||||
case IPCTelephonyResponse::TEnumerateCallsResponse:
|
||||
mListener->EnumerateCallStateComplete();
|
||||
break;
|
||||
case IPCTelephonyResponse::TDialResponse:
|
||||
// Do nothing.
|
||||
break;
|
||||
case IPCTelephonyResponse::TDialResponseError:
|
||||
return DoResponse(aResponse.get_DialResponseError());
|
||||
case IPCTelephonyResponse::TDialResponseCallSuccess:
|
||||
return DoResponse(aResponse.get_DialResponseCallSuccess());
|
||||
default:
|
||||
MOZ_CRASH("Unknown type!");
|
||||
}
|
||||
@ -177,20 +179,17 @@ TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
|
||||
TelephonyRequestChild::DoResponse(const DialResponseError& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
|
||||
mCallback->NotifyDialError(aError);
|
||||
mCallback->NotifyDialError(aResponse.name());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TelephonyRequestChild::RecvNotifyDialCallSuccess(const uint32_t& aCallIndex,
|
||||
const nsString& aNumber)
|
||||
TelephonyRequestChild::DoResponse(const DialResponseCallSuccess& aResponse)
|
||||
{
|
||||
MOZ_ASSERT(mCallback);
|
||||
|
||||
mCallback->NotifyDialCallSuccess(aCallIndex, aNumber);
|
||||
mCallback->NotifyDialCallSuccess(aResponse.callIndex(), aResponse.number());
|
||||
return true;
|
||||
}
|
||||
|
@ -79,14 +79,13 @@ protected:
|
||||
RecvNotifyEnumerateCallState(const uint32_t& aClientId,
|
||||
const IPCCallStateData& aData) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
RecvNotifyDialError(const nsString& aError) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
RecvNotifyDialCallSuccess(const uint32_t& aCallIndex,
|
||||
const nsString& aNumber) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
bool
|
||||
DoResponse(const DialResponseError& aResponse);
|
||||
|
||||
bool
|
||||
DoResponse(const DialResponseCallSuccess& aResponse);
|
||||
|
||||
nsCOMPtr<nsITelephonyListener> mListener;
|
||||
nsCOMPtr<nsITelephonyCallback> mCallback;
|
||||
};
|
||||
|
@ -434,6 +434,14 @@ TelephonyRequestParent::DoRequest(const DialRequest& aRequest)
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return Send__delete__(this, aResponse) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// nsITelephonyListener
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -529,18 +537,12 @@ TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId,
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialError(const nsAString& aError)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return (SendNotifyDialError(nsString(aError)) &&
|
||||
Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
|
||||
return SendResponse(DialResponseError(nsAutoString(aError)));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelephonyRequestParent::NotifyDialCallSuccess(uint32_t aCallIndex,
|
||||
const nsAString& aNumber)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
|
||||
|
||||
return (SendNotifyDialCallSuccess(aCallIndex, nsString(aNumber)) &&
|
||||
Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
|
||||
return SendResponse(DialResponseCallSuccess(aCallIndex, nsAutoString(aNumber)));
|
||||
}
|
||||
|
@ -114,6 +114,9 @@ protected:
|
||||
virtual void
|
||||
ActorDestroy(ActorDestroyReason why);
|
||||
|
||||
nsresult
|
||||
SendResponse(const IPCTelephonyResponse& aResponse);
|
||||
|
||||
private:
|
||||
bool mActorDestroyed;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user