Backed out changeset 716ba77a9d0a (bug 967005) for ASAN m-4 failures

This commit is contained in:
Wes Kocher 2014-03-11 17:23:35 -07:00
Родитель 7abcfeca0b
Коммит 7bce447ef8
2 изменённых файлов: 4 добавлений и 78 удалений

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

@ -185,10 +185,11 @@ public:
NS_IMPL_CYCLE_COLLECTION_CLASS(Promise)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Promise)
tmp->MaybeReportRejectedOnce();
tmp->MaybeReportRejected();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mResolveCallbacks);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRejectCallbacks);
tmp->mResult = JS::UndefinedValue();
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -228,7 +229,8 @@ Promise::Promise(nsIGlobalObject* aGlobal)
Promise::~Promise()
{
MaybeReportRejectedOnce();
MaybeReportRejected();
mResult = JS::UndefinedValue();
mozilla::DropJSObjects(this);
}
@ -820,9 +822,6 @@ Promise::AppendCallbacks(PromiseCallback* aResolveCallback,
if (aRejectCallback) {
mHadRejectCallback = true;
mRejectCallbacks.AppendElement(aRejectCallback);
// Now that there is a callback, we don't need to report anymore.
RemoveFeature();
}
// If promise's state is resolved, queue a task to process our resolve
@ -1059,47 +1058,9 @@ Promise::RunResolveTask(JS::Handle<JS::Value> aValue,
SetResult(aValue);
SetState(aState);
// If the Promise was rejected, and there is no reject handler already setup,
// watch for thread shutdown.
if (aState == PromiseState::Rejected &&
!mHadRejectCallback &&
!NS_IsMainThread()) {
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(worker);
worker->AssertIsOnWorkerThread();
mFeature = new PromiseReportRejectFeature(this);
if (NS_WARN_IF(!worker->AddFeature(worker->GetJSContext(), mFeature))) {
// Worker is shutting down, report rejection immediately since it is
// unlikely that reject callbacks will be added after this point.
MaybeReportRejected();
}
}
RunTask();
}
void
Promise::RemoveFeature()
{
if (mFeature) {
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(worker);
worker->RemoveFeature(worker->GetJSContext(), mFeature);
mFeature = nullptr;
}
}
bool
PromiseReportRejectFeature::Notify(JSContext* aCx, workers::Status aStatus)
{
MOZ_ASSERT(aStatus > workers::Running);
mPromise->MaybeReportRejectedOnce();
mPromise = nullptr;
return true;
}
bool
Promise::ArgumentToJSValue(const nsAString& aArgument,
JSContext* aCx,

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

@ -18,8 +18,6 @@
#include "nsAutoPtr.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
class nsIGlobalObject;
namespace mozilla {
@ -30,23 +28,6 @@ class PromiseCallback;
class PromiseInit;
class PromiseNativeHandler;
class Promise;
class PromiseReportRejectFeature : public workers::WorkerFeature
{
// The Promise that owns this feature.
Promise* mPromise;
public:
PromiseReportRejectFeature(Promise* aPromise)
: mPromise(aPromise)
{
MOZ_ASSERT(mPromise);
}
virtual bool
Notify(JSContext* aCx, workers::Status aStatus) MOZ_OVERRIDE;
};
class Promise MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
@ -54,7 +35,6 @@ class Promise MOZ_FINAL : public nsISupports,
friend class PromiseResolverMixin;
friend class PromiseResolverTask;
friend class PromiseTask;
friend class PromiseReportRejectFeature;
friend class RejectPromiseCallback;
friend class ResolvePromiseCallback;
friend class WorkerPromiseResolverTask;
@ -177,15 +157,8 @@ private:
// If we have been rejected and our mResult is a JS exception,
// report it to the error console.
// Use MaybeReportRejectedOnce() for actual calls.
void MaybeReportRejected();
void MaybeReportRejectedOnce() {
MaybeReportRejected();
RemoveFeature();
mResult = JS::UndefinedValue();
}
void MaybeResolveInternal(JSContext* aCx,
JS::Handle<JS::Value> aValue,
PromiseTaskSync aSync = AsyncTask);
@ -298,8 +271,6 @@ private:
void HandleException(JSContext* aCx);
void RemoveFeature();
nsRefPtr<nsIGlobalObject> mGlobal;
nsTArray<nsRefPtr<PromiseCallback> > mResolveCallbacks;
@ -311,12 +282,6 @@ private:
bool mHadRejectCallback;
bool mResolvePending;
// If a rejected promise on a worker has no reject callbacks attached, it
// needs to know when the worker is shutting down, to report the error on the
// console before the worker's context is deleted. This feature is used for
// that purpose.
nsAutoPtr<PromiseReportRejectFeature> mFeature;
};
} // namespace dom