| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 , m_linkLoadingErrorTimer(this, &LinkLoader::linkLoadingErrorTimerFired) | 77 , m_linkLoadingErrorTimer(this, &LinkLoader::linkLoadingErrorTimerFired) |
| 78 { | 78 { |
| 79 } | 79 } |
| 80 | 80 |
| 81 LinkLoader::~LinkLoader() | 81 LinkLoader::~LinkLoader() |
| 82 { | 82 { |
| 83 } | 83 } |
| 84 | 84 |
| 85 void LinkLoader::linkLoadTimerFired(TimerBase* timer) | 85 void LinkLoader::linkLoadTimerFired(TimerBase* timer) |
| 86 { | 86 { |
| 87 ASSERT_UNUSED(timer, timer == &m_linkLoadTimer); | 87 DCHECK_EQ(timer, &m_linkLoadTimer); |
| 88 m_client->linkLoaded(); | 88 m_client->linkLoaded(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void LinkLoader::linkLoadingErrorTimerFired(TimerBase* timer) | 91 void LinkLoader::linkLoadingErrorTimerFired(TimerBase* timer) |
| 92 { | 92 { |
| 93 ASSERT_UNUSED(timer, timer == &m_linkLoadingErrorTimer); | 93 DCHECK_EQ(timer, &m_linkLoadingErrorTimer); |
| 94 m_client->linkLoadingErrored(); | 94 m_client->linkLoadingErrored(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void LinkLoader::triggerEvents(const Resource* resource) | 97 void LinkLoader::triggerEvents(const Resource* resource) |
| 98 { | 98 { |
| 99 if (resource->errorOccurred()) | 99 if (resource->errorOccurred()) |
| 100 m_linkLoadingErrorTimer.startOneShot(0, BLINK_FROM_HERE); | 100 m_linkLoadingErrorTimer.startOneShot(0, BLINK_FROM_HERE); |
| 101 else | 101 else |
| 102 m_linkLoadTimer.startOneShot(0, BLINK_FROM_HERE); | 102 m_linkLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void LinkLoader::notifyFinished(Resource* resource) | 105 void LinkLoader::notifyFinished(Resource* resource) |
| 106 { | 106 { |
| 107 ASSERT(this->resource() == resource); | 107 DCHECK_EQ(this->resource(), resource); |
| 108 | 108 |
| 109 triggerEvents(resource); | 109 triggerEvents(resource); |
| 110 clearResource(); | 110 clearResource(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void LinkLoader::didStartPrerender() | 113 void LinkLoader::didStartPrerender() |
| 114 { | 114 { |
| 115 m_client->didStartLinkPrerender(); | 115 m_client->didStartLinkPrerender(); |
| 116 } | 116 } |
| 117 | 117 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, | 166 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, |
| 167 String("Preconnect CORS setting is ") + String((crossOrigin
== CrossOriginAttributeAnonymous) ? "anonymous" : "use-credentials"))); | 167 String("Preconnect CORS setting is ") + String((crossOrigin
== CrossOriginAttributeAnonymous) ? "anonymous" : "use-credentials"))); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 networkHintsInterface.preconnectHost(href, crossOrigin); | 170 networkHintsInterface.preconnectHost(href, crossOrigin); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool LinkLoader::getResourceTypeFromAsAttribute(const String& as, Resource::Type
& type) | 174 bool LinkLoader::getResourceTypeFromAsAttribute(const String& as, Resource::Type
& type) |
| 175 { | 175 { |
| 176 ASSERT(as.lower() == as); | 176 DCHECK_EQ(as.lower(), as); |
| 177 if (as == "image") { | 177 if (as == "image") { |
| 178 type = Resource::Image; | 178 type = Resource::Image; |
| 179 } else if (as == "script") { | 179 } else if (as == "script") { |
| 180 type = Resource::Script; | 180 type = Resource::Script; |
| 181 } else if (as == "style") { | 181 } else if (as == "style") { |
| 182 type = Resource::CSSStyleSheet; | 182 type = Resource::CSSStyleSheet; |
| 183 } else if (as == "media") { | 183 } else if (as == "media") { |
| 184 type = Resource::Media; | 184 type = Resource::Media; |
| 185 } else if (as == "font") { | 185 } else if (as == "font") { |
| 186 type = Resource::Font; | 186 type = Resource::Font; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 210 break; | 210 break; |
| 211 case Resource::Font: | 211 case Resource::Font: |
| 212 m_linkPreloadResourceClient = LinkPreloadFontResourceClient::create(this
, toFontResource(resource)); | 212 m_linkPreloadResourceClient = LinkPreloadFontResourceClient::create(this
, toFontResource(resource)); |
| 213 break; | 213 break; |
| 214 case Resource::Media: | 214 case Resource::Media: |
| 215 case Resource::TextTrack: | 215 case Resource::TextTrack: |
| 216 case Resource::Raw: | 216 case Resource::Raw: |
| 217 m_linkPreloadResourceClient = LinkPreloadRawResourceClient::create(this,
toRawResource(resource)); | 217 m_linkPreloadResourceClient = LinkPreloadRawResourceClient::create(this,
toRawResource(resource)); |
| 218 break; | 218 break; |
| 219 default: | 219 default: |
| 220 ASSERT_NOT_REACHED(); | 220 NOTREACHED(); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 static bool isSupportedType(Resource::Type resourceType, const String& mimeType) | 224 static bool isSupportedType(Resource::Type resourceType, const String& mimeType) |
| 225 { | 225 { |
| 226 if (mimeType.isEmpty()) | 226 if (mimeType.isEmpty()) |
| 227 return true; | 227 return true; |
| 228 switch (resourceType) { | 228 switch (resourceType) { |
| 229 case Resource::Image: | 229 case Resource::Image: |
| 230 return MIMETypeRegistry::isSupportedImagePrefixedMIMEType(mimeType); | 230 return MIMETypeRegistry::isSupportedImagePrefixedMIMEType(mimeType); |
| 231 case Resource::Script: | 231 case Resource::Script: |
| 232 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType); | 232 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType); |
| 233 case Resource::CSSStyleSheet: | 233 case Resource::CSSStyleSheet: |
| 234 return MIMETypeRegistry::isSupportedStyleSheetMIMEType(mimeType); | 234 return MIMETypeRegistry::isSupportedStyleSheetMIMEType(mimeType); |
| 235 case Resource::Font: | 235 case Resource::Font: |
| 236 return MIMETypeRegistry::isSupportedFontMIMEType(mimeType); | 236 return MIMETypeRegistry::isSupportedFontMIMEType(mimeType); |
| 237 case Resource::Media: | 237 case Resource::Media: |
| 238 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(mimeType, String
()); | 238 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(mimeType, String
()); |
| 239 case Resource::TextTrack: | 239 case Resource::TextTrack: |
| 240 return MIMETypeRegistry::isSupportedTextTrackMIMEType(mimeType); | 240 return MIMETypeRegistry::isSupportedTextTrackMIMEType(mimeType); |
| 241 case Resource::Raw: | 241 case Resource::Raw: |
| 242 return true; | 242 return true; |
| 243 default: | 243 default: |
| 244 ASSERT_NOT_REACHED(); | 244 NOTREACHED(); |
| 245 } | 245 } |
| 246 return false; | 246 return false; |
| 247 } | 247 } |
| 248 | 248 |
| 249 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, const KUR
L& href, Document& document, const String& as, const String& mimeType, | 249 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, const KUR
L& href, Document& document, const String& as, const String& mimeType, |
| 250 const String& media, CrossOriginAttributeValue crossOrigin, LinkCaller calle
r, bool& errorOccurred, ViewportDescription* viewportDescription) | 250 const String& media, CrossOriginAttributeValue crossOrigin, LinkCaller calle
r, bool& errorOccurred, ViewportDescription* viewportDescription) |
| 251 { | 251 { |
| 252 if (!document.loader() || !relAttribute.isLinkPreload()) | 252 if (!document.loader() || !relAttribute.isLinkPreload()) |
| 253 return nullptr; | 253 return nullptr; |
| 254 | 254 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 DEFINE_TRACE(LinkLoader) | 392 DEFINE_TRACE(LinkLoader) |
| 393 { | 393 { |
| 394 visitor->trace(m_client); | 394 visitor->trace(m_client); |
| 395 visitor->trace(m_prerender); | 395 visitor->trace(m_prerender); |
| 396 visitor->trace(m_linkPreloadResourceClient); | 396 visitor->trace(m_linkPreloadResourceClient); |
| 397 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 397 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
| 398 PrerenderClient::trace(visitor); | 398 PrerenderClient::trace(visitor); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |