| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 visitor->trace(m_replayXHRsToBeDeleted); | 308 visitor->trace(m_replayXHRsToBeDeleted); |
| 309 #endif | 309 #endif |
| 310 InspectorBaseAgent::trace(visitor); | 310 InspectorBaseAgent::trace(visitor); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL
oader* loader, ResourceRequest& request, const ResourceResponse& redirectRespons
e, const FetchInitiatorInfo& initiatorInfo) | 313 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL
oader* loader, ResourceRequest& request, const ResourceResponse& redirectRespons
e, const FetchInitiatorInfo& initiatorInfo) |
| 314 { | 314 { |
| 315 // Ignore the request initiated internally. | 315 // Ignore the request initiated internally. |
| 316 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) | 316 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) |
| 317 return; | 317 return; |
| 318 if (loader && loader->substituteData().isValid()) | 318 |
| 319 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader && loa
der->substituteData().isValid()) |
| 319 return; | 320 return; |
| 320 | 321 |
| 321 String requestId = IdentifiersFactory::requestId(identifier); | 322 String requestId = IdentifiersFactory::requestId(identifier); |
| 322 m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(loader)); | 323 m_resourcesData->resourceCreated(requestId, m_pageAgent->loaderId(loader)); |
| 323 | 324 |
| 324 RefPtr<JSONObject> headers = m_state->getObject(ResourceAgentState::extraReq
uestHeaders); | 325 RefPtr<JSONObject> headers = m_state->getObject(ResourceAgentState::extraReq
uestHeaders); |
| 325 | 326 |
| 326 if (headers) { | 327 if (headers) { |
| 327 JSONObject::const_iterator end = headers->end(); | 328 JSONObject::const_iterator end = headers->end(); |
| 328 for (JSONObject::const_iterator it = headers->begin(); it != end; ++it)
{ | 329 for (JSONObject::const_iterator it = headers->begin(); it != end; ++it)
{ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 367 |
| 367 RefPtr<JSONValue> status = response->get("status"); | 368 RefPtr<JSONValue> status = response->get("status"); |
| 368 RefPtr<JSONValue> mimeType = response->get("mimeType"); | 369 RefPtr<JSONValue> mimeType = response->get("mimeType"); |
| 369 RefPtr<JSONObject> headers = response->getObject("headers"); | 370 RefPtr<JSONObject> headers = response->getObject("headers"); |
| 370 | 371 |
| 371 return !status && !mimeType && (!headers || !headers->size()); | 372 return !status && !mimeType && (!headers || !headers->size()); |
| 372 } | 373 } |
| 373 | 374 |
| 374 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig
ned long identifier, DocumentLoader* loader, const ResourceResponse& response, R
esourceLoader* resourceLoader) | 375 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig
ned long identifier, DocumentLoader* loader, const ResourceResponse& response, R
esourceLoader* resourceLoader) |
| 375 { | 376 { |
| 376 if (loader && loader->substituteData().isValid()) | |
| 377 return; | |
| 378 | |
| 379 String requestId = IdentifiersFactory::requestId(identifier); | 377 String requestId = IdentifiersFactory::requestId(identifier); |
| 380 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso
urceResponse(response, loader); | 378 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso
urceResponse(response, loader); |
| 381 | 379 |
| 382 bool isNotModified = response.httpStatusCode() == 304; | 380 bool isNotModified = response.httpStatusCode() == 304; |
| 383 | 381 |
| 384 Resource* cachedResource = 0; | 382 Resource* cachedResource = 0; |
| 385 if (resourceLoader && !isNotModified) | 383 if (resourceLoader && !isNotModified) |
| 386 cachedResource = resourceLoader->cachedResource(); | 384 cachedResource = resourceLoader->cachedResource(); |
| 387 if (!cachedResource || cachedResource->type() == Resource::MainResource) | 385 if (!cachedResource || cachedResource->type() == Resource::MainResource) |
| 388 cachedResource = InspectorPageAgent::cachedResource(frame, response.url(
)); | 386 cachedResource = InspectorPageAgent::cachedResource(frame, response.url(
)); |
| 389 | 387 |
| 390 if (cachedResource) { | 388 if (cachedResource && resourceResponse && response.mimeType().isEmpty()) { |
| 391 // Use mime type from cached resource in case the one in response is emp
ty. | 389 // Use mime type from cached resource in case the one in response is emp
ty. |
| 392 if (resourceResponse && response.mimeType().isEmpty()) | 390 resourceResponse->setString(TypeBuilder::Network::Response::MimeType, ca
chedResource->response().mimeType()); |
| 393 resourceResponse->setString(TypeBuilder::Network::Response::MimeType
, cachedResource->response().mimeType()); | |
| 394 m_resourcesData->addResource(requestId, cachedResource); | |
| 395 } | 391 } |
| 396 | 392 |
| 397 InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent:
:cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource; | 393 InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent:
:cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource; |
| 398 // Workaround for worker scripts that use RawResources for loading. | 394 // Workaround for worker scripts that use RawResources for loading. |
| 399 if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptRe
source) | 395 if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptRe
source) |
| 400 type = InspectorPageAgent::ScriptResource; | 396 type = InspectorPageAgent::ScriptResource; |
| 401 // Workaround for background: url() in inline style. | 397 // Workaround for background: url() in inline style. |
| 402 if (loader && equalIgnoringFragmentIdentifier(response.url(), loader->url())
&& !loader->isCommitted()) | 398 if (loader && equalIgnoringFragmentIdentifier(response.url(), loader->url())
&& !loader->isCommitted()) |
| 403 type = InspectorPageAgent::DocumentResource; | 399 type = InspectorPageAgent::DocumentResource; |
| 404 | 400 |
| 401 if (type == InspectorPageAgent::DocumentResource && loader && loader->substi
tuteData().isValid()) |
| 402 return; |
| 403 |
| 404 if (cachedResource) |
| 405 m_resourcesData->addResource(requestId, cachedResource); |
| 405 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(frame), re
sponse); | 406 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(frame), re
sponse); |
| 406 m_resourcesData->setResourceType(requestId, type); | 407 m_resourcesData->setResourceType(requestId, type); |
| 407 | 408 |
| 409 |
| 408 if (!isResponseEmpty(resourceResponse)) | 410 if (!isResponseEmpty(resourceResponse)) |
| 409 m_frontend->responseReceived(requestId, m_pageAgent->frameId(frame), m_p
ageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(
type), resourceResponse); | 411 m_frontend->responseReceived(requestId, m_pageAgent->frameId(frame), m_p
ageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(
type), resourceResponse); |
| 410 // If we revalidated the resource and got Not modified, send content length
following didReceiveResponse | 412 // If we revalidated the resource and got Not modified, send content length
following didReceiveResponse |
| 411 // as there will be no calls to didReceiveData from the network stack. | 413 // as there will be no calls to didReceiveData from the network stack. |
| 412 if (isNotModified && cachedResource && cachedResource->encodedSize()) | 414 if (isNotModified && cachedResource && cachedResource->encodedSize()) |
| 413 didReceiveData(frame, identifier, 0, cachedResource->encodedSize(), 0); | 415 didReceiveData(frame, identifier, 0, cachedResource->encodedSize(), 0); |
| 414 } | 416 } |
| 415 | 417 |
| 416 static bool isErrorStatusCode(int statusCode) | 418 static bool isErrorStatusCode(int statusCode) |
| 417 { | 419 { |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) | 887 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish
edReplayXHRFired) |
| 886 { | 888 { |
| 887 } | 889 } |
| 888 | 890 |
| 889 bool InspectorResourceAgent::shouldForceCORSPreflight() | 891 bool InspectorResourceAgent::shouldForceCORSPreflight() |
| 890 { | 892 { |
| 891 return m_state->getBoolean(ResourceAgentState::cacheDisabled); | 893 return m_state->getBoolean(ResourceAgentState::cacheDisabled); |
| 892 } | 894 } |
| 893 | 895 |
| 894 } // namespace blink | 896 } // namespace blink |
| OLD | NEW |