зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0ae1b3474b22 (bug 982726)
This commit is contained in:
Родитель
9d66a5184e
Коммит
a6cf71fdfd
|
@ -45,8 +45,6 @@ namespace {
|
|||
// keeping the worker alive.
|
||||
class PromiseHolder MOZ_FINAL : public WorkerFeature
|
||||
{
|
||||
friend class GetServicedRunnable;
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PromiseHolder)
|
||||
|
||||
public:
|
||||
|
@ -54,7 +52,6 @@ public:
|
|||
Promise* aPromise)
|
||||
: mWorkerPrivate(aWorkerPrivate),
|
||||
mPromise(aPromise),
|
||||
mCleanUpLock("promiseHolderCleanUpLock"),
|
||||
mClean(false)
|
||||
{
|
||||
MOZ_ASSERT(mWorkerPrivate);
|
||||
|
@ -71,7 +68,7 @@ public:
|
|||
}
|
||||
|
||||
Promise*
|
||||
GetPromise() const
|
||||
Get() const
|
||||
{
|
||||
return mPromise;
|
||||
}
|
||||
|
@ -81,7 +78,6 @@ public:
|
|||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
MutexAutoLock lock(mCleanUpLock);
|
||||
if (mClean) {
|
||||
return;
|
||||
}
|
||||
|
@ -112,11 +108,6 @@ private:
|
|||
WorkerPrivate* mWorkerPrivate;
|
||||
nsRefPtr<Promise> mPromise;
|
||||
|
||||
// Used to prevent race conditions on |mClean| and to ensure that either a
|
||||
// Notify() call or a dispatch back to the worker thread occurs before
|
||||
// this object is released.
|
||||
Mutex mCleanUpLock;
|
||||
|
||||
bool mClean;
|
||||
};
|
||||
|
||||
|
@ -142,7 +133,7 @@ public:
|
|||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
Promise* promise = mPromiseHolder->GetPromise();
|
||||
Promise* promise = mPromiseHolder->Get();
|
||||
MOZ_ASSERT(promise);
|
||||
|
||||
nsTArray<nsRefPtr<ServiceWorkerClient>> ret;
|
||||
|
@ -163,18 +154,18 @@ public:
|
|||
class GetServicedRunnable MOZ_FINAL : public nsRunnable
|
||||
{
|
||||
WorkerPrivate* mWorkerPrivate;
|
||||
nsRefPtr<PromiseHolder> mPromiseHolder;
|
||||
nsCString mScope;
|
||||
nsRefPtr<PromiseHolder> mPromiseHolder;
|
||||
public:
|
||||
GetServicedRunnable(WorkerPrivate* aWorkerPrivate,
|
||||
PromiseHolder* aPromiseHolder,
|
||||
Promise* aPromise,
|
||||
const nsCString& aScope)
|
||||
: mWorkerPrivate(aWorkerPrivate),
|
||||
mPromiseHolder(aPromiseHolder),
|
||||
mScope(aScope)
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
mPromiseHolder = new PromiseHolder(aWorkerPrivate, aPromise);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
|
@ -182,12 +173,6 @@ public:
|
|||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
MutexAutoLock lock(mPromiseHolder->mCleanUpLock);
|
||||
if (mPromiseHolder->mClean) {
|
||||
// Don't resolve the promise if it was already released.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
nsAutoPtr<nsTArray<uint64_t>> result(new nsTArray<uint64_t>());
|
||||
|
||||
|
@ -218,17 +203,8 @@ ServiceWorkerClients::GetServiced(ErrorResult& aRv)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<PromiseHolder> promiseHolder = new PromiseHolder(workerPrivate,
|
||||
promise);
|
||||
if (!promiseHolder->GetPromise()) {
|
||||
// Don't dispatch if adding the worker feature failed.
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
nsRefPtr<GetServicedRunnable> r =
|
||||
new GetServicedRunnable(workerPrivate,
|
||||
promiseHolder,
|
||||
NS_ConvertUTF16toUTF8(scope));
|
||||
new GetServicedRunnable(workerPrivate, promise, NS_ConvertUTF16toUTF8(scope));
|
||||
nsresult rv = NS_DispatchToMainThread(r);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче