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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 auto entry = blockedURLs->at(i); | 487 auto entry = blockedURLs->at(i); |
488 if (matches(url, entry.first)) | 488 if (matches(url, entry.first)) |
489 return true; | 489 return true; |
490 } | 490 } |
491 return false; | 491 return false; |
492 } | 492 } |
493 | 493 |
494 void InspectorNetworkAgent::didBlockRequest(LocalFrame* frame, const ResourceReq uest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason) | 494 void InspectorNetworkAgent::didBlockRequest(LocalFrame* frame, const ResourceReq uest& request, DocumentLoader* loader, const FetchInitiatorInfo& initiatorInfo, ResourceRequestBlockedReason reason) |
495 { | 495 { |
496 unsigned long identifier = createUniqueIdentifier(); | 496 unsigned long identifier = createUniqueIdentifier(); |
497 willSendRequestInternal(frame, identifier, loader, request, ResourceResponse (), initiatorInfo); | 497 willSendRequest(frame, identifier, loader, request, ResourceResponse(), init iatorInfo); |
498 | 498 |
499 String requestId = IdentifiersFactory::requestId(identifier); | 499 String requestId = IdentifiersFactory::requestId(identifier); |
500 String protocolReason = buildBlockedReason(reason); | 500 String protocolReason = buildBlockedReason(reason); |
501 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), Inspecto rPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String() , false, protocolReason); | 501 frontend()->loadingFailed(requestId, monotonicallyIncreasingTime(), Inspecto rPageAgent::resourceTypeJson(m_resourcesData->resourceType(requestId)), String() , false, protocolReason); |
502 } | 502 } |
503 | 503 |
504 void InspectorNetworkAgent::didChangeResourcePriority(unsigned long identifier, ResourceLoadPriority loadPriority) | 504 void InspectorNetworkAgent::didChangeResourcePriority(unsigned long identifier, ResourceLoadPriority loadPriority) |
505 { | 505 { |
506 String requestId = IdentifiersFactory::requestId(identifier); | 506 String requestId = IdentifiersFactory::requestId(identifier); |
507 frontend()->resourceChangedPriority(requestId, resourcePriorityJSON(loadPrio rity), monotonicallyIncreasingTime()); | 507 frontend()->resourceChangedPriority(requestId, resourcePriorityJSON(loadPrio rity), monotonicallyIncreasingTime()); |
508 } | 508 } |
509 | 509 |
510 void InspectorNetworkAgent::willSendRequestInternal(LocalFrame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, const R esourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) | 510 void InspectorNetworkAgent::willSendRequest(LocalFrame* frame, unsigned long ide ntifier, DocumentLoader* loader, const ResourceRequest& request, const ResourceR esponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) |
511 { | 511 { |
512 // Ignore the request initiated internally. | |
513 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) | |
514 return; | |
515 | |
516 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid()) | |
517 return; | |
518 | |
512 String requestId = IdentifiersFactory::requestId(identifier); | 519 String requestId = IdentifiersFactory::requestId(identifier); |
513 String loaderId = IdentifiersFactory::loaderId(loader); | 520 String loaderId = IdentifiersFactory::loaderId(loader); |
514 m_resourcesData->resourceCreated(requestId, loaderId, request.url()); | 521 m_resourcesData->resourceCreated(requestId, loaderId, request.url()); |
515 | 522 |
516 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; | 523 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; |
517 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) { | 524 if (initiatorInfo.name == FetchInitiatorTypeNames::xmlhttprequest) { |
518 type = InspectorPageAgent::XHRResource; | 525 type = InspectorPageAgent::XHRResource; |
519 m_resourcesData->setResourceType(requestId, type); | 526 m_resourcesData->setResourceType(requestId, type); |
520 } else if (initiatorInfo.name == FetchInitiatorTypeNames::document) { | 527 } else if (initiatorInfo.name == FetchInitiatorTypeNames::document) { |
521 type = InspectorPageAgent::DocumentResource; | 528 type = InspectorPageAgent::DocumentResource; |
(...skipping 11 matching lines...) Expand all Loading... | |
533 std::unique_ptr<protocol::Network::Request> requestInfo(buildObjectForResour ceRequest(request)); | 540 std::unique_ptr<protocol::Network::Request> requestInfo(buildObjectForResour ceRequest(request)); |
534 | 541 |
535 requestInfo->setMixedContentType(mixedContentTypeForContextType(MixedContent Checker::contextTypeForInspector(frame, request))); | 542 requestInfo->setMixedContentType(mixedContentTypeForContextType(MixedContent Checker::contextTypeForInspector(frame, request))); |
536 | 543 |
537 String resourceType = InspectorPageAgent::resourceTypeJson(type); | 544 String resourceType = InspectorPageAgent::resourceTypeJson(type); |
538 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).getString(), std::move(requestInfo), monotonicallyIncreasingTi me(), currentTime(), std::move(initiatorObject), buildObjectForResourceResponse( redirectResponse), resourceType); | 545 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).getString(), std::move(requestInfo), monotonicallyIncreasingTi me(), currentTime(), std::move(initiatorObject), buildObjectForResourceResponse( redirectResponse), resourceType); |
539 if (m_pendingXHRReplayData && !m_pendingXHRReplayData->async()) | 546 if (m_pendingXHRReplayData && !m_pendingXHRReplayData->async()) |
540 frontend()->flush(); | 547 frontend()->flush(); |
541 } | 548 } |
542 | 549 |
543 void InspectorNetworkAgent::willSendRequest(LocalFrame* frame, unsigned long ide ntifier, DocumentLoader* loader, ResourceRequest& request, const ResourceRespons e& redirectResponse, const FetchInitiatorInfo& initiatorInfo) | 550 void InspectorNetworkAgent::prepareRequest(DocumentLoader* loader, ResourceReque st& request) |
544 { | 551 { |
545 // Ignore the request initiated internally. | |
hiroshige
2016/08/04 09:51:14
Don't we need these |if| statements in InspectorNe
Nate Chapin
2016/08/04 21:21:55
Dropping the subsituteData() check is benign, sinc
| |
546 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) | |
547 return; | |
548 | |
549 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid()) | |
550 return; | |
551 | |
552 protocol::DictionaryValue* headers = m_state->getObject(NetworkAgentState::e xtraRequestHeaders); | 552 protocol::DictionaryValue* headers = m_state->getObject(NetworkAgentState::e xtraRequestHeaders); |
553 if (headers) { | 553 if (headers) { |
554 for (size_t i = 0; i < headers->size(); ++i) { | 554 for (size_t i = 0; i < headers->size(); ++i) { |
555 auto header = headers->at(i); | 555 auto header = headers->at(i); |
556 String16 value; | 556 String16 value; |
557 if (header.second->asString(&value)) | 557 if (header.second->asString(&value)) |
558 request.setHTTPHeaderField(AtomicString(header.first), AtomicStr ing(String(value))); | 558 request.setHTTPHeaderField(AtomicString(header.first), AtomicStr ing(String(value))); |
559 } | 559 } |
560 } | 560 } |
561 | 561 |
562 request.setReportRawHeaders(true); | 562 request.setReportRawHeaders(true); |
563 | 563 |
564 if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false)) { | 564 if (m_state->booleanProperty(NetworkAgentState::cacheDisabled, false)) { |
565 request.setCachePolicy(WebCachePolicy::BypassingCache); | 565 request.setCachePolicy(WebCachePolicy::BypassingCache); |
566 request.setShouldResetAppCache(true); | 566 request.setShouldResetAppCache(true); |
567 } | 567 } |
568 if (m_state->booleanProperty(NetworkAgentState::bypassServiceWorker, false)) | 568 if (m_state->booleanProperty(NetworkAgentState::bypassServiceWorker, false)) |
569 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | 569 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
570 | 570 |
571 willSendRequestInternal(frame, identifier, loader, request, redirectResponse , initiatorInfo); | |
572 | |
573 if (!m_hostId.isEmpty()) | 571 if (!m_hostId.isEmpty()) |
574 request.addHTTPHeaderField(HTTPNames::X_DevTools_Emulate_Network_Conditi ons_Client_Id, AtomicString(m_hostId)); | 572 request.addHTTPHeaderField(HTTPNames::X_DevTools_Emulate_Network_Conditi ons_Client_Id, AtomicString(m_hostId)); |
pfeldman
2016/08/04 21:39:59
Do you mean that these are now getting reported ov
Nate Chapin
2016/08/04 21:46:49
I think that's what this would mean, yeah. Will mo
Nate Chapin
2016/08/04 22:51:31
So, my theory had been that willSendRequest would
| |
575 } | 573 } |
576 | 574 |
577 void InspectorNetworkAgent::markResourceAsCached(unsigned long identifier) | 575 void InspectorNetworkAgent::markResourceAsCached(unsigned long identifier) |
578 { | 576 { |
579 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier) ); | 577 frontend()->requestServedFromCache(IdentifiersFactory::requestId(identifier) ); |
580 } | 578 } |
581 | 579 |
582 void InspectorNetworkAgent::didReceiveResourceResponse(LocalFrame* frame, unsign ed long identifier, DocumentLoader* loader, const ResourceResponse& response, Re source* cachedResource) | 580 void InspectorNetworkAgent::didReceiveResourceResponse(LocalFrame* frame, unsign ed long identifier, DocumentLoader* loader, const ResourceResponse& response, Re source* cachedResource) |
583 { | 581 { |
584 String requestId = IdentifiersFactory::requestId(identifier); | 582 String requestId = IdentifiersFactory::requestId(identifier); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 , m_removeFinishedReplayXHRTimer(this, &InspectorNetworkAgent::removeFinishe dReplayXHRFired) | 1189 , m_removeFinishedReplayXHRTimer(this, &InspectorNetworkAgent::removeFinishe dReplayXHRFired) |
1192 { | 1190 { |
1193 } | 1191 } |
1194 | 1192 |
1195 bool InspectorNetworkAgent::shouldForceCORSPreflight() | 1193 bool InspectorNetworkAgent::shouldForceCORSPreflight() |
1196 { | 1194 { |
1197 return m_state->booleanProperty(NetworkAgentState::cacheDisabled, false); | 1195 return m_state->booleanProperty(NetworkAgentState::cacheDisabled, false); |
1198 } | 1196 } |
1199 | 1197 |
1200 } // namespace blink | 1198 } // namespace blink |
OLD | NEW |