Bug 824717 - Part 5: Fire DOMMobileMessageError when NotifySendMessageFailed(). r=vyang

This commit is contained in:
Bevis Tseng 2014-04-28 13:20:02 +08:00
Родитель ac5591074f
Коммит 36b02ef228
2 изменённых файлов: 26 добавлений и 4 удалений

Просмотреть файл

@ -16,6 +16,7 @@
#include "xpcpublic.h"
#include "nsServiceManagerUtils.h"
#include "nsTArrayHelpers.h"
#include "DOMMobileMessageError.h"
namespace mozilla {
namespace dom {
@ -78,7 +79,7 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage, bool aAsync)
}
nsresult
MobileMessageCallback::NotifyError(int32_t aError, bool aAsync)
MobileMessageCallback::NotifyError(int32_t aError, nsISupports *aData, bool aAsync)
{
nsAutoString errorStr;
switch (aError) {
@ -119,6 +120,10 @@ MobileMessageCallback::NotifyError(int32_t aError, bool aAsync)
MOZ_CRASH("Should never get here!");
}
if (aData && aAsync) {
MOZ_CRASH("No Support to FireDetailedErrorAsync() in nsIDOMRequestService!");
}
if (aAsync) {
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
@ -127,6 +132,23 @@ MobileMessageCallback::NotifyError(int32_t aError, bool aAsync)
return rs->FireErrorAsync(mDOMRequest, errorStr);
}
if (aData) {
nsCOMPtr<nsISupports> domMobileMessageError;
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aData);
if (smsMsg) {
domMobileMessageError =
new DOMMobileMessageError(mDOMRequest->GetOwner(), errorStr, smsMsg);
}
else {
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aData);
domMobileMessageError =
new DOMMobileMessageError(mDOMRequest->GetOwner(), errorStr, mmsMsg);
}
NS_ASSERTION(domMobileMessageError, "Invalid DOMMobileMessageError!");
mDOMRequest->FireDetailedError(domMobileMessageError);
return NS_OK;
}
mDOMRequest->FireError(errorStr);
return NS_OK;
}
@ -140,7 +162,7 @@ MobileMessageCallback::NotifyMessageSent(nsISupports *aMessage)
NS_IMETHODIMP
MobileMessageCallback::NotifySendMessageFailed(int32_t aError, nsISupports *aMessage)
{
return NotifyError(aError);
return NotifyError(aError, aMessage);
}
NS_IMETHODIMP
@ -211,7 +233,7 @@ MobileMessageCallback::NotifySegmentInfoForTextGot(nsIDOMMozSmsSegmentInfo *aInf
NS_IMETHODIMP
MobileMessageCallback::NotifyGetSegmentInfoForTextFailed(int32_t aError)
{
return NotifyError(aError, true);
return NotifyError(aError, nullptr, true);
}
NS_IMETHODIMP

Просмотреть файл

@ -31,7 +31,7 @@ private:
nsresult NotifySuccess(JS::Handle<JS::Value> aResult, bool aAsync = false);
nsresult NotifySuccess(nsISupports *aMessage, bool aAsync = false);
nsresult NotifyError(int32_t aError, bool aAsync = false);
nsresult NotifyError(int32_t aError, nsISupports *aData = nullptr, bool aAsync = false);
};
} // namespace mobilemessage