| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> | 3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org> |
| 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 virtual ~ResourceFetcher(); | 73 virtual ~ResourceFetcher(); |
| 74 DECLARE_VIRTUAL_TRACE(); | 74 DECLARE_VIRTUAL_TRACE(); |
| 75 | 75 |
| 76 Resource* requestResource(FetchRequest&, const ResourceFactory&, const Subst
ituteData& = SubstituteData()); | 76 Resource* requestResource(FetchRequest&, const ResourceFactory&, const Subst
ituteData& = SubstituteData()); |
| 77 | 77 |
| 78 Resource* cachedResource(const KURL&) const; | 78 Resource* cachedResource(const KURL&) const; |
| 79 | 79 |
| 80 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>; | 80 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>; |
| 81 const DocumentResourceMap& allResources() const { return m_documentResources
; } | 81 const DocumentResourceMap& allResources() const { return m_documentResources
; } |
| 82 | 82 |
| 83 // Actually starts loading a Resource if it wasn't started during requestRes
ource(). |
| 84 bool startLoad(Resource*); |
| 85 |
| 83 void setAutoLoadImages(bool); | 86 void setAutoLoadImages(bool); |
| 84 void setImagesEnabled(bool); | 87 void setImagesEnabled(bool); |
| 85 | 88 |
| 86 FetchContext& context() const { return m_context ? *m_context.get() : FetchC
ontext::nullInstance(); } | 89 FetchContext& context() const { return m_context ? *m_context.get() : FetchC
ontext::nullInstance(); } |
| 87 void clearContext() { m_context.clear(); } | 90 void clearContext() { m_context.clear(); } |
| 88 | 91 |
| 89 int requestCount() const; | 92 int requestCount() const; |
| 90 | 93 |
| 91 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads
}; | 94 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads
}; |
| 92 | 95 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 103 void stopFetching(); | 106 void stopFetching(); |
| 104 bool isFetching() const; | 107 bool isFetching() const; |
| 105 | 108 |
| 106 void didLoadResource(Resource*); | 109 void didLoadResource(Resource*); |
| 107 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse&
); | 110 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse&
); |
| 108 void didFinishLoading(Resource*, double finishTime, int64_t encodedDataLengt
h); | 111 void didFinishLoading(Resource*, double finishTime, int64_t encodedDataLengt
h); |
| 109 void didFailLoading(const Resource*, const ResourceError&); | 112 void didFailLoading(const Resource*, const ResourceError&); |
| 110 void didReceiveResponse(const Resource*, const ResourceResponse&); | 113 void didReceiveResponse(const Resource*, const ResourceResponse&); |
| 111 void didReceiveData(const Resource*, const char* data, int dataLength, int e
ncodedDataLength); | 114 void didReceiveData(const Resource*, const char* data, int dataLength, int e
ncodedDataLength); |
| 112 void didDownloadData(const Resource*, int dataLength, int encodedDataLength)
; | 115 void didDownloadData(const Resource*, int dataLength, int encodedDataLength)
; |
| 113 void willStartLoadingResource(Resource*, ResourceLoader*, ResourceRequest&); | |
| 114 bool defersLoading() const; | 116 bool defersLoading() const; |
| 115 | 117 |
| 116 void moveResourceLoaderToNonBlocking(ResourceLoader*); | 118 void moveResourceLoaderToNonBlocking(ResourceLoader*); |
| 117 void removeResourceLoader(ResourceLoader*); | 119 void removeResourceLoader(ResourceLoader*); |
| 118 | 120 |
| 119 enum AccessControlLoggingDecision { | 121 enum AccessControlLoggingDecision { |
| 120 ShouldLogAccessControlErrors, | 122 ShouldLogAccessControlErrors, |
| 121 ShouldNotLogAccessControlErrors | 123 ShouldNotLogAccessControlErrors |
| 122 }; | 124 }; |
| 123 bool canAccessResource(Resource*, SecurityOrigin*, const KURL&, AccessContro
lLoggingDecision) const; | 125 bool canAccessResource(Resource*, SecurityOrigin*, const KURL&, AccessContro
lLoggingDecision) const; |
| 124 bool isControlledByServiceWorker() const; | 126 bool isControlledByServiceWorker() const; |
| 125 | 127 |
| 126 void acceptDataFromThreadedReceiver(unsigned long identifier, const char* da
ta, int dataLength, int encodedDataLength); | 128 void acceptDataFromThreadedReceiver(unsigned long identifier, const char* da
ta, int dataLength, int encodedDataLength); |
| 127 | 129 |
| 128 ResourceLoadPriority loadPriority(Resource::Type, const FetchRequest&, Resou
rcePriority::VisibilityStatus = ResourcePriority::NotVisible); | 130 ResourceLoadPriority loadPriority(Resource::Type, const FetchRequest&, Resou
rcePriority::VisibilityStatus = ResourcePriority::NotVisible); |
| 129 | 131 |
| 130 enum ResourceLoadStartType { | 132 enum ResourceLoadStartType { |
| 131 ResourceLoadingFromNetwork, | 133 ResourceLoadingFromNetwork, |
| 132 ResourceLoadingFromCache | 134 ResourceLoadingFromCache |
| 133 }; | 135 }; |
| 134 void requestLoadStarted(Resource*, const FetchRequest&, ResourceLoadStartTyp
e, bool isStaticData = false); | 136 void requestLoadStarted(Resource*, const FetchRequest&, ResourceLoadStartTyp
e, bool isStaticData = false); |
| 135 static const ResourceLoaderOptions& defaultResourceOptions(); | 137 static const ResourceLoaderOptions& defaultResourceOptions(); |
| 136 | 138 |
| 137 String getCacheIdentifier() const; | 139 String getCacheIdentifier() const; |
| 138 | 140 |
| 139 static void determineRequestContext(ResourceRequest&, Resource::Type, bool i
sMainFrame); | 141 static void determineRequestContext(ResourceRequest&, Resource::Type, bool i
sMainFrame); |
| 140 void determineRequestContext(ResourceRequest&, Resource::Type); | 142 void determineRequestContext(ResourceRequest&, Resource::Type); |
| 141 | 143 |
| 142 WebTaskRunner* loadingTaskRunner(); | |
| 143 | |
| 144 void updateAllImageResourcePriorities(); | 144 void updateAllImageResourcePriorities(); |
| 145 | 145 |
| 146 void reloadLoFiImages(); | 146 void reloadLoFiImages(); |
| 147 | 147 |
| 148 // This is only exposed for testing purposes. | 148 // This is only exposed for testing purposes. |
| 149 HeapListHashSet<Member<Resource>>* preloads() { return m_preloads.get(); } | 149 HeapListHashSet<Member<Resource>>* preloads() { return m_preloads.get(); } |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 friend class ResourceCacheValidationSuppressor; | 152 friend class ResourceCacheValidationSuppressor; |
| 153 | 153 |
| 154 explicit ResourceFetcher(FetchContext*); | 154 explicit ResourceFetcher(FetchContext*); |
| 155 | 155 |
| 156 void initializeRevalidation(const FetchRequest&, Resource*); | 156 void initializeRevalidation(const FetchRequest&, Resource*); |
| 157 Resource* createResourceForLoading(FetchRequest&, const String& charset, con
st ResourceFactory&); | 157 Resource* createResourceForLoading(FetchRequest&, const String& charset, con
st ResourceFactory&); |
| 158 void storeResourceTimingInitiatorInformation(Resource*); | 158 void storeResourceTimingInitiatorInformation(Resource*); |
| 159 | 159 |
| 160 Resource* resourceForStaticData(const FetchRequest&, const ResourceFactory&,
const SubstituteData&); | 160 Resource* resourceForStaticData(const FetchRequest&, const ResourceFactory&,
const SubstituteData&); |
| 161 | 161 |
| 162 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. | 162 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. |
| 163 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; | 163 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; |
| 164 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe
quest&, Resource* existingResource, bool isStaticData) const; | 164 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe
quest&, Resource* existingResource, bool isStaticData) const; |
| 165 | 165 |
| 166 void moveCachedNonBlockingResourceToBlocking(Resource*, const FetchRequest&)
; | 166 void moveCachedNonBlockingResourceToBlocking(Resource*, const FetchRequest&)
; |
| 167 | 167 |
| 168 void initializeResourceRequest(ResourceRequest&, Resource::Type, FetchReques
t::DeferOption); | 168 void initializeResourceRequest(ResourceRequest&, Resource::Type, FetchReques
t::DeferOption); |
| 169 void willStartLoadingResource(Resource*, ResourceLoader*, ResourceRequest&); |
| 169 | 170 |
| 170 bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPolicy); | 171 bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPolicy); |
| 171 bool shouldDeferImageLoad(const KURL&) const; | 172 bool shouldDeferImageLoad(const KURL&) const; |
| 172 | 173 |
| 173 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*); | 174 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*); |
| 174 | 175 |
| 175 void reloadImagesIfNotDeferred(); | 176 void reloadImagesIfNotDeferred(); |
| 176 | 177 |
| 177 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques
t&, const ResourceFactory&, bool isStaticData) const; | 178 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques
t&, const ResourceFactory&, bool isStaticData) const; |
| 178 | 179 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 m_loader->m_allowStaleResources = m_previousState; | 236 m_loader->m_allowStaleResources = m_previousState; |
| 236 } | 237 } |
| 237 private: | 238 private: |
| 238 Member<ResourceFetcher> m_loader; | 239 Member<ResourceFetcher> m_loader; |
| 239 bool m_previousState; | 240 bool m_previousState; |
| 240 }; | 241 }; |
| 241 | 242 |
| 242 } // namespace blink | 243 } // namespace blink |
| 243 | 244 |
| 244 #endif // ResourceFetcher_h | 245 #endif // ResourceFetcher_h |
| OLD | NEW |