void DocumentLoader::startLoadingMainResource() { m_mainDocumentError = ResourceError(); timing()->markNavigationStart(); ASSERT(!m_mainResourceLoader); if (maybeLoadEmpty()) return; m_mainResourceLoader = MainResourceLoader::create(this); // FIXME: Is there any way the extra fields could have not been added by now? // If not, it would be great to remove this line of code. // Note that currently, some requests may have incorrect extra fields even if this function has been called, // because we pass a wrong loadType (see FIXME in addExtraFieldsToMainResourceRequest()). frameLoader()->addExtraFieldsToMainResourceRequest(m_request); m_mainResourceLoader->load(m_request, m_substituteData); if (m_request.isNull()) { m_mainResourceLoader = 0; // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost // is now in a state where starting an empty load will be inconsistent. Replace it with // a new ApplicationCacheHost. m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this)); maybeLoadEmpty(); } }
void DocumentLoader::startLoadingMainResource() { timing().markNavigationStart(); ASSERT(!m_mainResource); ASSERT(m_state == NotStarted); m_state = Provisional; if (maybeLoadEmpty()) return; ASSERT(timing().navigationStart()); ASSERT(!timing().fetchStart()); timing().markFetchStart(); DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext)); FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions); m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); if (!m_mainResource) { m_request = ResourceRequest(blankURL()); maybeLoadEmpty(); return; } // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. // Even when using a cached resource, we may make some modification to the request, e.g. adding the referer header. m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); m_mainResource->addClient(this); }
void DocumentLoader::startLoadingMainResource() { m_mainDocumentError = ResourceError(); timing()->markNavigationStart(); ASSERT(!m_mainResource); ASSERT(!m_loadingMainResource); m_loadingMainResource = true; if (maybeLoadEmpty()) return; ASSERT(timing()->navigationStart()); ASSERT(!timing()->fetchStart()); timing()->markFetchStart(); willSendRequest(m_request, ResourceResponse()); // willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest. if (!m_frame || m_request.isNull()) return; m_applicationCacheHost->willStartLoadingMainResource(m_request); prepareSubframeArchiveLoadIfNeeded(); if (m_substituteData.isValid()) { m_identifierForLoadWithoutResourceLoader = createUniqueIdentifier(); frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse()); handleSubstituteDataLoadSoon(); return; } ResourceRequest request(m_request); DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, (SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck, CheckContentSecurityPolicy, UseDefaultOriginRestrictionsForType)); CachedResourceRequest cachedResourceRequest(request, cachedResourceRequestInitiators().document, mainResourceLoadOptions); m_mainResource = m_cachedResourceLoader->requestMainResource(cachedResourceRequest); if (!m_mainResource) { setRequest(ResourceRequest()); // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost // is now in a state where starting an empty load will be inconsistent. Replace it with // a new ApplicationCacheHost. m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this)); maybeLoadEmpty(); return; } m_mainResource->addClient(this); // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. if (mainResourceLoader()) request = mainResourceLoader()->originalRequest(); // If there was a fragment identifier on m_request, the cache will have stripped it. m_request should include // the fragment identifier, so add that back in. if (equalIgnoringFragmentIdentifier(m_request.url(), request.url())) request.setURL(m_request.url()); setRequest(request); }
void DocumentLoader::startLoadingMainResource() { RefPtr<DocumentLoader> protect(this); m_mainDocumentError = ResourceError(); timing()->markNavigationStart(); ASSERT(!m_mainResource); ASSERT(!m_loadingMainResource); m_loadingMainResource = true; if (maybeLoadEmpty()) return; ASSERT(timing()->navigationStart()); ASSERT(!timing()->fetchStart()); timing()->markFetchStart(); willSendRequest(m_request, ResourceResponse()); // willSendRequest() may lead to our LocalFrame being detached or cancelling the load via nulling the ResourceRequest. if (!m_frame || m_request.isNull()) return; m_applicationCacheHost->willStartLoadingMainResource(m_request); prepareSubframeArchiveLoadIfNeeded(); ResourceRequest request(m_request); DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext)); FetchRequest cachedResourceRequest(request, FetchInitiatorTypeNames::document, mainResourceLoadOptions); m_mainResource = m_fetcher->fetchMainResource(cachedResourceRequest, m_substituteData); if (!m_mainResource) { m_request = ResourceRequest(); // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost // is now in a state where starting an empty load will be inconsistent. Replace it with // a new ApplicationCacheHost. m_applicationCacheHost = ApplicationCacheHost::create(this); maybeLoadEmpty(); return; } m_mainResource->addClient(this); // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. if (mainResourceLoader()) request = mainResourceLoader()->originalRequest(); // If there was a fragment identifier on m_request, the cache will have stripped it. m_request should include // the fragment identifier, so add that back in. if (equalIgnoringFragmentIdentifier(m_request.url(), request.url())) request.setURL(m_request.url()); m_request = request; }
void DocumentLoader::startLoadingMainResource() { timing().markNavigationStart(); DCHECK(!m_mainResource); DCHECK_EQ(m_state, NotStarted); m_state = Provisional; if (maybeLoadEmpty()) return; DCHECK(timing().navigationStart()); // PlzNavigate: // The fetch has already started in the browser. Don't mark it again. if (!m_frame->settings()->browserSideNavigationEnabled()) { DCHECK(!timing().fetchStart()); timing().markFetchStart(); } DEFINE_STATIC_LOCAL( ResourceLoaderOptions, mainResourceLoadOptions, (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext)); FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions); m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); // PlzNavigate: // The final access checks are still performed here, potentially rejecting // the "provisional" load, but the browser side already expects the renderer // to be able to unconditionally commit. if (!m_mainResource || (m_frame->settings()->browserSideNavigationEnabled() && m_mainResource->errorOccurred())) { m_request = ResourceRequest(blankURL()); maybeLoadEmpty(); return; } // A bunch of headers are set when the underlying resource load begins, and // m_request needs to include those. Even when using a cached resource, we may // make some modification to the request, e.g. adding the referer header. m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); m_mainResource->addClient(this); }