Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2766583002: Set the same headers for data URLs in WebURLLoaderImpl and ResourceFetcher (Closed)
Patch Set: Add a comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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));
375 NetworkUtils::parseDataURL(url, mimetype, charset));
376 if (!data) 376 if (!data)
377 return nullptr; 377 return nullptr;
378 // |response| is modified by parseDataURL() and is ready to be used.
378 } else { 379 } else {
379 ArchiveResource* archiveResource = 380 ArchiveResource* archiveResource =
380 m_archive->subresourceForURL(request.url()); 381 m_archive->subresourceForURL(request.url());
381 // Fall back to the network if the archive doesn't contain the resource. 382 // Fall back to the network if the archive doesn't contain the resource.
382 if (!archiveResource) 383 if (!archiveResource)
383 return nullptr; 384 return nullptr;
384 mimetype = archiveResource->mimeType();
385 charset = archiveResource->textEncoding();
386 data = archiveResource->data(); 385 data = archiveResource->data();
387 } 386 response.setURL(url);
388 387 response.setMimeType(archiveResource->mimeType());
389 ResourceResponse response(url, mimetype, data->size(), charset); 388 response.setExpectedContentLength(data->size());
390 if (!substituteData.isValid() && url.protocolIsData()) { 389 response.setTextEncodingName(archiveResource->textEncoding());
391 response.setHTTPStatusCode(200);
392 response.setHTTPStatusText("OK");
393 } 390 }
394 391
395 Resource* resource = factory.create(request.resourceRequest(), 392 Resource* resource = factory.create(request.resourceRequest(),
396 request.options(), request.charset()); 393 request.options(), request.charset());
397 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()); 394 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad());
398 // FIXME: We should provide a body stream here. 395 // FIXME: We should provide a body stream here.
399 resource->responseReceived(response, nullptr); 396 resource->responseReceived(response, nullptr);
400 resource->setDataBufferingPolicy(BufferData); 397 resource->setDataBufferingPolicy(BufferData);
401 if (data->size()) 398 if (data->size())
402 resource->setResourceBuffer(data); 399 resource->setResourceBuffer(data);
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 visitor->trace(m_context); 1543 visitor->trace(m_context);
1547 visitor->trace(m_archive); 1544 visitor->trace(m_archive);
1548 visitor->trace(m_loaders); 1545 visitor->trace(m_loaders);
1549 visitor->trace(m_nonBlockingLoaders); 1546 visitor->trace(m_nonBlockingLoaders);
1550 visitor->trace(m_documentResources); 1547 visitor->trace(m_documentResources);
1551 visitor->trace(m_preloads); 1548 visitor->trace(m_preloads);
1552 visitor->trace(m_resourceTimingInfoMap); 1549 visitor->trace(m_resourceTimingInfoMap);
1553 } 1550 }
1554 1551
1555 } // namespace blink 1552 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698