| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 m_frontend->requestWillBeSent(requestId, frameId, m_pageAgent->loaderId(load
er), urlWithoutFragment(loader->url()).string(), buildObjectForResourceRequest(r
equest), currentTime(), initiatorObject, buildObjectForResourceResponse(redirect
Response, loader)); | 331 m_frontend->requestWillBeSent(requestId, frameId, m_pageAgent->loaderId(load
er), urlWithoutFragment(loader->url()).string(), buildObjectForResourceRequest(r
equest), currentTime(), initiatorObject, buildObjectForResourceResponse(redirect
Response, loader)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) | 334 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) |
| 335 { | 335 { |
| 336 m_frontend->requestServedFromCache(IdentifiersFactory::requestId(identifier)
); | 336 m_frontend->requestServedFromCache(IdentifiersFactory::requestId(identifier)
); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame*, unsigned lo
ng identifier, DocumentLoader* loader, const ResourceResponse& response, Resourc
eLoader* resourceLoader) | 339 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig
ned long identifier, DocumentLoader* loader, const ResourceResponse& response, R
esourceLoader* resourceLoader) |
| 340 { | 340 { |
| 341 if (!loader) | 341 if (!loader) |
| 342 return; | 342 return; |
| 343 | 343 |
| 344 String requestId = IdentifiersFactory::requestId(identifier); | 344 String requestId = IdentifiersFactory::requestId(identifier); |
| 345 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso
urceResponse(response, loader); | 345 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso
urceResponse(response, loader); |
| 346 | 346 |
| 347 bool isNotModified = response.httpStatusCode() == 304; | 347 bool isNotModified = response.httpStatusCode() == 304; |
| 348 | 348 |
| 349 Resource* cachedResource = 0; | 349 Resource* cachedResource = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 366 // Workaround for background: url() in inline style. | 366 // Workaround for background: url() in inline style. |
| 367 if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loade
r->isCommitted()) | 367 if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loade
r->isCommitted()) |
| 368 type = InspectorPageAgent::DocumentResource; | 368 type = InspectorPageAgent::DocumentResource; |
| 369 | 369 |
| 370 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->fr
ame()), response); | 370 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->fr
ame()), response); |
| 371 m_resourcesData->setResourceType(requestId, type); | 371 m_resourcesData->setResourceType(requestId, type); |
| 372 m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame()
), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTyp
eJson(type), resourceResponse); | 372 m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame()
), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTyp
eJson(type), resourceResponse); |
| 373 // If we revalidated the resource and got Not modified, send content length
following didReceiveResponse | 373 // If we revalidated the resource and got Not modified, send content length
following didReceiveResponse |
| 374 // as there will be no calls to didReceiveData from the network stack. | 374 // as there will be no calls to didReceiveData from the network stack. |
| 375 if (isNotModified && cachedResource && cachedResource->encodedSize()) | 375 if (isNotModified && cachedResource && cachedResource->encodedSize()) |
| 376 didReceiveData(identifier, 0, cachedResource->encodedSize(), 0); | 376 didReceiveData(frame, identifier, 0, cachedResource->encodedSize(), 0); |
| 377 } | 377 } |
| 378 | 378 |
| 379 static bool isErrorStatusCode(int statusCode) | 379 static bool isErrorStatusCode(int statusCode) |
| 380 { | 380 { |
| 381 return statusCode >= 400; | 381 return statusCode >= 400; |
| 382 } | 382 } |
| 383 | 383 |
| 384 void InspectorResourceAgent::didReceiveData(unsigned long identifier, const char
* data, int dataLength, int encodedDataLength) | 384 void InspectorResourceAgent::didReceiveData(LocalFrame*, unsigned long identifie
r, const char* data, int dataLength, int encodedDataLength) |
| 385 { | 385 { |
| 386 String requestId = IdentifiersFactory::requestId(identifier); | 386 String requestId = IdentifiersFactory::requestId(identifier); |
| 387 | 387 |
| 388 if (data) { | 388 if (data) { |
| 389 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData
->data(requestId); | 389 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData
->data(requestId); |
| 390 if (resourceData && (!resourceData->cachedResource() || resourceData->ca
chedResource()->dataBufferingPolicy() == DoNotBufferData || isErrorStatusCode(re
sourceData->httpStatusCode()))) | 390 if (resourceData && (!resourceData->cachedResource() || resourceData->ca
chedResource()->dataBufferingPolicy() == DoNotBufferData || isErrorStatusCode(re
sourceData->httpStatusCode()))) |
| 391 m_resourcesData->maybeAddResourceData(requestId, data, dataLength); | 391 m_resourcesData->maybeAddResourceData(requestId, data, dataLength); |
| 392 } | 392 } |
| 393 | 393 |
| 394 m_frontend->dataReceived(requestId, currentTime(), dataLength, encodedDataLe
ngth); | 394 m_frontend->dataReceived(requestId, currentTime(), dataLength, encodedDataLe
ngth); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 : InspectorBaseAgent<InspectorResourceAgent>("Network") | 810 : InspectorBaseAgent<InspectorResourceAgent>("Network") |
| 811 , m_pageAgent(pageAgent) | 811 , m_pageAgent(pageAgent) |
| 812 , m_client(client) | 812 , m_client(client) |
| 813 , m_frontend(0) | 813 , m_frontend(0) |
| 814 , m_resourcesData(adoptPtr(new NetworkResourcesData())) | 814 , m_resourcesData(adoptPtr(new NetworkResourcesData())) |
| 815 , m_isRecalculatingStyle(false) | 815 , m_isRecalculatingStyle(false) |
| 816 { | 816 { |
| 817 } | 817 } |
| 818 | 818 |
| 819 } // namespace WebCore | 819 } // namespace WebCore |
| OLD | NEW |