Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1201)

Unified Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 1179903003: [DevTools] Log failed XHR requests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/xmlhttprequest/XMLHttpRequest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorResourceAgent.cpp
diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp
index 34bd6a587c4c561f4a6fbc4032002ba7625bc064..650de1e84edcf863942d8c945a981f9192691ec0 100644
--- a/Source/core/inspector/InspectorResourceAgent.cpp
+++ b/Source/core/inspector/InspectorResourceAgent.cpp
@@ -497,6 +497,7 @@ void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns
String requestId = IdentifiersFactory::requestId(identifier);
m_resourcesData->setResourceType(requestId, InspectorPageAgent::XHRResource);
m_resourcesData->setXHRReplayData(requestId, m_pendingXHRReplayData.get());
+ m_xhrRequestIdMap.set(client, identifier);
m_pendingXHR = nullptr;
m_pendingXHRReplayData.clear();
}
@@ -521,30 +522,35 @@ void InspectorResourceAgent::delayedRemoveReplayXHR(XMLHttpRequest* xhr)
m_removeFinishedReplayXHRTimer.startOneShot(0, FROM_HERE);
}
-void InspectorResourceAgent::didFailXHRLoading(XMLHttpRequest* xhr, ThreadableLoaderClient* client)
+void InspectorResourceAgent::didFailXHRLoading(ExecutionContext* context, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const String& url)
{
- m_pendingXHR = nullptr;
- m_pendingXHRReplayData.clear();
+ didFinishXHRInternal(context, xhr, client, method, url, false);
+}
- // This method will be called from the XHR.
- // We delay deleting the replay XHR, as deleting here may delete the caller.
- delayedRemoveReplayXHR(xhr);
+void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const String& url)
+{
+ didFinishXHRInternal(context, xhr, client, method, url, true);
}
-void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLHttpRequest* xhr, ThreadableLoaderClient* client, unsigned long identifier, ScriptString sourceString, const AtomicString& method, const String& url)
+void InspectorResourceAgent::didFinishXHRInternal(ExecutionContext* context, XMLHttpRequest* xhr, ThreadableLoaderClient* client, const AtomicString& method, const String& url, bool success)
{
m_pendingXHR = nullptr;
m_pendingXHRReplayData.clear();
- // See comments on |didFailXHRLoading| for why we are delaying delete.
+ // This method will be called from the XHR.
+ // We delay deleting the replay XHR, as deleting here may delete the caller.
delayedRemoveReplayXHR(xhr);
- if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) {
- String message = "XHR finished loading: " + method + " \"" + url + "\".";
+ ThreadableLoaderClientRequestIdMap::iterator it = m_xhrRequestIdMap.find(client);
+
+ if (m_state->getBoolean(ResourceAgentState::monitoringXHR) && it != m_eventSourceRequestIdMap.end()) {
+ String message = (success ? "XHR finished loading: " : "XHR failed loading: ") + method + " \"" + url + "\".";
RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(NetworkMessageSource, DebugMessageLevel, message);
- consoleMessage->setRequestIdentifier(identifier);
+ consoleMessage->setRequestIdentifier(it->value);
m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context, consoleMessage.release());
}
+
+ m_xhrRequestIdMap.remove(client);
}
void InspectorResourceAgent::willSendEventSourceRequest(ThreadableLoaderClient* eventSource)
@@ -554,7 +560,7 @@ void InspectorResourceAgent::willSendEventSourceRequest(ThreadableLoaderClient*
void InspectorResourceAgent::willDispachEventSourceEvent(ThreadableLoaderClient* eventSource, const AtomicString& eventName, const AtomicString& eventId, const Vector<UChar>& data)
{
- EventSourceRequestIdMap::iterator it = m_eventSourceRequestIdMap.find(eventSource);
+ ThreadableLoaderClientRequestIdMap::iterator it = m_eventSourceRequestIdMap.find(eventSource);
if (it == m_eventSourceRequestIdMap.end())
return;
frontend()->eventSourceMessageReceived(IdentifiersFactory::requestId(it->value), monotonicallyIncreasingTime(), eventName.string(), eventId.string(), String(data));
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | Source/core/xmlhttprequest/XMLHttpRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698