void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) { ActionLogScope log_scope("script runner timer"); ASSERT_UNUSED(timer, timer == &m_timer); RefPtr<Document> protect(m_document); Vector<PendingScript> scripts; scripts.swap(m_scriptsToExecuteSoon); size_t numInOrderScriptsToExecute = 0; for (; numInOrderScriptsToExecute < m_scriptsToExecuteInOrder.size() && m_scriptsToExecuteInOrder[numInOrderScriptsToExecute].cachedScript()->isLoaded(); ++numInOrderScriptsToExecute) scripts.append(m_scriptsToExecuteInOrder[numInOrderScriptsToExecute]); if (numInOrderScriptsToExecute) m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute); size_t size = scripts.size(); for (size_t i = 0; i < size; ++i) { CachedScript* cachedScript = scripts[i].cachedScript(); RefPtr<Element> element = scripts[i].releaseElementAndClear(); ScriptElement* script = toScriptElement(element.get()); ActionLogFormat(ActionLog::READ_MEMORY, "ScriptRunner-%p-%p", static_cast<void*>(this), static_cast<void*>(script)); script->execute(cachedScript); m_document->decrementLoadEventDelayCount(); } }
void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) { ASSERT(handle()->hasAuthenticationChallenge()); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); if (m_options.allowCredentials == AllowStoredCredentials) { if (m_options.crossOriginCredentialPolicy == AskClientForCrossOriginCredentials || m_frame->document()->securityOrigin()->canRequest(originalRequest().url())) { // SRL: Event action for https request. ActionLogFormat(ActionLog::ENTER_SCOPE, "auth_recv:%s", m_request.url().lastPathComponent().ascii().data()); frameLoader()->notifier()->didReceiveAuthenticationChallenge(this, challenge); ActionLogScopeEnd(); return; } } // Only these platforms provide a way to continue without credentials. // If we can't continue with credentials, we need to cancel the load altogether. #if PLATFORM(MAC) || USE(CFNETWORK) || USE(CURL) handle()->receivedRequestToContinueWithoutCredential(challenge); ASSERT(!handle()->hasAuthenticationChallenge()); #else didFail(blockedError()); #endif }
void ResourceLoader::didFail(const ResourceError& error) { if (m_cancelled) return; ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); if (FormData* data = m_request.httpBody()) data->removeGeneratedFilesIfNeeded(); if (!m_notifiedLoadComplete) { m_notifiedLoadComplete = true; // SRL: Log that an atomic action is generated with a load failure. ActionLogFormat(ActionLog::ENTER_SCOPE, "failed:%s", m_request.url().lastPathComponent().ascii().data()); if (m_options.sendLoadCallbacks == SendCallbacks) frameLoader()->notifier()->didFailToLoad(this, error); ActionLogScopeEnd(); } releaseResources(); }
void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge) { // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); // SRL: Event action for https. ActionLogFormat(ActionLog::ENTER_SCOPE, "cancel_auth:%s", m_request.url().lastPathComponent().ascii().data()); frameLoader()->notifier()->didCancelAuthenticationChallenge(this, challenge); ActionLogScopeEnd(); }
void SubresourceLoader::didReceiveResponse(const ResourceResponse& response) { ASSERT(!response.isNull()); ASSERT(m_state == Initialized); // Reference the object in this method since the additional processing can do // anything including removing the last reference to this object; one example of this is 3266216. RefPtr<SubresourceLoader> protect(this); if (m_resource->resourceToRevalidate()) { if (response.httpStatusCode() == 304) { // 304 Not modified / Use local copy // Existing resource is ok, just use it updating the expiration time. // SRL: Create a network response event action. ActionLogFormat(ActionLog::ENTER_SCOPE, "recv_304:%s", m_resource->url().lastPathComponent().ascii().data()); memoryCache()->revalidationSucceeded(m_resource, response); if (!reachedTerminalState()) ResourceLoader::didReceiveResponse(response); ActionLogScopeEnd(); return; } // Did not get 304 response, continue as a regular resource load. memoryCache()->revalidationFailed(m_resource); } m_resource->setResponse(response); if (reachedTerminalState()) return; ResourceLoader::didReceiveResponse(response); if (response.isMultipart()) { m_loadingMultipartContent = true; // We don't count multiParts in a CachedResourceLoader's request count m_requestCountTracker.clear(); if (!m_resource->isImage()) { cancel(); return; } } RefPtr<SharedBuffer> buffer = resourceData(); if (m_loadingMultipartContent && buffer && buffer->size()) { sendDataToResource(buffer->data(), buffer->size()); clearResourceData(); // Since a subresource loader does not load multipart sections progressively, data was delivered to the loader all at once. // After the first multipart section is complete, signal to delegates that this load is "finished" m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this); didFinishLoadingOnePart(0); } }
void ScriptRunner::notifyScriptReady(ScriptElement* scriptElement, ExecutionType executionType) { switch (executionType) { case ASYNC_EXECUTION: ASSERT(m_pendingAsyncScripts.contains(scriptElement)); m_scriptsToExecuteSoon.append(m_pendingAsyncScripts.take(scriptElement)); break; case IN_ORDER_EXECUTION: ASSERT(!m_scriptsToExecuteInOrder.isEmpty()); break; } ActionLogFormat(ActionLog::WRITE_MEMORY, "ScriptRunner-%p-%p", static_cast<void*>(this), static_cast<void*>(scriptElement)); m_timer.startOneShot(0); }
void ResourceLoader::didReceiveResponse(const ResourceResponse& r) { ASSERT(!m_reachedTerminalState); // Protect this in this delegate method since the additional processing can do // anything including possibly derefing this; one example of this is Radar 3266216. RefPtr<ResourceLoader> protector(this); m_response = r; if (FormData* data = m_request.httpBody()) data->removeGeneratedFilesIfNeeded(); if (m_options.sendLoadCallbacks == SendCallbacks) { ActionLogFormat(ActionLog::ENTER_SCOPE, "recv_resp:%s", m_request.url().lastPathComponent().ascii().data()); frameLoader()->notifier()->didReceiveResponse(this, m_response); ActionLogScopeEnd(); } }
void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript, ExecutionType executionType) { ASSERT(scriptElement); ASSERT(cachedScript.get()); Element* element = scriptElement->element(); ASSERT(element); ASSERT(element->inDocument()); m_document->incrementLoadEventDelayCount(); switch (executionType) { case ASYNC_EXECUTION: m_pendingAsyncScripts.add(scriptElement, PendingScript(element, cachedScript.get())); break; case IN_ORDER_EXECUTION: m_scriptsToExecuteInOrder.append(PendingScript(element, cachedScript.get())); ActionLogFormat(ActionLog::WRITE_MEMORY, "ScriptRunner-%p-%p", static_cast<void*>(this), static_cast<void*>(scriptElement)); break; } }