Ejemplo n.º 1
0
void DocumentLoader::finishedLoading(double finishTime) {
  DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() ||
         !m_frame->page()->defersLoading() ||
         InspectorInstrumentation::isDebuggerPaused(m_frame));

  double responseEndTime = finishTime;
  if (!responseEndTime)
    responseEndTime = m_timeOfLastDataReceived;
  if (!responseEndTime)
    responseEndTime = monotonicallyIncreasingTime();
  timing().setResponseEnd(responseEndTime);

  commitIfReady();
  if (!frameLoader())
    return;

  if (!maybeCreateArchive()) {
    // If this is an empty document, it will not have actually been created yet.
    // Commit dummy data so that DocumentWriter::begin() gets called and creates
    // the Document.
    if (!m_writer)
      commitData(0, 0);
  }

  if (!m_frame)
    return;

  m_applicationCacheHost->finishedLoadingMainResource();
  endWriting();
  if (m_state < MainResourceDone)
    m_state = MainResourceDone;
  clearMainResourceHandle();
}
Ejemplo n.º 2
0
DocumentLoader::~DocumentLoader()
{
    ASSERT(!m_frame || !isLoading());
    m_fetcher->clearDocumentLoader();
    clearMainResourceHandle();
    m_applicationCacheHost->dispose();
}
Ejemplo n.º 3
0
void DocumentLoader::mainReceivedError(const ResourceError& error)
{
    ASSERT(!error.isNull());
    ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame));
    m_applicationCacheHost->failedLoadingMainResource();
    if (!frameLoader())
        return;
    setMainDocumentError(error);
    clearMainResourceLoader();
    frameLoader()->receivedMainResourceError(this, error);
    clearMainResourceHandle();
}
Ejemplo n.º 4
0
void DocumentLoader::notifyFinished(Resource* resource) {
  DCHECK_EQ(m_mainResource, resource);
  DCHECK(m_mainResource);

  if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
    finishedLoading(m_mainResource->loadFinishTime());
    return;
  }

  if (m_applicationCacheHost)
    m_applicationCacheHost->failedLoadingMainResource();
  m_state = MainResourceDone;
  frameLoader()->loadFailed(this, m_mainResource->resourceError());
  clearMainResourceHandle();
}
Ejemplo n.º 5
0
void DocumentLoader::finishedLoading(double finishTime)
{
    ASSERT(!m_frame->page()->defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame));

    RefPtr<DocumentLoader> protect(this);

    if (m_identifierForLoadWithoutResourceLoader) {
        frameLoader()->notifier()->dispatchDidFinishLoading(this, m_identifierForLoadWithoutResourceLoader, finishTime);
        m_identifierForLoadWithoutResourceLoader = 0;
    }

    double responseEndTime = finishTime;
    if (!responseEndTime)
        responseEndTime = m_timeOfLastDataReceived;
    if (!responseEndTime)
        responseEndTime = monotonicallyIncreasingTime();
    timing()->setResponseEnd(responseEndTime);

    commitIfReady();
    if (!frameLoader())
        return;

    if (!maybeCreateArchive()) {
        // If this is an empty document, it will not have actually been created yet. Commit dummy data so that
        // DocumentWriter::begin() gets called and creates the Document.
        if (!m_gotFirstByte)
            commitData(0, 0);
        frameLoader()->client()->finishedLoading(this);
    }

    m_writer.end();
    if (!m_mainDocumentError.isNull())
        return;
    clearMainResourceLoader();
    if (!frameLoader()->stateMachine()->creatingInitialEmptyDocument())
        frameLoader()->checkLoadComplete();

    // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
    // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
    if (m_frame) {
        if (m_mainResource && m_frame->document()->hasManifest())
            memoryCache()->remove(m_mainResource.get());
    }
    m_applicationCacheHost->finishedLoadingMainResource();
    clearMainResourceHandle();
}
Ejemplo n.º 6
0
void DocumentLoader::detachFromFrame() {
  DCHECK(m_frame);

  // It never makes sense to have a document loader that is detached from its
  // frame have any loads active, so go ahead and kill all the loads.
  m_fetcher->stopFetching();

  // If that load cancellation triggered another detach, leave.
  // (fast/frames/detach-frame-nested-no-crash.html is an example of this.)
  if (!m_frame)
    return;

  m_fetcher->clearContext();
  m_applicationCacheHost->detachFromDocumentLoader();
  m_applicationCacheHost.clear();
  WeakIdentifierMap<DocumentLoader>::notifyObjectDestroyed(this);
  clearMainResourceHandle();
  m_frame = nullptr;
}
Ejemplo n.º 7
0
void DocumentLoader::mainReceivedError(const ResourceError& error)
{
    ASSERT(!error.isNull());
    if (m_identifierForLoadWithoutResourceLoader) {
        ASSERT(!mainResourceLoader());
        frameLoader()->client()->dispatchDidFailLoading(this, m_identifierForLoadWithoutResourceLoader, error);
    }

    ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());

    m_applicationCacheHost->failedLoadingMainResource();

    if (!frameLoader())
        return;
    setMainDocumentError(error);
    clearMainResourceLoader();
    frameLoader()->receivedMainResourceError(error);
    clearMainResourceHandle();
}
Ejemplo n.º 8
0
void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied(const ResourceResponse& response)
{
    InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, mainResourceIdentifier(), response, m_mainResource.get());

    setWasBlockedAfterXFrameOptionsOrCSP();

    // Pretend that this was an empty HTTP 200 response.  Don't reuse the
    // original URL for the empty page (https://crbug.com/622385).
    //
    // TODO(mkwst):  Remove this once XFO moves to the browser.
    // https://crbug.com/555418.
    clearMainResourceHandle();
    KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin();
    m_originalRequest.setURL(blockedURL);
    m_request.setURL(blockedURL);
    m_redirectChain.removeLast();
    appendRedirect(blockedURL);
    m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String());
    finishedLoading(monotonicallyIncreasingTime());

    return;
}
Ejemplo n.º 9
0
DocumentLoader::~DocumentLoader()
{
    ASSERT(!m_frame || !isLoading());
    m_fetcher->clearDocumentLoader();
    clearMainResourceHandle();
}
Ejemplo n.º 10
0
DocumentLoader::~DocumentLoader()
{
    ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !isLoading());
    m_cachedResourceLoader->clearDocumentLoader();
    clearMainResourceHandle();
}