зеркало из https://github.com/mozilla/gecko-dev.git
Bug 852134 - simplify rooting and unrooting of SMS. r=smaug
This commit is contained in:
Родитель
eee669680d
Коммит
409625bfdf
|
@ -42,9 +42,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
if (tmp->mResultRooted) {
|
||||
tmp->UnrootResult();
|
||||
}
|
||||
tmp->mResult = JSVAL_VOID;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCursor)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
@ -90,7 +88,6 @@ SmsRequest::Create(SmsRequestParent* aRequestParent)
|
|||
|
||||
SmsRequest::SmsRequest(SmsManager* aManager)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mResultRooted(false)
|
||||
, mDone(false)
|
||||
, mParentAlive(false)
|
||||
, mParent(nullptr)
|
||||
|
@ -100,7 +97,6 @@ SmsRequest::SmsRequest(SmsManager* aManager)
|
|||
|
||||
SmsRequest::SmsRequest(MobileMessageManager* aManager)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mResultRooted(false)
|
||||
, mDone(false)
|
||||
, mParentAlive(false)
|
||||
, mParent(nullptr)
|
||||
|
@ -110,7 +106,6 @@ SmsRequest::SmsRequest(MobileMessageManager* aManager)
|
|||
|
||||
SmsRequest::SmsRequest(SmsRequestParent* aRequestParent)
|
||||
: mResult(JSVAL_VOID)
|
||||
, mResultRooted(false)
|
||||
, mDone(false)
|
||||
, mParentAlive(true)
|
||||
, mParent(aRequestParent)
|
||||
|
@ -120,9 +115,8 @@ SmsRequest::SmsRequest(SmsRequestParent* aRequestParent)
|
|||
|
||||
SmsRequest::~SmsRequest()
|
||||
{
|
||||
if (mResultRooted) {
|
||||
UnrootResult();
|
||||
}
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, SmsRequest);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -132,31 +126,10 @@ SmsRequest::Reset()
|
|||
NS_ASSERTION(mResult != JSVAL_VOID, "mResult should be set if we try to reset!");
|
||||
NS_ASSERTION(!mError, "There should be no error if we try to reset!");
|
||||
|
||||
if (mResultRooted) {
|
||||
UnrootResult();
|
||||
}
|
||||
|
||||
mResult = JSVAL_VOID;
|
||||
mDone = false;
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::RootResult()
|
||||
{
|
||||
NS_ASSERTION(!mResultRooted, "Don't call RootResult() if already rooted!");
|
||||
NS_HOLD_JS_OBJECTS(this, SmsRequest);
|
||||
mResultRooted = true;
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::UnrootResult()
|
||||
{
|
||||
NS_ASSERTION(mResultRooted, "Don't call UnrotResult() if not rooted!");
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, SmsRequest);
|
||||
mResultRooted = false;
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::SetSuccess(nsIDOMMozSmsMessage* aMessage)
|
||||
{
|
||||
|
@ -218,10 +191,10 @@ SmsRequest::SetSuccessInternal(nsISupports* aObject)
|
|||
JSAutoRequest ar(cx);
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
RootResult();
|
||||
NS_HOLD_JS_OBJECTS(this, SmsRequest);
|
||||
|
||||
if (NS_FAILED(nsContentUtils::WrapNative(cx, global, aObject, &mResult))) {
|
||||
UnrootResult();
|
||||
mResult = JSVAL_VOID;
|
||||
SetError(nsIMobileMessageCallback::INTERNAL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -91,16 +91,6 @@ private:
|
|||
|
||||
nsresult SendMessageReply(const mobilemessage::MessageReply& aReply);
|
||||
|
||||
/**
|
||||
* Root mResult (JS::Value) to prevent garbage collection.
|
||||
*/
|
||||
void RootResult();
|
||||
|
||||
/**
|
||||
* Unroot mResult (JS::Value) to allow garbage collection.
|
||||
*/
|
||||
void UnrootResult();
|
||||
|
||||
/**
|
||||
* Set the object in a success state with the result being aMessage.
|
||||
*/
|
||||
|
@ -140,7 +130,6 @@ private:
|
|||
nsresult NotifyError(int32_t aError);
|
||||
|
||||
JS::Value mResult;
|
||||
bool mResultRooted;
|
||||
bool mDone;
|
||||
bool mParentAlive;
|
||||
mobilemessage::SmsRequestParent* mParent;
|
||||
|
|
Загрузка…
Ссылка в новой задаче