| OLD | NEW |
| 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 Loading... |
| 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(); | |
| 374 } | 372 } |
| 375 | 373 |
| 376 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) | 374 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) |
| 377 { | 375 { |
| 378 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier)
); | 376 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier)
); |
| 379 } | 377 } |
| 380 | 378 |
| 381 bool isResponseEmpty(PassRefPtr<TypeBuilder::Network::Response> response) | 379 bool isResponseEmpty(PassRefPtr<TypeBuilder::Network::Response> response) |
| 382 { | 380 { |
| 383 if (!response) | 381 if (!response) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 482 } |
| 485 | 483 |
| 486 void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns
igned long identifier, ThreadableLoaderClient* client) | 484 void InspectorResourceAgent::documentThreadableLoaderStartedLoadingForClient(uns
igned long identifier, ThreadableLoaderClient* client) |
| 487 { | 485 { |
| 488 if (!client) | 486 if (!client) |
| 489 return; | 487 return; |
| 490 | 488 |
| 491 if (client == m_pendingEventSource) { | 489 if (client == m_pendingEventSource) { |
| 492 m_eventSourceRequestIdMap.set(client, identifier); | 490 m_eventSourceRequestIdMap.set(client, identifier); |
| 493 m_pendingEventSource = nullptr; | 491 m_pendingEventSource = nullptr; |
| 492 return; |
| 494 } | 493 } |
| 495 | 494 |
| 496 if (client == m_pendingXHR) { | 495 PendingXHRReplayDataMap::iterator it = m_pendingXHRReplayData.find(client); |
| 497 String requestId = IdentifiersFactory::requestId(identifier); | 496 if (it == m_pendingXHRReplayData.end()) |
| 498 m_resourcesData->setResourceType(requestId, InspectorPageAgent::XHRResou
rce); | 497 return; |
| 499 m_resourcesData->setXHRReplayData(requestId, m_pendingXHRReplayData.get(
)); | 498 |
| 500 m_pendingXHR = nullptr; | 499 String requestId = IdentifiersFactory::requestId(identifier); |
| 501 m_pendingXHRReplayData.clear(); | 500 m_resourcesData->setResourceType(requestId, InspectorPageAgent::XHRResource)
; |
| 502 } | 501 m_resourcesData->setXHRReplayData(requestId, it->value.get()); |
| 503 } | 502 } |
| 504 | 503 |
| 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) | 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) |
| 506 { | 505 { |
| 507 ASSERT(xhr); | 506 ASSERT(xhr); |
| 508 m_pendingXHR = client; | 507 RefPtrWillBeRawPtr<XHRReplayData> xhrReplayData = XHRReplayData::create(xhr-
>executionContext(), method, urlWithoutFragment(url), async, formData.get(), inc
ludeCredentials); |
| 509 m_pendingXHRReplayData = XHRReplayData::create(xhr->executionContext(), meth
od, urlWithoutFragment(url), async, formData.get(), includeCredentials); | |
| 510 for (const auto& header : headers) | 508 for (const auto& header : headers) |
| 511 m_pendingXHRReplayData->addHeader(header.key, header.value); | 509 xhrReplayData->addHeader(header.key, header.value); |
| 510 m_pendingXHRReplayData.set(client, xhrReplayData); |
| 512 } | 511 } |
| 513 | 512 |
| 514 void InspectorResourceAgent::delayedRemoveReplayXHR(XMLHttpRequest* xhr) | 513 void InspectorResourceAgent::delayedRemoveReplayXHR(XMLHttpRequest* xhr) |
| 515 { | 514 { |
| 516 if (!m_replayXHRs.contains(xhr)) | 515 if (!m_replayXHRs.contains(xhr)) |
| 517 return; | 516 return; |
| 518 | 517 |
| 519 m_replayXHRsToBeDeleted.add(xhr); | 518 m_replayXHRsToBeDeleted.add(xhr); |
| 520 m_replayXHRs.remove(xhr); | 519 m_replayXHRs.remove(xhr); |
| 521 m_removeFinishedReplayXHRTimer.startOneShot(0, FROM_HERE); | 520 m_removeFinishedReplayXHRTimer.startOneShot(0, FROM_HERE); |
| 522 } | 521 } |
| 523 | 522 |
| 524 void InspectorResourceAgent::didFailXHRLoading(XMLHttpRequest* xhr, ThreadableLo
aderClient* client) | 523 void InspectorResourceAgent::didFailXHRLoading(XMLHttpRequest* xhr, ThreadableLo
aderClient* client) |
| 525 { | 524 { |
| 526 m_pendingXHR = nullptr; | 525 m_pendingXHRReplayData.remove(client); |
| 527 m_pendingXHRReplayData.clear(); | |
| 528 | 526 |
| 529 // This method will be called from the XHR. | 527 // This method will be called from the XHR. |
| 530 // We delay deleting the replay XHR, as deleting here may delete the caller. | 528 // We delay deleting the replay XHR, as deleting here may delete the caller. |
| 531 delayedRemoveReplayXHR(xhr); | 529 delayedRemoveReplayXHR(xhr); |
| 532 } | 530 } |
| 533 | 531 |
| 534 void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLH
ttpRequest* xhr, ThreadableLoaderClient* client, unsigned long identifier, Scrip
tString sourceString, const AtomicString& method, const String& url) | 532 void InspectorResourceAgent::didFinishXHRLoading(ExecutionContext* context, XMLH
ttpRequest* xhr, ThreadableLoaderClient* client, unsigned long identifier, Scrip
tString sourceString, const AtomicString& method, const String& url) |
| 535 { | 533 { |
| 536 m_pendingXHR = nullptr; | 534 m_pendingXHRReplayData.remove(client); |
| 537 m_pendingXHRReplayData.clear(); | |
| 538 | 535 |
| 539 // See comments on |didFailXHRLoading| for why we are delaying delete. | 536 // See comments on |didFailXHRLoading| for why we are delaying delete. |
| 540 delayedRemoveReplayXHR(xhr); | 537 delayedRemoveReplayXHR(xhr); |
| 541 | 538 |
| 542 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) { | 539 if (m_state->getBoolean(ResourceAgentState::monitoringXHR)) { |
| 543 String message = "XHR finished loading: " + method + " \"" + url + "\"."
; | 540 String message = "XHR finished loading: " + method + " \"" + url + "\"."
; |
| 544 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea
te(NetworkMessageSource, DebugMessageLevel, message); | 541 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea
te(NetworkMessageSource, DebugMessageLevel, message); |
| 545 consoleMessage->setRequestIdentifier(identifier); | 542 consoleMessage->setRequestIdentifier(identifier); |
| 546 m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context,
consoleMessage.release()); | 543 m_pageAgent->frameHost()->consoleMessageStorage().reportMessage(context,
consoleMessage.release()); |
| 547 } | 544 } |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) | 914 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) |
| 918 { | 915 { |
| 919 } | 916 } |
| 920 | 917 |
| 921 bool InspectorResourceAgent::shouldForceCORSPreflight() | 918 bool InspectorResourceAgent::shouldForceCORSPreflight() |
| 922 { | 919 { |
| 923 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 920 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
| 924 } | 921 } |
| 925 | 922 |
| 926 } // namespace blink | 923 } // namespace blink |
| OLD | NEW |