Commit 505f87a5 authored by Harveer Singh's avatar Harveer Singh Committed by dsmith@mozilla.com
Browse files

Bug 2030111: Skip dispatching ScriptExecutorRunnable again if one has dispatched already. a=dsmith

parent c78fc2aa
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@ void CachePromiseHandler::ResolvedCallback(JSContext* aCx,
                                           JS::Handle<JS::Value> aValue,
                                           ErrorResult& aRv) {
  AssertIsOnMainThread();
  if (mRequestHandle->IsEmpty()) {
  // skip to schedule execution if it has been scheduled already.
  if (mRequestHandle->mExecutionScheduled) {
    return;
  }
  WorkerLoadContext* loadContext = mRequestHandle->GetContext();
@@ -75,7 +76,8 @@ void CachePromiseHandler::RejectedCallback(JSContext* aCx,
                                           JS::Handle<JS::Value> aValue,
                                           ErrorResult& aRv) {
  AssertIsOnMainThread();
  if (mRequestHandle->IsEmpty()) {
  // skip to schedule execution if it has been scheduled already.
  if (mRequestHandle->mExecutionScheduled) {
    return;
  }
  WorkerLoadContext* loadContext = mRequestHandle->GetContext();
@@ -267,6 +269,11 @@ void CacheLoadHandler::Fail(nsresult aRv) {
    mPump->Cancel(aRv);
    mPump = nullptr;
  }

  if (mRequestHandle->mExecutionScheduled) {
    return;
  }

  if (mRequestHandle->IsEmpty()) {
    return;
  }
@@ -281,8 +288,13 @@ void CacheLoadHandler::Fail(nsresult aRv) {

  loadContext->mCachePromise = nullptr;

  if (loadContext->mLoadingFinished) {
    loadContext->mLoadResult = aRv;
    mRequestHandle->MaybeExecuteFinishedScripts();
  } else {
    mRequestHandle->LoadingFinished(aRv);
  }
}

void CacheLoadHandler::Load(Cache* aCache) {
  AssertIsOnMainThread();