Chromium Code Reviews| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 const String cacheIdentifier = getCacheIdentifier(); | 356 const String cacheIdentifier = getCacheIdentifier(); |
| 357 if (Resource* oldResource = | 357 if (Resource* oldResource = |
| 358 memoryCache()->resourceForURL(url, cacheIdentifier)) { | 358 memoryCache()->resourceForURL(url, cacheIdentifier)) { |
| 359 // There's no reason to re-parse if we saved the data from the previous | 359 // There's no reason to re-parse if we saved the data from the previous |
| 360 // parse. | 360 // parse. |
| 361 if (request.options().dataBufferingPolicy != DoNotBufferData) | 361 if (request.options().dataBufferingPolicy != DoNotBufferData) |
| 362 return oldResource; | 362 return oldResource; |
| 363 memoryCache()->remove(oldResource); | 363 memoryCache()->remove(oldResource); |
| 364 } | 364 } |
| 365 | 365 |
| 366 AtomicString mimetype; | 366 ResourceResponse response; |
| 367 AtomicString charset; | |
| 368 RefPtr<SharedBuffer> data; | 367 RefPtr<SharedBuffer> data; |
| 369 if (substituteData.isValid()) { | 368 if (substituteData.isValid()) { |
| 370 mimetype = substituteData.mimeType(); | |
| 371 charset = substituteData.textEncoding(); | |
| 372 data = substituteData.content(); | 369 data = substituteData.content(); |
| 370 response.setURL(url); | |
| 371 response.setMimeType(substituteData.mimeType()); | |
| 372 response.setExpectedContentLength(data->size()); | |
| 373 response.setTextEncodingName(substituteData.textEncoding()); | |
| 373 } else if (url.protocolIsData()) { | 374 } else if (url.protocolIsData()) { |
| 374 data = PassRefPtr<SharedBuffer>( | 375 data = PassRefPtr<SharedBuffer>(NetworkUtils::parseDataURL(url, response)); |
|
kouhei (in TOK)
2017/03/21 07:29:20
can we note that response is modified by parseData
hiroshige
2017/03/21 08:04:47
Done.
| |
| 375 NetworkUtils::parseDataURL(url, mimetype, charset)); | |
| 376 if (!data) | 376 if (!data) |
| 377 return nullptr; | 377 return nullptr; |
| 378 } else { | 378 } else { |
| 379 ArchiveResource* archiveResource = | 379 ArchiveResource* archiveResource = |
| 380 m_archive->subresourceForURL(request.url()); | 380 m_archive->subresourceForURL(request.url()); |
| 381 // Fall back to the network if the archive doesn't contain the resource. | 381 // Fall back to the network if the archive doesn't contain the resource. |
| 382 if (!archiveResource) | 382 if (!archiveResource) |
| 383 return nullptr; | 383 return nullptr; |
| 384 mimetype = archiveResource->mimeType(); | |
| 385 charset = archiveResource->textEncoding(); | |
| 386 data = archiveResource->data(); | 384 data = archiveResource->data(); |
| 387 } | 385 response.setURL(url); |
| 388 | 386 response.setMimeType(archiveResource->mimeType()); |
| 389 ResourceResponse response(url, mimetype, data->size(), charset); | 387 response.setExpectedContentLength(data->size()); |
| 390 if (!substituteData.isValid() && url.protocolIsData()) { | 388 response.setTextEncodingName(archiveResource->textEncoding()); |
| 391 response.setHTTPStatusCode(200); | |
|
hiroshige
2017/03/21 08:00:12
This block is moved to parseDataURL().
| |
| 392 response.setHTTPStatusText("OK"); | |
| 393 } | 389 } |
| 394 | 390 |
| 395 Resource* resource = factory.create(request.resourceRequest(), | 391 Resource* resource = factory.create(request.resourceRequest(), |
| 396 request.options(), request.charset()); | 392 request.options(), request.charset()); |
| 397 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()); | 393 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()); |
| 398 // FIXME: We should provide a body stream here. | 394 // FIXME: We should provide a body stream here. |
| 399 resource->responseReceived(response, nullptr); | 395 resource->responseReceived(response, nullptr); |
| 400 resource->setDataBufferingPolicy(BufferData); | 396 resource->setDataBufferingPolicy(BufferData); |
| 401 if (data->size()) | 397 if (data->size()) |
| 402 resource->setResourceBuffer(data); | 398 resource->setResourceBuffer(data); |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1546 visitor->trace(m_context); | 1542 visitor->trace(m_context); |
| 1547 visitor->trace(m_archive); | 1543 visitor->trace(m_archive); |
| 1548 visitor->trace(m_loaders); | 1544 visitor->trace(m_loaders); |
| 1549 visitor->trace(m_nonBlockingLoaders); | 1545 visitor->trace(m_nonBlockingLoaders); |
| 1550 visitor->trace(m_documentResources); | 1546 visitor->trace(m_documentResources); |
| 1551 visitor->trace(m_preloads); | 1547 visitor->trace(m_preloads); |
| 1552 visitor->trace(m_resourceTimingInfoMap); | 1548 visitor->trace(m_resourceTimingInfoMap); |
| 1553 } | 1549 } |
| 1554 | 1550 |
| 1555 } // namespace blink | 1551 } // namespace blink |
| OLD | NEW |