modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.cpp

Print this page




 805 {
 806     // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
 807     // FIXME: We should consider adding a setting to toggle aggressive preloading behavior as opposed
 808     // to making this behavior specific to iOS.
 809 #if !PLATFORM(IOS)
 810     bool hasRendering = m_document->body() && m_document->renderView();
 811     bool canBlockParser = type == CachedResource::Script || type == CachedResource::CSSStyleSheet;
 812     if (!hasRendering && !canBlockParser) {
 813         // Don't preload subresources that can't block the parser before we have something to draw.
 814         // This helps prevent preloads from delaying first display when bandwidth is limited.
 815         PendingPreload pendingPreload = { type, request, charset };
 816         m_pendingPreloads.append(pendingPreload);
 817         return;
 818     }
 819 #endif
 820     requestPreload(type, request, charset);
 821 }
 822 
 823 void CachedResourceLoader::checkForPendingPreloads()
 824 {
 825     if (m_pendingPreloads.isEmpty() || !m_document->body() || !m_document->body()->renderer())
 826         return;
 827 #if PLATFORM(IOS)
 828     // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
 829     // So, we should never have any pending preloads.
 830     // FIXME: We should look to avoid compiling this code entirely when building for iOS.
 831     ASSERT_NOT_REACHED();
 832 #endif
 833     while (!m_pendingPreloads.isEmpty()) {
 834         PendingPreload preload = m_pendingPreloads.takeFirst();
 835         // Don't request preload if the resource already loaded normally (this will result in double load if the page is being reloaded with cached results ignored).
 836         if (!cachedResource(preload.m_request.resourceRequest().url()))
 837             requestPreload(preload.m_type, preload.m_request, preload.m_charset);
 838     }
 839     m_pendingPreloads.clear();
 840 }
 841 
 842 void CachedResourceLoader::requestPreload(CachedResource::Type type, CachedResourceRequest& request, const String& charset)
 843 {
 844     String encoding;
 845     if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet)




 805 {
 806     // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
 807     // FIXME: We should consider adding a setting to toggle aggressive preloading behavior as opposed
 808     // to making this behavior specific to iOS.
 809 #if !PLATFORM(IOS)
 810     bool hasRendering = m_document->body() && m_document->renderView();
 811     bool canBlockParser = type == CachedResource::Script || type == CachedResource::CSSStyleSheet;
 812     if (!hasRendering && !canBlockParser) {
 813         // Don't preload subresources that can't block the parser before we have something to draw.
 814         // This helps prevent preloads from delaying first display when bandwidth is limited.
 815         PendingPreload pendingPreload = { type, request, charset };
 816         m_pendingPreloads.append(pendingPreload);
 817         return;
 818     }
 819 #endif
 820     requestPreload(type, request, charset);
 821 }
 822 
 823 void CachedResourceLoader::checkForPendingPreloads()
 824 {
 825     if (m_pendingPreloads.isEmpty() || !m_document || !m_document->body() || !m_document->body()->renderer())
 826         return;
 827 #if PLATFORM(IOS)
 828     // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
 829     // So, we should never have any pending preloads.
 830     // FIXME: We should look to avoid compiling this code entirely when building for iOS.
 831     ASSERT_NOT_REACHED();
 832 #endif
 833     while (!m_pendingPreloads.isEmpty()) {
 834         PendingPreload preload = m_pendingPreloads.takeFirst();
 835         // Don't request preload if the resource already loaded normally (this will result in double load if the page is being reloaded with cached results ignored).
 836         if (!cachedResource(preload.m_request.resourceRequest().url()))
 837             requestPreload(preload.m_type, preload.m_request, preload.m_charset);
 838     }
 839     m_pendingPreloads.clear();
 840 }
 841 
 842 void CachedResourceLoader::requestPreload(CachedResource::Type type, CachedResourceRequest& request, const String& charset)
 843 {
 844     String encoding;
 845     if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet)