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

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

Issue 2454983002: Cache-aware Resource loading (Closed)
Patch Set: nit Created 4 years, 1 month 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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 DCHECK(resource->stillNeedsLoad()); 1274 DCHECK(resource->stillNeedsLoad());
1275 if (!context().shouldLoadNewResource(resource->getType())) { 1275 if (!context().shouldLoadNewResource(resource->getType())) {
1276 memoryCache()->remove(resource); 1276 memoryCache()->remove(resource);
1277 return false; 1277 return false;
1278 } 1278 }
1279 1279
1280 ResourceRequest request(resource->resourceRequest()); 1280 ResourceRequest request(resource->resourceRequest());
1281 willSendRequest(resource->identifier(), request, ResourceResponse(), 1281 willSendRequest(resource->identifier(), request, ResourceResponse(),
1282 resource->options()); 1282 resource->options());
1283 1283
1284 // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove
1285 // once willSendRequest() takes const ResourceRequest. crbug.com/632580
1286 resource->setResourceRequest(request);
1287
1284 // Resource requests from suborigins should not be intercepted by the service 1288 // Resource requests from suborigins should not be intercepted by the service
1285 // worker of the physical origin. This has the effect that, for now, 1289 // worker of the physical origin. This has the effect that, for now,
1286 // suborigins do not work with service workers. See 1290 // suborigins do not work with service workers. See
1287 // https://w3c.github.io/webappsec-suborigins/. 1291 // https://w3c.github.io/webappsec-suborigins/.
1288 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); 1292 SecurityOrigin* sourceOrigin = context().getSecurityOrigin();
1289 if (sourceOrigin && sourceOrigin->hasSuborigin()) 1293 if (sourceOrigin && sourceOrigin->hasSuborigin())
1290 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); 1294 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All);
1291 1295
1292 ResourceLoader* loader = ResourceLoader::create(this, resource); 1296 ResourceLoader* loader = ResourceLoader::create(this, resource);
1293 if (resource->shouldBlockLoadEvent()) 1297 if (resource->shouldBlockLoadEvent())
1294 m_loaders.add(loader); 1298 m_loaders.add(loader);
1295 else 1299 else
1296 m_nonBlockingLoaders.add(loader); 1300 m_nonBlockingLoaders.add(loader);
1297 1301
1298 storeResourceTimingInitiatorInformation(resource); 1302 storeResourceTimingInitiatorInformation(resource);
1299 resource->setFetcherSecurityOrigin(sourceOrigin); 1303 resource->setFetcherSecurityOrigin(sourceOrigin);
1304
1305 loader->activateCacheAwareLoadingIfNeeded(request);
1300 loader->start(request, context().loadingTaskRunner(), 1306 loader->start(request, context().loadingTaskRunner(),
1301 context().defersLoading()); 1307 context().defersLoading());
1302 return true; 1308 return true;
1303 } 1309 }
1304 1310
1305 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { 1311 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) {
1306 if (m_loaders.contains(loader)) 1312 if (m_loaders.contains(loader))
1307 m_loaders.remove(loader); 1313 m_loaders.remove(loader);
1308 else if (m_nonBlockingLoaders.contains(loader)) 1314 else if (m_nonBlockingLoaders.contains(loader))
1309 m_nonBlockingLoaders.remove(loader); 1315 m_nonBlockingLoaders.remove(loader);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 visitor->trace(m_context); 1625 visitor->trace(m_context);
1620 visitor->trace(m_archive); 1626 visitor->trace(m_archive);
1621 visitor->trace(m_loaders); 1627 visitor->trace(m_loaders);
1622 visitor->trace(m_nonBlockingLoaders); 1628 visitor->trace(m_nonBlockingLoaders);
1623 visitor->trace(m_documentResources); 1629 visitor->trace(m_documentResources);
1624 visitor->trace(m_preloads); 1630 visitor->trace(m_preloads);
1625 visitor->trace(m_resourceTimingInfoMap); 1631 visitor->trace(m_resourceTimingInfoMap);
1626 } 1632 }
1627 1633
1628 } // namespace blink 1634 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698