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

Side by Side Diff: third_party/WebKit/Source/core/loader/LinkLoader.cpp

Issue 2486193002: HTMLImport preload support
Patch Set: 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
« 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } else if (as == "script") { 190 } else if (as == "script") {
191 type = Resource::Script; 191 type = Resource::Script;
192 } else if (as == "style") { 192 } else if (as == "style") {
193 type = Resource::CSSStyleSheet; 193 type = Resource::CSSStyleSheet;
194 } else if (as == "media") { 194 } else if (as == "media") {
195 type = Resource::Media; 195 type = Resource::Media;
196 } else if (as == "font") { 196 } else if (as == "font") {
197 type = Resource::Font; 197 type = Resource::Font;
198 } else if (as == "track") { 198 } else if (as == "track") {
199 type = Resource::TextTrack; 199 type = Resource::TextTrack;
200 } else if (as == "import") {
201 // This is a non-specced, proprietary value and we should not ship this
202 // without previous discussion!!!!
203 type = Resource::ImportResource;
200 } else { 204 } else {
201 type = Resource::Raw; 205 type = Resource::Raw;
202 if (!as.isEmpty()) 206 if (!as.isEmpty())
203 return false; 207 return false;
204 } 208 }
205 return true; 209 return true;
206 } 210 }
207 211
208 void LinkLoader::createLinkPreloadResourceClient(Resource* resource) { 212 void LinkLoader::createLinkPreloadResourceClient(Resource* resource) {
209 if (!resource) 213 if (!resource)
210 return; 214 return;
211 switch (resource->getType()) { 215 switch (resource->getType()) {
212 case Resource::Image: 216 case Resource::Image:
213 m_linkPreloadResourceClient = LinkPreloadImageResourceClient::create( 217 m_linkPreloadResourceClient = LinkPreloadImageResourceClient::create(
214 this, toImageResource(resource)); 218 this, toImageResource(resource));
215 break; 219 break;
216 case Resource::Script: 220 case Resource::Script:
217 m_linkPreloadResourceClient = LinkPreloadScriptResourceClient::create( 221 m_linkPreloadResourceClient = LinkPreloadScriptResourceClient::create(
218 this, toScriptResource(resource)); 222 this, toScriptResource(resource));
219 break; 223 break;
220 case Resource::CSSStyleSheet: 224 case Resource::CSSStyleSheet:
221 m_linkPreloadResourceClient = LinkPreloadStyleResourceClient::create( 225 m_linkPreloadResourceClient = LinkPreloadStyleResourceClient::create(
222 this, toCSSStyleSheetResource(resource)); 226 this, toCSSStyleSheetResource(resource));
223 break; 227 break;
224 case Resource::Font: 228 case Resource::Font:
225 m_linkPreloadResourceClient = 229 m_linkPreloadResourceClient =
226 LinkPreloadFontResourceClient::create(this, toFontResource(resource)); 230 LinkPreloadFontResourceClient::create(this, toFontResource(resource));
227 break; 231 break;
232 case Resource::ImportResource:
228 case Resource::Media: 233 case Resource::Media:
229 case Resource::TextTrack: 234 case Resource::TextTrack:
230 case Resource::Raw: 235 case Resource::Raw:
231 m_linkPreloadResourceClient = 236 m_linkPreloadResourceClient =
232 LinkPreloadRawResourceClient::create(this, toRawResource(resource)); 237 LinkPreloadRawResourceClient::create(this, toRawResource(resource));
233 break; 238 break;
234 default: 239 default:
235 NOTREACHED(); 240 NOTREACHED();
236 } 241 }
237 } 242 }
238 243
239 static bool isSupportedType(Resource::Type resourceType, 244 static bool isSupportedType(Resource::Type resourceType,
240 const String& mimeType) { 245 const String& mimeType) {
241 if (mimeType.isEmpty()) 246 if (mimeType.isEmpty())
242 return true; 247 return true;
243 switch (resourceType) { 248 switch (resourceType) {
244 case Resource::Image: 249 case Resource::Image:
245 return MIMETypeRegistry::isSupportedImagePrefixedMIMEType(mimeType); 250 return MIMETypeRegistry::isSupportedImagePrefixedMIMEType(mimeType);
246 case Resource::Script: 251 case Resource::Script:
247 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType); 252 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType);
248 case Resource::CSSStyleSheet: 253 case Resource::CSSStyleSheet:
249 return MIMETypeRegistry::isSupportedStyleSheetMIMEType(mimeType); 254 return MIMETypeRegistry::isSupportedStyleSheetMIMEType(mimeType);
250 case Resource::Font: 255 case Resource::Font:
251 return MIMETypeRegistry::isSupportedFontMIMEType(mimeType); 256 return MIMETypeRegistry::isSupportedFontMIMEType(mimeType);
252 case Resource::Media: 257 case Resource::Media:
253 return MIMETypeRegistry::isSupportedMediaMIMEType(mimeType, String()); 258 return MIMETypeRegistry::isSupportedMediaMIMEType(mimeType, String());
254 case Resource::TextTrack: 259 case Resource::TextTrack:
255 return MIMETypeRegistry::isSupportedTextTrackMIMEType(mimeType); 260 return MIMETypeRegistry::isSupportedTextTrackMIMEType(mimeType);
261 case Resource::ImportResource:
256 case Resource::Raw: 262 case Resource::Raw:
257 return true; 263 return true;
258 default: 264 default:
259 NOTREACHED(); 265 NOTREACHED();
260 } 266 }
261 return false; 267 return false;
262 } 268 }
263 269
264 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, 270 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute,
265 const KURL& href, 271 const KURL& href,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 483
478 DEFINE_TRACE(LinkLoader) { 484 DEFINE_TRACE(LinkLoader) {
479 visitor->trace(m_client); 485 visitor->trace(m_client);
480 visitor->trace(m_prerender); 486 visitor->trace(m_prerender);
481 visitor->trace(m_linkPreloadResourceClient); 487 visitor->trace(m_linkPreloadResourceClient);
482 ResourceOwner<Resource, ResourceClient>::trace(visitor); 488 ResourceOwner<Resource, ResourceClient>::trace(visitor);
483 PrerenderClient::trace(visitor); 489 PrerenderClient::trace(visitor);
484 } 490 }
485 491
486 } // namespace blink 492 } // 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