| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 const String cacheIdentifier = getCacheIdentifier(); | 362 const String cacheIdentifier = getCacheIdentifier(); |
| 363 if (Resource* oldResource = | 363 if (Resource* oldResource = |
| 364 memoryCache()->resourceForURL(url, cacheIdentifier)) { | 364 memoryCache()->resourceForURL(url, cacheIdentifier)) { |
| 365 // There's no reason to re-parse if we saved the data from the previous | 365 // There's no reason to re-parse if we saved the data from the previous |
| 366 // parse. | 366 // parse. |
| 367 if (request.options().dataBufferingPolicy != DoNotBufferData) | 367 if (request.options().dataBufferingPolicy != DoNotBufferData) |
| 368 return oldResource; | 368 return oldResource; |
| 369 memoryCache()->remove(oldResource); | 369 memoryCache()->remove(oldResource); |
| 370 } | 370 } |
| 371 | 371 |
| 372 AtomicString mimetype; | 372 ResourceResponse response; |
| 373 AtomicString charset; | |
| 374 RefPtr<SharedBuffer> data; | 373 RefPtr<SharedBuffer> data; |
| 375 if (substituteData.isValid()) { | 374 if (substituteData.isValid()) { |
| 376 mimetype = substituteData.mimeType(); | |
| 377 charset = substituteData.textEncoding(); | |
| 378 data = substituteData.content(); | 375 data = substituteData.content(); |
| 376 response.setURL(url); |
| 377 response.setMimeType(substituteData.mimeType()); |
| 378 response.setExpectedContentLength(data->size()); |
| 379 response.setTextEncodingName(substituteData.textEncoding()); |
| 379 } else if (url.protocolIsData()) { | 380 } else if (url.protocolIsData()) { |
| 380 data = PassRefPtr<SharedBuffer>( | 381 data = NetworkUtils::parseDataURLAndPopulateResponse(url, response); |
| 381 NetworkUtils::parseDataURL(url, mimetype, charset)); | |
| 382 if (!data) | 382 if (!data) |
| 383 return nullptr; | 383 return nullptr; |
| 384 // |response| is modified by parseDataURLAndPopulateResponse() and is |
| 385 // ready to be used. |
| 384 } else { | 386 } else { |
| 385 ArchiveResource* archiveResource = | 387 ArchiveResource* archiveResource = |
| 386 m_archive->subresourceForURL(request.url()); | 388 m_archive->subresourceForURL(request.url()); |
| 387 // Fall back to the network if the archive doesn't contain the resource. | 389 // Fall back to the network if the archive doesn't contain the resource. |
| 388 if (!archiveResource) | 390 if (!archiveResource) |
| 389 return nullptr; | 391 return nullptr; |
| 390 mimetype = archiveResource->mimeType(); | |
| 391 charset = archiveResource->textEncoding(); | |
| 392 data = archiveResource->data(); | 392 data = archiveResource->data(); |
| 393 } | 393 response.setURL(url); |
| 394 | 394 response.setMimeType(archiveResource->mimeType()); |
| 395 ResourceResponse response(url, mimetype, data->size(), charset); | 395 response.setExpectedContentLength(data->size()); |
| 396 if (!substituteData.isValid() && url.protocolIsData()) { | 396 response.setTextEncodingName(archiveResource->textEncoding()); |
| 397 response.setHTTPStatusCode(200); | |
| 398 response.setHTTPStatusText("OK"); | |
| 399 } | 397 } |
| 400 | 398 |
| 401 Resource* resource = factory.create(request.resourceRequest(), | 399 Resource* resource = factory.create(request.resourceRequest(), |
| 402 request.options(), request.charset()); | 400 request.options(), request.charset()); |
| 403 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()); | 401 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()); |
| 404 // FIXME: We should provide a body stream here. | 402 // FIXME: We should provide a body stream here. |
| 405 resource->responseReceived(response, nullptr); | 403 resource->responseReceived(response, nullptr); |
| 406 resource->setDataBufferingPolicy(BufferData); | 404 resource->setDataBufferingPolicy(BufferData); |
| 407 if (data->size()) | 405 if (data->size()) |
| 408 resource->setResourceBuffer(data); | 406 resource->setResourceBuffer(data); |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 visitor->trace(m_context); | 1551 visitor->trace(m_context); |
| 1554 visitor->trace(m_archive); | 1552 visitor->trace(m_archive); |
| 1555 visitor->trace(m_loaders); | 1553 visitor->trace(m_loaders); |
| 1556 visitor->trace(m_nonBlockingLoaders); | 1554 visitor->trace(m_nonBlockingLoaders); |
| 1557 visitor->trace(m_documentResources); | 1555 visitor->trace(m_documentResources); |
| 1558 visitor->trace(m_preloads); | 1556 visitor->trace(m_preloads); |
| 1559 visitor->trace(m_resourceTimingInfoMap); | 1557 visitor->trace(m_resourceTimingInfoMap); |
| 1560 } | 1558 } |
| 1561 | 1559 |
| 1562 } // namespace blink | 1560 } // namespace blink |
| OLD | NEW |