| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); | 125 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSo
urce, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); |
| 126 prefetchDNS(href.host()); | 126 prefetchDNS(href.host()); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL&
href, Document& document) | 131 static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL&
href, Document& document) |
| 132 { | 132 { |
| 133 if (relAttribute.isPreconnect() && href.isValid()) { | 133 if (relAttribute.isPreconnect() && href.isValid()) { |
| 134 ASSERT(RuntimeEnabledFeatures::linkPreconnectEnabled()); | 134 ASSERT(RuntimeEnabledFeatures::linkPreconnectEnabled()); |
| 135 if (document.settings()->logDnsPrefetchAndPreconnect()) | 135 Settings* settings = document.settings(); |
| 136 if (settings && settings->logDnsPrefetchAndPreconnect()) |
| 136 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, DebugMessageLevel, String("Preconnect triggered for " + href.host()))); | 137 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, DebugMessageLevel, String("Preconnect triggered for " + href.host()))); |
| 137 preconnect(href); | 138 preconnect(href); |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 | 141 |
| 141 // TODO(yoav): Replace Resource:Type here with some way that conveys priority bu
t not context. | 142 // TODO(yoav): Replace Resource:Type here with some way that conveys priority bu
t not context. |
| 142 static bool getTypeFromAsAttribute(const String& as, Resource::Type& type) | 143 static bool getTypeFromAsAttribute(const String& as, Resource::Type& type) |
| 143 { | 144 { |
| 144 if (as.isEmpty()) | 145 if (as.isEmpty()) |
| 145 return false; | 146 return false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 156 if (!href.isValid() || href.isEmpty()) { | 157 if (!href.isValid() || href.isEmpty()) { |
| 157 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, WarningMessageLevel, String("<link rel=preload> has an invalid `href` value"))
); | 158 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, WarningMessageLevel, String("<link rel=preload> has an invalid `href` value"))
); |
| 158 return; | 159 return; |
| 159 } | 160 } |
| 160 Resource::Type type; | 161 Resource::Type type; |
| 161 if (!getTypeFromAsAttribute(as, type)) { | 162 if (!getTypeFromAsAttribute(as, type)) { |
| 162 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, WarningMessageLevel, String("<link rel=preload> must have a valid `as` value")
)); | 163 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, WarningMessageLevel, String("<link rel=preload> must have a valid `as` value")
)); |
| 163 return; | 164 return; |
| 164 } | 165 } |
| 165 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); | 166 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); |
| 166 if (document.settings()->logPreload()) | 167 Settings* settings = document.settings(); |
| 168 if (settings && settings->logPreload()) |
| 167 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, DebugMessageLevel, String("Preload triggered for " + href.host() + href.path()
))); | 169 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource
, DebugMessageLevel, String("Preload triggered for " + href.host() + href.path()
))); |
| 168 setResource(document.fetcher()->fetchLinkPreloadResource(type, linkReque
st)); | 170 setResource(document.fetcher()->fetchLinkPreloadResource(type, linkReque
st)); |
| 169 } | 171 } |
| 170 } | 172 } |
| 171 | 173 |
| 172 bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
t) | 174 bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
t) |
| 173 { | 175 { |
| 174 if (!document) | 176 if (!document) |
| 175 return false; | 177 return false; |
| 176 LinkHeaderSet headerSet(headerValue); | 178 LinkHeaderSet headerSet(headerValue); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 m_prerender.clear(); | 236 m_prerender.clear(); |
| 235 } | 237 } |
| 236 } | 238 } |
| 237 | 239 |
| 238 DEFINE_TRACE(LinkLoader) | 240 DEFINE_TRACE(LinkLoader) |
| 239 { | 241 { |
| 240 visitor->trace(m_prerender); | 242 visitor->trace(m_prerender); |
| 241 } | 243 } |
| 242 | 244 |
| 243 } | 245 } |
| OLD | NEW |