| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 std::unique_ptr<PreloadRequest> preload, | 70 std::unique_ptr<PreloadRequest> preload, |
| 71 const NetworkHintsInterface& networkHintsInterface) { | 71 const NetworkHintsInterface& networkHintsInterface) { |
| 72 if (preload->isPreconnect()) { | 72 if (preload->isPreconnect()) { |
| 73 preconnectHost(preload.get(), networkHintsInterface); | 73 preconnectHost(preload.get(), networkHintsInterface); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 // TODO(yoichio): Should preload if document is imported. | 76 // TODO(yoichio): Should preload if document is imported. |
| 77 if (!m_document->loader()) | 77 if (!m_document->loader()) |
| 78 return; | 78 return; |
| 79 FetchRequest request = preload->resourceRequest(m_document); | 79 FetchRequest request = preload->resourceRequest(m_document); |
| 80 // TODO(dgozman): This check should go to HTMLPreloadScanner, but this | 80 |
| 81 // requires making Document::completeURLWithOverride logic to be statically | 81 // Data URLs are filtered out in the preload scanner. |
| 82 // accessible. | 82 DCHECK(!request.url().protocolIsData()); |
| 83 if (request.url().protocolIsData()) | 83 |
| 84 return; | |
| 85 if (preload->resourceType() == Resource::Script || | 84 if (preload->resourceType() == Resource::Script || |
| 86 preload->resourceType() == Resource::CSSStyleSheet || | 85 preload->resourceType() == Resource::CSSStyleSheet || |
| 87 preload->resourceType() == Resource::ImportResource) | 86 preload->resourceType() == Resource::ImportResource) |
| 88 request.setCharset(preload->charset().isEmpty() | 87 request.setCharset(preload->charset().isEmpty() |
| 89 ? m_document->characterSet().getString() | 88 ? m_document->characterSet().getString() |
| 90 : preload->charset()); | 89 : preload->charset()); |
| 91 request.setForPreload(true, preload->discoveryTime()); | 90 request.setForPreload(true, preload->discoveryTime()); |
| 92 int duration = static_cast<int>( | 91 int duration = static_cast<int>( |
| 93 1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())); | 92 1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())); |
| 94 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, | 93 DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, |
| 95 ("WebCore.PreloadDelayMs", 0, 2000, 20)); | 94 ("WebCore.PreloadDelayMs", 0, 2000, 20)); |
| 96 preloadDelayHistogram.count(duration); | 95 preloadDelayHistogram.count(duration); |
| 97 | 96 |
| 98 if (preload->scriptHasInvalidTypeOrLanguage()) { | 97 if (preload->scriptHasInvalidTypeOrLanguage()) { |
| 99 Deprecation::countDeprecation(m_document, | 98 Deprecation::countDeprecation(m_document, |
| 100 UseCounter::ScriptInvalidTypeOrLanguage); | 99 UseCounter::ScriptInvalidTypeOrLanguage); |
| 101 } | 100 } |
| 102 | 101 |
| 103 Resource* resource = | 102 Resource* resource = |
| 104 m_document->loader()->startPreload(preload->resourceType(), request); | 103 m_document->loader()->startPreload(preload->resourceType(), request); |
| 105 if (resource && preload->resourceType() == Resource::CSSStyleSheet) { | 104 if (resource && preload->resourceType() == Resource::CSSStyleSheet) { |
| 106 Settings* settings = m_document->settings(); | 105 Settings* settings = m_document->settings(); |
| 107 if (settings && (settings->cssExternalScannerNoPreload() || | 106 if (settings && (settings->cssExternalScannerNoPreload() || |
| 108 settings->cssExternalScannerPreload())) | 107 settings->cssExternalScannerPreload())) |
| 109 m_cssPreloaders.add(new CSSPreloaderResourceClient(resource, this)); | 108 m_cssPreloaders.add(new CSSPreloaderResourceClient(resource, this)); |
| 110 } | 109 } |
| 111 } | 110 } |
| 112 | 111 |
| 113 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |