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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (caller == LinkCalledFromHeader) | 137 if (caller == LinkCalledFromHeader) |
138 UseCounter::count(document, UseCounter::LinkHeaderDnsPrefetch); | 138 UseCounter::count(document, UseCounter::LinkHeaderDnsPrefetch); |
139 Settings* settings = document.settings(); | 139 Settings* settings = document.settings(); |
140 // FIXME: The href attribute of the link element can be in "//hostname" | 140 // FIXME: The href attribute of the link element can be in "//hostname" |
141 // form, and we shouldn't attempt to complete that as URL | 141 // form, and we shouldn't attempt to complete that as URL |
142 // <https://bugs.webkit.org/show_bug.cgi?id=48857>. | 142 // <https://bugs.webkit.org/show_bug.cgi?id=48857>. |
143 if (settings && settings->getDNSPrefetchingEnabled() && href.isValid() && | 143 if (settings && settings->getDNSPrefetchingEnabled() && href.isValid() && |
144 !href.isEmpty()) { | 144 !href.isEmpty()) { |
145 if (settings->getLogDnsPrefetchAndPreconnect()) { | 145 if (settings->getLogDnsPrefetchAndPreconnect()) { |
146 document.addConsoleMessage(ConsoleMessage::create( | 146 document.addConsoleMessage(ConsoleMessage::create( |
147 OtherMessageSource, DebugMessageLevel, | 147 OtherMessageSource, VerboseMessageLevel, |
148 String("DNS prefetch triggered for " + href.host()))); | 148 String("DNS prefetch triggered for " + href.host()))); |
149 } | 149 } |
150 networkHintsInterface.dnsPrefetchHost(href.host()); | 150 networkHintsInterface.dnsPrefetchHost(href.host()); |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 static void preconnectIfNeeded( | 155 static void preconnectIfNeeded( |
156 const LinkRelAttribute& relAttribute, | 156 const LinkRelAttribute& relAttribute, |
157 const KURL& href, | 157 const KURL& href, |
158 Document& document, | 158 Document& document, |
159 const CrossOriginAttributeValue crossOrigin, | 159 const CrossOriginAttributeValue crossOrigin, |
160 const NetworkHintsInterface& networkHintsInterface, | 160 const NetworkHintsInterface& networkHintsInterface, |
161 LinkCaller caller) { | 161 LinkCaller caller) { |
162 if (relAttribute.isPreconnect() && href.isValid() && | 162 if (relAttribute.isPreconnect() && href.isValid() && |
163 href.protocolIsInHTTPFamily()) { | 163 href.protocolIsInHTTPFamily()) { |
164 UseCounter::count(document, UseCounter::LinkRelPreconnect); | 164 UseCounter::count(document, UseCounter::LinkRelPreconnect); |
165 if (caller == LinkCalledFromHeader) | 165 if (caller == LinkCalledFromHeader) |
166 UseCounter::count(document, UseCounter::LinkHeaderPreconnect); | 166 UseCounter::count(document, UseCounter::LinkHeaderPreconnect); |
167 Settings* settings = document.settings(); | 167 Settings* settings = document.settings(); |
168 if (settings && settings->getLogDnsPrefetchAndPreconnect()) { | 168 if (settings && settings->getLogDnsPrefetchAndPreconnect()) { |
169 document.addConsoleMessage(ConsoleMessage::create( | 169 document.addConsoleMessage(ConsoleMessage::create( |
170 OtherMessageSource, DebugMessageLevel, | 170 OtherMessageSource, VerboseMessageLevel, |
171 String("Preconnect triggered for ") + href.getString())); | 171 String("Preconnect triggered for ") + href.getString())); |
172 if (crossOrigin != CrossOriginAttributeNotSet) { | 172 if (crossOrigin != CrossOriginAttributeNotSet) { |
173 document.addConsoleMessage(ConsoleMessage::create( | 173 document.addConsoleMessage(ConsoleMessage::create( |
174 OtherMessageSource, DebugMessageLevel, | 174 OtherMessageSource, VerboseMessageLevel, |
175 String("Preconnect CORS setting is ") + | 175 String("Preconnect CORS setting is ") + |
176 String((crossOrigin == CrossOriginAttributeAnonymous) | 176 String((crossOrigin == CrossOriginAttributeAnonymous) |
177 ? "anonymous" | 177 ? "anonymous" |
178 : "use-credentials"))); | 178 : "use-credentials"))); |
179 } | 179 } |
180 } | 180 } |
181 networkHintsInterface.preconnectHost(href, crossOrigin); | 181 networkHintsInterface.preconnectHost(href, crossOrigin); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, | 326 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, |
327 document.encodingName()); | 327 document.encodingName()); |
328 | 328 |
329 if (crossOrigin != CrossOriginAttributeNotSet) { | 329 if (crossOrigin != CrossOriginAttributeNotSet) { |
330 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), | 330 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), |
331 crossOrigin); | 331 crossOrigin); |
332 } | 332 } |
333 Settings* settings = document.settings(); | 333 Settings* settings = document.settings(); |
334 if (settings && settings->getLogPreload()) { | 334 if (settings && settings->getLogPreload()) { |
335 document.addConsoleMessage(ConsoleMessage::create( | 335 document.addConsoleMessage(ConsoleMessage::create( |
336 OtherMessageSource, DebugMessageLevel, | 336 OtherMessageSource, VerboseMessageLevel, |
337 String("Preload triggered for " + href.host() + href.path()))); | 337 String("Preload triggered for " + href.host() + href.path()))); |
338 } | 338 } |
339 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); | 339 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); |
340 linkRequest.setLinkPreload(true); | 340 linkRequest.setLinkPreload(true); |
341 return document.loader()->startPreload(resourceType.value(), linkRequest); | 341 return document.loader()->startPreload(resourceType.value(), linkRequest); |
342 } | 342 } |
343 | 343 |
344 static Resource* prefetchIfNeeded(Document& document, | 344 static Resource* prefetchIfNeeded(Document& document, |
345 const KURL& href, | 345 const KURL& href, |
346 const LinkRelAttribute& relAttribute, | 346 const LinkRelAttribute& relAttribute, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 DEFINE_TRACE(LinkLoader) { | 487 DEFINE_TRACE(LinkLoader) { |
488 visitor->trace(m_client); | 488 visitor->trace(m_client); |
489 visitor->trace(m_prerender); | 489 visitor->trace(m_prerender); |
490 visitor->trace(m_linkPreloadResourceClient); | 490 visitor->trace(m_linkPreloadResourceClient); |
491 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 491 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
492 PrerenderClient::trace(visitor); | 492 PrerenderClient::trace(visitor); |
493 } | 493 } |
494 | 494 |
495 } // namespace blink | 495 } // namespace blink |
OLD | NEW |