| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/html/parser/HTMLResourcePreloader.h" | 26 #include "core/html/parser/HTMLResourcePreloader.h" |
| 27 | 27 |
| 28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 29 #include "core/fetch/CSSStyleSheetResource.h" | 29 #include "core/fetch/CSSStyleSheetResource.h" |
| 30 #include "core/fetch/FetchInitiatorInfo.h" | 30 #include "core/fetch/FetchInitiatorInfo.h" |
| 31 #include "core/fetch/ResourceFetcher.h" | 31 #include "core/fetch/ResourceFetcher.h" |
| 32 #include "core/frame/Deprecation.h" |
| 32 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 33 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/DocumentLoader.h" |
| 34 #include "platform/Histogram.h" | 35 #include "platform/Histogram.h" |
| 35 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 36 #include <memory> | 37 #include <memory> |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 inline HTMLResourcePreloader::HTMLResourcePreloader(Document& document) | 41 inline HTMLResourcePreloader::HTMLResourcePreloader(Document& document) |
| 41 : m_document(document) | 42 : m_document(document) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // making Document::completeURLWithOverride logic to be statically accessibl
e. | 85 // making Document::completeURLWithOverride logic to be statically accessibl
e. |
| 85 if (request.url().protocolIsData()) | 86 if (request.url().protocolIsData()) |
| 86 return; | 87 return; |
| 87 if (preload->resourceType() == Resource::Script || preload->resourceType() =
= Resource::CSSStyleSheet || preload->resourceType() == Resource::ImportResource
) | 88 if (preload->resourceType() == Resource::Script || preload->resourceType() =
= Resource::CSSStyleSheet || preload->resourceType() == Resource::ImportResource
) |
| 88 request.setCharset(preload->charset().isEmpty() ? m_document->characterS
et().getString() : preload->charset()); | 89 request.setCharset(preload->charset().isEmpty() ? m_document->characterS
et().getString() : preload->charset()); |
| 89 request.setForPreload(true, preload->discoveryTime()); | 90 request.setForPreload(true, preload->discoveryTime()); |
| 90 int duration = static_cast<int>(1000 * (monotonicallyIncreasingTime() - prel
oad->discoveryTime())); | 91 int duration = static_cast<int>(1000 * (monotonicallyIncreasingTime() - prel
oad->discoveryTime())); |
| 91 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, ("WebCore.P
reloadDelayMs", 0, 2000, 20)); | 92 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, ("WebCore.P
reloadDelayMs", 0, 2000, 20)); |
| 92 preloadDelayHistogram.count(duration); | 93 preloadDelayHistogram.count(duration); |
| 93 | 94 |
| 95 if (preload->scriptHasInvalidTypeOrLanguage()) { |
| 96 Deprecation::countDeprecation(m_document, UseCounter::ScriptInvalidTypeO
rLanguage); |
| 97 } |
| 98 |
| 94 Resource* resource = m_document->loader()->startPreload(preload->resourceTyp
e(), request); | 99 Resource* resource = m_document->loader()->startPreload(preload->resourceTyp
e(), request); |
| 95 if (resource && preload->resourceType() == Resource::CSSStyleSheet) { | 100 if (resource && preload->resourceType() == Resource::CSSStyleSheet) { |
| 96 Settings* settings = m_document->settings(); | 101 Settings* settings = m_document->settings(); |
| 97 if (settings && (settings->cssExternalScannerNoPreload() || settings->cs
sExternalScannerPreload())) | 102 if (settings && (settings->cssExternalScannerNoPreload() || settings->cs
sExternalScannerPreload())) |
| 98 m_cssPreloaders.add(new CSSPreloaderResourceClient(resource, this)); | 103 m_cssPreloaders.add(new CSSPreloaderResourceClient(resource, this)); |
| 99 } | 104 } |
| 100 } | 105 } |
| 101 | 106 |
| 102 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |