mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 708546 - Use DOMError in nsIDOMSmsRequest. r=bent
--HG-- extra : rebase_source : 93e54cabbe9aa2fbb19beb3a2078f2ebdf6d1615
This commit is contained in:
parent
609b5766f3
commit
9b7de99e31
@ -5,14 +5,15 @@
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMDOMError;
|
||||
|
||||
[scriptable, builtinclass, uuid(1b24469d-cfb7-4667-aaf0-c1d17289ae7c)]
|
||||
[scriptable, builtinclass, uuid(a41765d7-6e5d-4458-b08a-993c2c60ce88)]
|
||||
interface nsIDOMMozSmsRequest : nsIDOMEventTarget
|
||||
{
|
||||
// Returns whether "processing" or "done".
|
||||
readonly attribute DOMString readyState;
|
||||
// Can be null.
|
||||
readonly attribute DOMString error;
|
||||
readonly attribute nsIDOMDOMError error;
|
||||
// Can be bool, nsIDOMSmsMessage, nsIDOMSmsIterator or null.
|
||||
readonly attribute jsval result;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsIDOMSmsCursor.h"
|
||||
#include "nsISmsRequestManager.h"
|
||||
#include "SmsManager.h"
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
|
||||
DOMCI_DATA(MozSmsRequest, mozilla::dom::sms::SmsRequest)
|
||||
|
||||
@ -26,6 +27,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SmsRequest,
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(success)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCursor)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest,
|
||||
@ -37,6 +39,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest,
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(success)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(error)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCursor)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(SmsRequest,
|
||||
@ -62,7 +65,6 @@ NS_IMPL_EVENT_HANDLER(SmsRequest, error)
|
||||
SmsRequest::SmsRequest(SmsManager* aManager)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mResultRooted(false)
|
||||
, mError(nsISmsRequestManager::SUCCESS_NO_ERROR)
|
||||
, mDone(false)
|
||||
{
|
||||
BindToOwner(aManager);
|
||||
@ -80,8 +82,7 @@ SmsRequest::Reset()
|
||||
{
|
||||
NS_ASSERTION(mDone, "mDone should be true if we try to reset!");
|
||||
NS_ASSERTION(mResult != JSVAL_VOID, "mResult should be set if we try to reset!");
|
||||
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"There should be no error if we try to reset!");
|
||||
NS_ASSERTION(!mError, "There should be no error if we try to reset!");
|
||||
|
||||
if (mResultRooted) {
|
||||
UnrootResult();
|
||||
@ -117,8 +118,7 @@ void
|
||||
SmsRequest::SetSuccess(bool aResult)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"mError shouldn't have been set!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(mResult == JSVAL_NULL, "mResult shouldn't have been set!");
|
||||
|
||||
mResult.setBoolean(aResult);
|
||||
@ -144,8 +144,7 @@ bool
|
||||
SmsRequest::SetSuccessInternal(nsISupports* aObject)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"mError shouldn't have been set!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
|
||||
|
||||
nsresult rv;
|
||||
@ -185,13 +184,30 @@ void
|
||||
SmsRequest::SetError(PRInt32 aError)
|
||||
{
|
||||
NS_PRECONDITION(!mDone, "mDone shouldn't have been set to true already!");
|
||||
NS_PRECONDITION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"mError shouldn't have been set!");
|
||||
NS_PRECONDITION(!mError, "mError shouldn't have been set!");
|
||||
NS_PRECONDITION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
|
||||
NS_PRECONDITION(aError != nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"Can't call SetError() with SUCCESS_NO_ERROR!");
|
||||
|
||||
mDone = true;
|
||||
mError = aError;
|
||||
mCursor = nsnull;
|
||||
|
||||
switch (aError) {
|
||||
case nsISmsRequestManager::NO_SIGNAL_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NoSignalError"));
|
||||
break;
|
||||
case nsISmsRequestManager::NOT_FOUND_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NotFoundError"));
|
||||
break;
|
||||
case nsISmsRequestManager::UNKNOWN_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("UnknownError"));
|
||||
break;
|
||||
case nsISmsRequestManager::INTERNAL_ERROR:
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("InternalError"));
|
||||
break;
|
||||
default: // SUCCESS_NO_ERROR is handled above.
|
||||
MOZ_ASSERT(false, "Unknown error value.");
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -207,39 +223,13 @@ SmsRequest::GetReadyState(nsAString& aReadyState)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsRequest::GetError(nsAString& aError)
|
||||
SmsRequest::GetError(nsIDOMDOMError** aError)
|
||||
{
|
||||
if (!mDone) {
|
||||
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR,
|
||||
"There should be no error if the request is still processing!");
|
||||
|
||||
SetDOMStringToNull(aError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mError == nsISmsRequestManager::SUCCESS_NO_ERROR ||
|
||||
mResult == JSVAL_VOID,
|
||||
NS_ASSERTION(mDone || !mError, "mError should be null when pending");
|
||||
NS_ASSERTION(!mError || mResult == JSVAL_VOID,
|
||||
"mResult should be void when there is an error!");
|
||||
|
||||
switch (mError) {
|
||||
case nsISmsRequestManager::SUCCESS_NO_ERROR:
|
||||
SetDOMStringToNull(aError);
|
||||
break;
|
||||
case nsISmsRequestManager::NO_SIGNAL_ERROR:
|
||||
aError.AssignLiteral("NoSignalError");
|
||||
break;
|
||||
case nsISmsRequestManager::NOT_FOUND_ERROR:
|
||||
aError.AssignLiteral("NotFoundError");
|
||||
break;
|
||||
case nsISmsRequestManager::UNKNOWN_ERROR:
|
||||
aError.AssignLiteral("UnknownError");
|
||||
break;
|
||||
case nsISmsRequestManager::INTERNAL_ERROR:
|
||||
aError.AssignLiteral("InternalError");
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unknown error value.");
|
||||
}
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ private:
|
||||
|
||||
jsval mResult;
|
||||
bool mResultRooted;
|
||||
PRInt32 mError;
|
||||
bool mDone;
|
||||
nsCOMPtr<nsIDOMDOMError> mError;
|
||||
nsCOMPtr<nsIDOMMozSmsCursor> mCursor;
|
||||
|
||||
NS_DECL_EVENT_HANDLER(success)
|
||||
|
Loading…
Reference in New Issue
Block a user