예제 #1
0
NS_IMETHODIMP
nsWyciwygChannel::OnStopRequest(nsIRequest *request, nsISupports *ctx, nsresult status)
{
    LOG(("nsWyciwygChannel::OnStopRequest [this=%p request=%x status=%d\n",
         this, request, status));

    if (NS_SUCCEEDED(mStatus))
        mStatus = status;

    mListener->OnStopRequest(this, mListenerContext, mStatus);
    mListener = 0;
    mListenerContext = 0;

    if (mLoadGroup)
        mLoadGroup->RemoveRequest(this, nullptr, mStatus);

    CloseCacheEntry(mStatus);
    mPump = 0;
    mIsPending = false;

    // Drop notification callbacks to prevent cycles.
    mCallbacks = 0;
    mProgressSink = 0;

    return NS_OK;
}
예제 #2
0
//////////////////////////////////////////////////////////////////////////////
// nsICachelistener
//////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor * aCacheEntry, nsCacheAccessMode aMode, nsresult aStatus)
{
  LOG(("nsWyciwygChannel::OnCacheEntryAvailable [this=%x entry=%x "
       "access=%x status=%x]\n", this, aCacheEntry, aMode, aStatus));

  // if the channel's already fired onStopRequest, 
  // then we should ignore this event.
  if (!mIsPending)
    return NS_OK;

  // otherwise, we have to handle this event.
  if (NS_SUCCEEDED(aStatus))
    mCacheEntry = aCacheEntry;
  else if (NS_SUCCEEDED(mStatus))
    mStatus = aStatus;

  nsresult rv;
  if (NS_FAILED(mStatus)) {
    LOG(("channel was canceled [this=%x status=%x]\n", this, mStatus));
    rv = mStatus;
  }
  else { // advance to the next state...
    rv = ReadFromCache();
  }

  // a failure from Connect means that we have to abort the channel.
  if (NS_FAILED(rv)) {
    CloseCacheEntry(rv);

    NotifyListener();
  }

  return NS_OK;
}
예제 #3
0
//////////////////////////////////////////////////////////////////////////////
// nsICachelistener
//////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor * aCacheEntry, nsCacheAccessMode aMode, nsresult aStatus)
{
  LOG(("nsWyciwygChannel::OnCacheEntryAvailable [this=%x entry=%x "
       "access=%x status=%x]\n", this, aCacheEntry, aMode, aStatus));

  // if the channel's already fired onStopRequest, 
  // then we should ignore this event.
  if (!mIsPending)
    return NS_OK;

  // otherwise, we have to handle this event.
  if (NS_SUCCEEDED(aStatus))
    mCacheEntry = aCacheEntry;
  else if (NS_SUCCEEDED(mStatus))
    mStatus = aStatus;

  nsresult rv;
  if (NS_FAILED(mStatus)) {
    LOG(("channel was canceled [this=%x status=%x]\n", this, mStatus));
    rv = mStatus;
  }
  else { // advance to the next state...
    rv = ReadFromCache();
  }

  // a failure from Connect means that we have to abort the channel.
  if (NS_FAILED(rv)) {
    CloseCacheEntry(rv);

    if (mListener) {
      mListener->OnStartRequest(this, mListenerContext);
      mListener->OnStopRequest(this, mListenerContext, mStatus);
      mListener = 0;
      mListenerContext = 0;
    }

    mIsPending = PR_FALSE;

    // Remove ourselves from the load group.
    if (mLoadGroup)
      mLoadGroup->RemoveRequest(this, nsnull, mStatus);
  }

  return NS_OK;
}
예제 #4
0
NS_IMETHODIMP
nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntry *aCacheEntry,
                                        bool aNew,
                                        nsIApplicationCache* aAppCache,
                                        nsresult aStatus)
{
    LOG(("nsWyciwygChannel::OnCacheEntryAvailable [this=%p entry=%p "
         "new=%d status=%x]\n", this, aCacheEntry, aNew, aStatus));

    // if the channel's already fired onStopRequest,
    // then we should ignore this event.
    if (!mIsPending && !aNew)
        return NS_OK;

    // otherwise, we have to handle this event.
    if (NS_SUCCEEDED(aStatus))
        mCacheEntry = aCacheEntry;
    else if (NS_SUCCEEDED(mStatus))
        mStatus = aStatus;

    nsresult rv = NS_OK;
    if (NS_FAILED(mStatus)) {
        LOG(("channel was canceled [this=%p status=%x]\n", this, mStatus));
        rv = mStatus;
    }
    else if (!aNew) { // advance to the next state...
        rv = ReadFromCache();
    }

    // a failure from Connect means that we have to abort the channel.
    if (NS_FAILED(rv)) {
        CloseCacheEntry(rv);

        if (!aNew) {
            // Since OnCacheEntryAvailable can be called directly from AsyncOpen
            // we must dispatch.
            NS_DispatchToCurrentThread(NS_NewRunnableMethod(
                                           this, &nsWyciwygChannel::NotifyListener));
        }
    }

    return NS_OK;
}