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

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

Issue 711213002: ResourceFetcher::requestPreload should set its requestContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tyoshino@ suggestion Created 6 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
« 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 { 1235 {
1236 requestPreload(type, request, charset); 1236 requestPreload(type, request, charset);
1237 } 1237 }
1238 1238
1239 void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request, const String& charset) 1239 void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request, const String& charset)
1240 { 1240 {
1241 // Ensure main resources aren't preloaded, since the cache can't actually re use the preload. 1241 // Ensure main resources aren't preloaded, since the cache can't actually re use the preload.
1242 if (type == Resource::MainResource) 1242 if (type == Resource::MainResource)
1243 return; 1243 return;
1244 1244
1245 ASSERT(type == Resource::Script || type == Resource::CSSStyleSheet || type = = Resource::Image);
Mike West 2014/11/11 13:34:18 Is this an exhaustive list of what goes through th
1246
1245 String encoding; 1247 String encoding;
1246 if (type == Resource::Script || type == Resource::CSSStyleSheet) 1248 if (type == Resource::Script || type == Resource::CSSStyleSheet) {
1247 encoding = charset.isEmpty() ? m_document->charset().string() : charset; 1249 encoding = charset.isEmpty() ? m_document->charset().string() : charset;
1248 1250
1251 // RequestContext for Resource::Image is set in fetchImage below.
1252 determineRequestContext(request.mutableResourceRequest(), type);
1253 }
1254
1249 request.setCharset(encoding); 1255 request.setCharset(encoding);
1250 request.setForPreload(true); 1256 request.setForPreload(true);
1251 1257
1252 ResourcePtr<Resource> resource; 1258 ResourcePtr<Resource> resource;
1253 // Loading images involves several special cases, so use dedicated fetch met hod instead. 1259 // Loading images involves several special cases, so use dedicated fetch met hod instead.
1254 if (type == Resource::Image) 1260 if (type == Resource::Image)
1255 resource = fetchImage(request); 1261 resource = fetchImage(request);
1262
1256 if (!resource) 1263 if (!resource)
1257 resource = requestResource(type, request); 1264 resource = requestResource(type, request);
1258 if (!resource || (m_preloads && m_preloads->contains(resource.get()))) 1265 if (!resource || (m_preloads && m_preloads->contains(resource.get())))
1259 return; 1266 return;
1260 TRACE_EVENT_ASYNC_STEP_INTO0("net", "Resource", resource.get(), "Preload"); 1267 TRACE_EVENT_ASYNC_STEP_INTO0("net", "Resource", resource.get(), "Preload");
1261 resource->increasePreloadCount(); 1268 resource->increasePreloadCount();
1262 1269
1263 if (!m_preloads) 1270 if (!m_preloads)
1264 m_preloads = adoptPtr(new ListHashSet<Resource*>); 1271 m_preloads = adoptPtr(new ListHashSet<Resource*>);
1265 m_preloads->add(resource.get()); 1272 m_preloads->add(resource.get());
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 1570
1564 void ResourceFetcher::trace(Visitor* visitor) 1571 void ResourceFetcher::trace(Visitor* visitor)
1565 { 1572 {
1566 visitor->trace(m_document); 1573 visitor->trace(m_document);
1567 visitor->trace(m_loaders); 1574 visitor->trace(m_loaders);
1568 visitor->trace(m_multipartLoaders); 1575 visitor->trace(m_multipartLoaders);
1569 ResourceLoaderHost::trace(visitor); 1576 ResourceLoaderHost::trace(visitor);
1570 } 1577 }
1571 1578
1572 } 1579 }
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