Commit ffec9b27 authored by Simon Giesecke's avatar Simon Giesecke
Browse files

Bug 1168606 - Set flag to invalidate in-flight responses as well. r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D52559

--HG--
extra : moz-landing-system : lando
parent 3de7ff85
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -3261,7 +3261,8 @@ BackgroundCursorChild::BackgroundCursorChild(IDBRequest* aRequest,
      mIndex(nullptr),
      mCursor(nullptr),
      mStrongRequest(aRequest),
      mDirection(aDirection) {
      mDirection(aDirection),
      mInFlightResponseInvalidationNeeded(false) {
  MOZ_ASSERT(aObjectStore);
  aObjectStore->AssertIsOnOwningThread();
  MOZ_ASSERT(mTransaction);
@@ -3278,7 +3279,8 @@ BackgroundCursorChild::BackgroundCursorChild(IDBRequest* aRequest,
      mIndex(aIndex),
      mCursor(nullptr),
      mStrongRequest(aRequest),
      mDirection(aDirection) {
      mDirection(aDirection),
      mInFlightResponseInvalidationNeeded(false) {
  MOZ_ASSERT(aIndex);
  aIndex->AssertIsOnOwningThread();
  MOZ_ASSERT(mTransaction);
@@ -3496,6 +3498,19 @@ void BackgroundCursorChild::InvalidateCachedResponses() {
      mCachedResponses.size());

  mCachedResponses.clear();

  // We only hold a strong cursor reference in mStrongCursor when
  // continue()/similar has been called. In those cases we expect a response
  // that will be received in the future, and it may include prefetched data
  // that needs to be discarded.
  if (mStrongCursor) {
    IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
        "PRELOAD: Setting flag to invalidate in-flight responses",
        "Set flag to invalidate in-flight responses",
        mTransaction->LoggingSerialNumber(), mRequest->LoggingSerialNumber());

    mInFlightResponseInvalidationNeeded = true;
  }
}

template <typename Condition>
@@ -3601,6 +3616,17 @@ void BackgroundCursorChild::HandleMultipleCursorResponses(
    // need to be cached.
    aHandleRecord(/* aUseAsCurrentResult */ isFirst, response);
    isFirst = false;

    if (mInFlightResponseInvalidationNeeded) {
      IDB_LOG_MARK_CHILD_TRANSACTION_REQUEST(
          "PRELOAD: Discarding remaining responses since "
          "mInFlightResponseInvalidationNeeded is set",
          "Discarding responses", mTransaction->LoggingSerialNumber(),
          mRequest->LoggingSerialNumber());

      mInFlightResponseInvalidationNeeded = false;
      break;
    }
  }

  ResultHelper helper(mRequest, mTransaction, mCursor);
+1 −0
Original line number Diff line number Diff line
@@ -658,6 +658,7 @@ class BackgroundCursorChild final : public PBackgroundIDBCursorChild {
  NS_DECL_OWNINGTHREAD

  std::deque<CachedResponse> mCachedResponses, mDelayedResponses;
  bool mInFlightResponseInvalidationNeeded;

 public:
  BackgroundCursorChild(IDBRequest* aRequest, IDBObjectStore* aObjectStore,