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

Side by Side Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 1183173002: [DevTools] Show sync XHR info during request loading. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Initialized m_pendingXHR 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 initiatorObject = it->value; 362 initiatorObject = it->value;
363 } 363 }
364 364
365 RefPtr<TypeBuilder::Network::Request> requestInfo(buildObjectForResourceRequ est(request)); 365 RefPtr<TypeBuilder::Network::Request> requestInfo(buildObjectForResourceRequ est(request));
366 366
367 if (!m_hostId.isEmpty()) 367 if (!m_hostId.isEmpty())
368 request.addHTTPHeaderField(kDevToolsEmulateNetworkConditionsClientId, At omicString(m_hostId)); 368 request.addHTTPHeaderField(kDevToolsEmulateNetworkConditionsClientId, At omicString(m_hostId));
369 369
370 TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::res ourceTypeJson(type); 370 TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::res ourceTypeJson(type);
371 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).string(), requestInfo.release(), monotonicallyIncreasingTime() , currentTime(), initiatorObject, buildObjectForResourceResponse(redirectRespons e), &resourceType); 371 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).string(), requestInfo.release(), monotonicallyIncreasingTime() , currentTime(), initiatorObject, buildObjectForResourceResponse(redirectRespons e), &resourceType);
372 if (m_pendingXHRReplayData && !m_pendingXHRReplayData->async())
373 frontend()->flush();
372 } 374 }
373 375
374 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) 376 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
375 { 377 {
376 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier) ); 378 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier) );
377 } 379 }
378 380
379 bool isResponseEmpty(PassRefPtr<TypeBuilder::Network::Response> response) 381 bool isResponseEmpty(PassRefPtr<TypeBuilder::Network::Response> response)
380 { 382 {
381 if (!response) 383 if (!response)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 } 484 }
483 485
484 void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns igned long identifier, ThreadableLoaderClient* client) 486 void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns igned long identifier, ThreadableLoaderClient* client)
485 { 487 {
486 if (!client) 488 if (!client)
487 return; 489 return;
488 490
489 if (client == m_pendingEventSource) { 491 if (client == m_pendingEventSource) {
490 m_eventSourceRequestIdMap.set(client, identifier); 492 m_eventSourceRequestIdMap.set(client, identifier);
491 m_pendingEventSource = nullptr; 493 m_pendingEventSource = nullptr;
492 return;
493 } 494 }
494 495
495 PendingXHRReplayDataMap::iterator it = m_pendingXHRReplayData.find(client); 496 if (client == m_pendingXHR) {
496 if (it == m_pendingXHRReplayData.end()) 497 String requestId = IdentifiersFactory::requestId(identifier);
497 return; 498 m_resourcesData->setResourceType(requestId, InspectorPageAgent::XHRResou rce);
498 499 m_resourcesData->setXHRReplayData(requestId, m_pendingXHRReplayData.get( ));
499 String requestId = IdentifiersFactory::requestId(identifier); 500 m_pendingXHR = nullptr;
500 m_resourcesData->setResourceType(requestId, InspectorPageAgent::XHRResource) ; 501 m_pendingXHRReplayData.clear();
501 m_resourcesData->setXHRReplayData(requestId, it->value.get()); 502 }
502 } 503 }
503 504
504 void InspectorResourceAgent::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderCl ient* client, const AtomicString& method, const KURL& url, bool async, PassRefPt r<FormData> formData, const HTTPHeaderMap& headers, bool includeCredentials) 505 void InspectorResourceAgent::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderCl ient* client, const AtomicString& method, const KURL& url, bool async, PassRefPt r<FormData> formData, const HTTPHeaderMap& headers, bool includeCredentials)
505 { 506 {
506 ASSERT(xhr); 507 ASSERT(xhr);
507 RefPtrWillBeRawPtr<XHRReplayData> xhrReplayData = XHRReplayData::create(xhr- >executionContext(), method, urlWithoutFragment(url), async, formData.get(), inc ludeCredentials); 508 m_pendingXHR = client;
509 m_pendingXHRReplayData = XHRReplayData::create(xhr->executionContext(), meth od, urlWithoutFragment(url), async, formData.get(), includeCredentials);
508 for (const auto& header : headers) 510 for (const auto& header : headers)
509 xhrReplayData->addHeader(header.key, header.value); 511 m_pendingXHRReplayData->addHeader(header.key, header.value);
510 m_pendingXHRReplayData.set(client, xhrReplayData);
511 } 512 }
512 513
513 void InspectorResourceAgent::delayedRemoveReplayXHR(XMLHttpRequest* xhr) 514 void InspectorResourceAgent::delayedRemoveReplayXHR(XMLHttpRequest* xhr)
514 { 515 {
515 if (!m_replayXHRs.contains(xhr)) 516 if (!m_replayXHRs.contains(xhr))
516 return; 517 return;
517 518
518 m_replayXHRsToBeDeleted.add(xhr); 519 m_replayXHRsToBeDeleted.add(xhr);
519 m_replayXHRs.remove(xhr); 520 m_replayXHRs.remove(xhr);
520 m_removeFinishedReplayXHRTimer.startOneShot(0, FROM_HERE); 521 m_removeFinishedReplayXHRTimer.startOneShot(0, FROM_HERE);
521 } 522 }
522 523
523 void InspectorResourceAgent::didFailXHRLoading(XMLHttpRequest* xhr, ThreadableLo aderClient* client) 524 void InspectorResourceAgent::didFailXHRLoading(XMLHttpRequest* xhr, ThreadableLo aderClient* client)
524 { 525 {
525 m_pendingXHRReplayData.remove(client); 526 m_pendingXHR = nullptr;
527 m_pendingXHRReplayData.clear();
526 528
527 // This method will be called from the XHR. 529 // This method will be called from the XHR.
528 // We delay deleting the replay XHR, as deleting here may delete the caller. 530 // We delay deleting the replay XHR, as deleting here may delete the caller.
529 delayedRemoveReplayXHR(xhr); 531 delayedRemoveReplayXHR(xhr);
530 } 532 }
531 533
532 void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLH ttpRequest* xhr, ThreadableLoaderClient* client, unsigned long identifier, Scrip tString sourceString, const AtomicString& method, const String& url) 534 void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLH ttpRequest* xhr, ThreadableLoaderClient* client, unsigned long identifier, Scrip tString sourceString, const AtomicString& method, const String& url)
533 { 535 {
534 m_pendingXHRReplayData.remove(client); 536 m_pendingXHR = nullptr;
537 m_pendingXHRReplayData.clear();
535 538
536 // See comments on |didFailXHRLoading| for why we are delaying delete. 539 // See comments on |didFailXHRLoading| for why we are delaying delete.
537 delayedRemoveReplayXHR(xhr); 540 delayedRemoveReplayXHR(xhr);
538 541
539 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) { 542 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) {
540 String message = "XHR finished loading: " + method + " \"" + url + "\"." ; 543 String message = "XHR finished loading: " + method + " \"" + url + "\"." ;
541 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(NetworkMessageSource, DebugMessageLevel, message); 544 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea te(NetworkMessageSource, DebugMessageLevel, message);
542 consoleMessage->setRequestIdentifier(identifier); 545 consoleMessage->setRequestIdentifier(identifier);
543 m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context, consoleMessage.release()); 546 m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context, consoleMessage.release());
544 } 547 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 905
903 void InspectorResourceAgent::removeFinishedReplayXHRFired(Timer<InspectorResourc eAgent>*) 906 void InspectorResourceAgent::removeFinishedReplayXHRFired(Timer<InspectorResourc eAgent>*)
904 { 907 {
905 m_replayXHRsToBeDeleted.clear(); 908 m_replayXHRsToBeDeleted.clear();
906 } 909 }
907 910
908 InspectorResourceAgent::InspectorResourceAgent(InspectorPageAgent* pageAgent) 911 InspectorResourceAgent::InspectorResourceAgent(InspectorPageAgent* pageAgent)
909 : InspectorBaseAgent<InspectorResourceAgent, InspectorFrontend::Network>("Ne twork") 912 : InspectorBaseAgent<InspectorResourceAgent, InspectorFrontend::Network>("Ne twork")
910 , m_pageAgent(pageAgent) 913 , m_pageAgent(pageAgent)
911 , m_resourcesData(adoptPtr(new NetworkResourcesData())) 914 , m_resourcesData(adoptPtr(new NetworkResourcesData()))
915 , m_pendingXHR(nullptr)
912 , m_pendingEventSource(nullptr) 916 , m_pendingEventSource(nullptr)
913 , m_isRecalculatingStyle(false) 917 , m_isRecalculatingStyle(false)
914 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 918 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
915 { 919 {
916 } 920 }
917 921
918 bool InspectorResourceAgent::shouldForceCORSPreflight() 922 bool InspectorResourceAgent::shouldForceCORSPreflight()
919 { 923 {
920 return m_state->getBoolean(ResourceAgentState::cacheDisabled); 924 return m_state->getBoolean(ResourceAgentState::cacheDisabled);
921 } 925 }
922 926
923 } // namespace blink 927 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698