< prev index next >

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

Print this page




 273     case CachedResource::MainResource:
 274 #if ENABLE(LINK_PREFETCH)
 275     case CachedResource::LinkPrefetch:
 276     case CachedResource::LinkSubresource:
 277         // Prefetch cannot affect the current document.
 278 #endif
 279         break;
 280     }
 281     return true;
 282 }
 283 
 284 bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload)
 285 {
 286     if (document() && !document()->securityOrigin()->canDisplay(url)) {
 287         if (!forPreload)
 288             FrameLoader::reportLocalLoadFailed(frame(), url.stringCenterEllipsizedToLength());
 289         LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay");
 290         return 0;
 291     }
 292 




 293     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
 294     bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy());
 295 
 296     // Some types of resources can be loaded only from the same origin.  Other
 297     // types of resources, like Images, Scripts, and CSS, can be loaded from
 298     // any URL.
 299     switch (type) {
 300     case CachedResource::MainResource:
 301     case CachedResource::ImageResource:
 302     case CachedResource::CSSStyleSheet:
 303     case CachedResource::Script:
 304     case CachedResource::FontResource:
 305     case CachedResource::RawResource:
 306 #if ENABLE(LINK_PREFETCH)
 307     case CachedResource::LinkPrefetch:
 308     case CachedResource::LinkSubresource:
 309 #endif
 310 #if ENABLE(VIDEO_TRACK)
 311     case CachedResource::TextTrackResource:
 312 #endif


 763 
 764 void CachedResourceLoader::garbageCollectDocumentResources()
 765 {
 766     typedef Vector<String, 10> StringVector;
 767     StringVector resourcesToDelete;
 768 
 769     for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m_documentResources.end(); ++it) {
 770         if (it->value->hasOneHandle()) {
 771             resourcesToDelete.append(it->key);
 772             it->value->setOwningCachedResourceLoader(0);
 773         }
 774     }
 775 
 776     for (StringVector::const_iterator it = resourcesToDelete.begin(); it != resourcesToDelete.end(); ++it)
 777         m_documentResources.remove(*it);
 778 }
 779 
 780 void CachedResourceLoader::performPostLoadActions()
 781 {
 782     checkForPendingPreloads();





 783 
 784     platformStrategies()->loaderStrategy()->resourceLoadScheduler()->servePendingRequests();
 785 }
 786 
 787 void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
 788 {
 789     if (res->ignoreForRequestCount())
 790         return;
 791 
 792     ++m_requestCount;
 793 }
 794 
 795 void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
 796 {
 797     if (res->ignoreForRequestCount())
 798         return;
 799 
 800     --m_requestCount;
 801     ASSERT(m_requestCount > -1);
 802 }




 273     case CachedResource::MainResource:
 274 #if ENABLE(LINK_PREFETCH)
 275     case CachedResource::LinkPrefetch:
 276     case CachedResource::LinkSubresource:
 277         // Prefetch cannot affect the current document.
 278 #endif
 279         break;
 280     }
 281     return true;
 282 }
 283 
 284 bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, bool forPreload)
 285 {
 286     if (document() && !document()->securityOrigin()->canDisplay(url)) {
 287         if (!forPreload)
 288             FrameLoader::reportLocalLoadFailed(frame(), url.stringCenterEllipsizedToLength());
 289         LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay");
 290         return 0;
 291     }
 292 
 293     // Don't load for user cancel or stop
 294     if (m_documentLoader && !m_documentLoader->mainDocumentError().isNull() && m_documentLoader->mainDocumentError().isCancellation())
 295         return false;
 296 
 297     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
 298     bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy());
 299 
 300     // Some types of resources can be loaded only from the same origin.  Other
 301     // types of resources, like Images, Scripts, and CSS, can be loaded from
 302     // any URL.
 303     switch (type) {
 304     case CachedResource::MainResource:
 305     case CachedResource::ImageResource:
 306     case CachedResource::CSSStyleSheet:
 307     case CachedResource::Script:
 308     case CachedResource::FontResource:
 309     case CachedResource::RawResource:
 310 #if ENABLE(LINK_PREFETCH)
 311     case CachedResource::LinkPrefetch:
 312     case CachedResource::LinkSubresource:
 313 #endif
 314 #if ENABLE(VIDEO_TRACK)
 315     case CachedResource::TextTrackResource:
 316 #endif


 767 
 768 void CachedResourceLoader::garbageCollectDocumentResources()
 769 {
 770     typedef Vector<String, 10> StringVector;
 771     StringVector resourcesToDelete;
 772 
 773     for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m_documentResources.end(); ++it) {
 774         if (it->value->hasOneHandle()) {
 775             resourcesToDelete.append(it->key);
 776             it->value->setOwningCachedResourceLoader(0);
 777         }
 778     }
 779 
 780     for (StringVector::const_iterator it = resourcesToDelete.begin(); it != resourcesToDelete.end(); ++it)
 781         m_documentResources.remove(*it);
 782 }
 783 
 784 void CachedResourceLoader::performPostLoadActions()
 785 {
 786     checkForPendingPreloads();
 787 
 788     // PostLoad might trigger async resource request which is not required for Canceled Main Document
 789     // caused by user cancel or stop
 790     if (m_documentLoader && !m_documentLoader->mainDocumentError().isNull() && m_documentLoader->mainDocumentError().isCancellation())
 791         return;
 792 
 793     platformStrategies()->loaderStrategy()->resourceLoadScheduler()->servePendingRequests();
 794 }
 795 
 796 void CachedResourceLoader::incrementRequestCount(const CachedResource* res)
 797 {
 798     if (res->ignoreForRequestCount())
 799         return;
 800 
 801     ++m_requestCount;
 802 }
 803 
 804 void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
 805 {
 806     if (res->ignoreForRequestCount())
 807         return;
 808 
 809     --m_requestCount;
 810     ASSERT(m_requestCount > -1);
 811 }


< prev index next >