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

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

Issue 1707013002: [WIP][SVG 3/4] Allow invalid data: URLs to be served synchronously by Resource::load() Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_SVGImage_Fix2
Patch Set: Rebase + reflect comments. Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 memoryCache()->remove(oldResource); 324 memoryCache()->remove(oldResource);
325 } 325 }
326 326
327 WebString mimetype; 327 WebString mimetype;
328 WebString charset; 328 WebString charset;
329 RefPtr<SharedBuffer> data; 329 RefPtr<SharedBuffer> data;
330 if (substituteData.isValid()) { 330 if (substituteData.isValid()) {
331 mimetype = substituteData.mimeType(); 331 mimetype = substituteData.mimeType();
332 charset = substituteData.textEncoding(); 332 charset = substituteData.textEncoding();
333 data = substituteData.content(); 333 data = substituteData.content();
334 ASSERT(data);
334 } else { 335 } else {
335 WrappedResourceRequest wrappedRequest(request.resourceRequest()); 336 WrappedResourceRequest wrappedRequest(request.resourceRequest());
336 WebData webData; 337 WebData webData;
337 if (!Platform::current()->parseDataURLIfCanBeHandledLocally(wrappedReque st, mimetype, charset, webData)) 338 if (!Platform::current()->parseDataURLIfCanBeHandledLocally(wrappedReque st, mimetype, charset, webData))
338 return nullptr; 339 return nullptr;
339 data = PassRefPtr<SharedBuffer>(webData); 340 data = PassRefPtr<SharedBuffer>(webData);
340 if (!data)
341 return nullptr;
342 } 341 }
342
343 RefPtrWillBeRawPtr<Resource> resource = factory.create(request.resourceReque st(), request.charset());
344 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()) ;
345 resource->setOptions(request.options());
346
347 if (!data) {
348 // We don't add |resource| to MemoryCache because it has an error,
349 // but make ResourceFetcher::requestResource() to return this
350 // Resource to make all data font URLs to be resolved synchronously.
351 // https://crbug.com/382170
352 resource->error(Resource::LoadError);
Nate Chapin 2016/03/01 23:11:34 ASSERT(url.protocolIsData()) here, just to be clea
353 return resource.release();
354 }
355
343 ResourceResponse response(url, mimetype, data->size(), charset, String()); 356 ResourceResponse response(url, mimetype, data->size(), charset, String());
344 response.setHTTPStatusCode(200); 357 response.setHTTPStatusCode(200);
345 response.setHTTPStatusText("OK"); 358 response.setHTTPStatusText("OK");
346 359
347 RefPtrWillBeRawPtr<Resource> resource = factory.create(request.resourceReque st(), request.charset());
348 resource->setNeedsSynchronousCacheHit(substituteData.forceSynchronousLoad()) ;
349 resource->setOptions(request.options());
350 // FIXME: We should provide a body stream here. 360 // FIXME: We should provide a body stream here.
351 resource->responseReceived(response, nullptr); 361 resource->responseReceived(response, nullptr);
352 resource->setDataBufferingPolicy(BufferData); 362 resource->setDataBufferingPolicy(BufferData);
353 if (data->size()) 363 if (data->size())
354 resource->setResourceBuffer(data); 364 resource->setResourceBuffer(data);
355 resource->setIdentifier(createUniqueIdentifier()); 365 resource->setIdentifier(createUniqueIdentifier());
356 resource->setCacheIdentifier(cacheIdentifier); 366 resource->setCacheIdentifier(cacheIdentifier);
357 resource->finish(); 367 resource->finish();
358 memoryCache()->add(resource.get()); 368 memoryCache()->add(resource.get());
359 return resource.release(); 369 return resource.release();
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 visitor->trace(m_loaders); 1228 visitor->trace(m_loaders);
1219 visitor->trace(m_nonBlockingLoaders); 1229 visitor->trace(m_nonBlockingLoaders);
1220 #if ENABLE(OILPAN) 1230 #if ENABLE(OILPAN)
1221 visitor->trace(m_documentResources); 1231 visitor->trace(m_documentResources);
1222 visitor->trace(m_preloads); 1232 visitor->trace(m_preloads);
1223 visitor->trace(m_resourceTimingInfoMap); 1233 visitor->trace(m_resourceTimingInfoMap);
1224 #endif 1234 #endif
1225 } 1235 }
1226 1236
1227 } // namespace blink 1237 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698