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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 class XSLStyleSheetResource; | 54 class XSLStyleSheetResource; |
55 class Document; | 55 class Document; |
56 class DocumentLoader; | 56 class DocumentLoader; |
57 class Frame; | 57 class Frame; |
58 class FrameLoader; | 58 class FrameLoader; |
59 class ImageLoader; | 59 class ImageLoader; |
60 class KURL; | 60 class KURL; |
61 class ResourceTimingInfo; | 61 class ResourceTimingInfo; |
62 class ResourceLoaderSet; | 62 class ResourceLoaderSet; |
63 | 63 |
| 64 enum CrossOriginEnabled { |
| 65 NotCrossOriginEnabled, |
| 66 PotentiallyCrossOriginEnabled // Indicates "potentially CORS-enabled fetch"
in HTML standard. |
| 67 }; |
| 68 |
64 // The ResourceFetcher provides a per-context interface to the MemoryCache | 69 // The ResourceFetcher provides a per-context interface to the MemoryCache |
65 // and enforces a bunch of security checks and rules for resource revalidation. | 70 // and enforces a bunch of security checks and rules for resource revalidation. |
66 // Its lifetime is roughly per-DocumentLoader, in that it is generally created | 71 // Its lifetime is roughly per-DocumentLoader, in that it is generally created |
67 // in the DocumentLoader constructor and loses its ability to generate network | 72 // in the DocumentLoader constructor and loses its ability to generate network |
68 // requests when the DocumentLoader is destroyed. Documents also hold a | 73 // requests when the DocumentLoader is destroyed. Documents also hold a |
69 // RefPtr<ResourceFetcher> for their lifetime (and will create one if they | 74 // RefPtr<ResourceFetcher> for their lifetime (and will create one if they |
70 // are initialized without a Frame), so a Document can keep a ResourceFetcher | 75 // are initialized without a Frame), so a Document can keep a ResourceFetcher |
71 // alive past detach if scripts still reference the Document. | 76 // alive past detach if scripts still reference the Document. |
72 class ResourceFetcher : public RefCounted<ResourceFetcher>, public ResourceLoade
rHost { | 77 class ResourceFetcher : public RefCounted<ResourceFetcher>, public ResourceLoade
rHost { |
73 WTF_MAKE_NONCOPYABLE(ResourceFetcher); WTF_MAKE_FAST_ALLOCATED; | 78 WTF_MAKE_NONCOPYABLE(ResourceFetcher); WTF_MAKE_FAST_ALLOCATED; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 void garbageCollectDocumentResources(); | 128 void garbageCollectDocumentResources(); |
124 | 129 |
125 int requestCount() const { return m_requestCount; } | 130 int requestCount() const { return m_requestCount; } |
126 | 131 |
127 bool isPreloaded(const String& urlString) const; | 132 bool isPreloaded(const String& urlString) const; |
128 void clearPreloads(); | 133 void clearPreloads(); |
129 void clearPendingPreloads(); | 134 void clearPendingPreloads(); |
130 void preload(Resource::Type, FetchRequest&, const String& charset); | 135 void preload(Resource::Type, FetchRequest&, const String& charset); |
131 void checkForPendingPreloads(); | 136 void checkForPendingPreloads(); |
132 void printPreloadStats(); | 137 void printPreloadStats(); |
133 bool canAccess(Resource*); | 138 bool canAccess(Resource*, CrossOriginEnabled, FetchRequest::OriginRestrictio
n = FetchRequest::UseDefaultOriginRestrictionForType); |
134 | 139 |
135 void setDefersLoading(bool); | 140 void setDefersLoading(bool); |
136 void stopFetching(); | 141 void stopFetching(); |
137 bool isFetching() const; | 142 bool isFetching() const; |
138 | 143 |
139 // ResourceLoaderHost | 144 // ResourceLoaderHost |
140 virtual void incrementRequestCount(const Resource*) OVERRIDE; | 145 virtual void incrementRequestCount(const Resource*) OVERRIDE; |
141 virtual void decrementRequestCount(const Resource*) OVERRIDE; | 146 virtual void decrementRequestCount(const Resource*) OVERRIDE; |
142 virtual void didLoadResource(Resource*) OVERRIDE; | 147 virtual void didLoadResource(Resource*) OVERRIDE; |
143 virtual void redirectReceived(Resource*, const ResourceResponse&) OVERRIDE; | 148 virtual void redirectReceived(Resource*, const ResourceResponse&) OVERRIDE; |
(...skipping 27 matching lines...) Expand all Loading... |
171 void storeResourceTimingInitiatorInformation(const ResourcePtr<Resource>&, c
onst FetchRequest&); | 176 void storeResourceTimingInitiatorInformation(const ResourcePtr<Resource>&, c
onst FetchRequest&); |
172 void requestPreload(Resource::Type, FetchRequest&, const String& charset); | 177 void requestPreload(Resource::Type, FetchRequest&, const String& charset); |
173 | 178 |
174 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; | 179 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; |
175 RevalidationPolicy determineRevalidationPolicy(Resource::Type, ResourceReque
st&, bool forPreload, Resource* existingResource, FetchRequest::DeferOption) con
st; | 180 RevalidationPolicy determineRevalidationPolicy(Resource::Type, ResourceReque
st&, bool forPreload, Resource* existingResource, FetchRequest::DeferOption) con
st; |
176 | 181 |
177 void determineTargetType(ResourceRequest&, Resource::Type); | 182 void determineTargetType(ResourceRequest&, Resource::Type); |
178 ResourceRequestCachePolicy resourceRequestCachePolicy(const ResourceRequest&
, Resource::Type); | 183 ResourceRequestCachePolicy resourceRequestCachePolicy(const ResourceRequest&
, Resource::Type); |
179 void addAdditionalRequestHeaders(ResourceRequest&, Resource::Type); | 184 void addAdditionalRequestHeaders(ResourceRequest&, Resource::Type); |
180 | 185 |
181 bool canRequest(Resource::Type, const KURL&, const ResourceLoaderOptions&, b
ool forPreload = false); | 186 bool canRequest(Resource::Type, const KURL&, const ResourceLoaderOptions&, b
ool forPreload, FetchRequest::OriginRestriction); |
182 bool checkInsecureContent(Resource::Type, const KURL&, MixedContentBlockingT
reatment) const; | 187 bool checkInsecureContent(Resource::Type, const KURL&, MixedContentBlockingT
reatment) const; |
183 | 188 |
184 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo
licy); | 189 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo
licy); |
185 | 190 |
186 void notifyLoadedFromMemoryCache(Resource*); | 191 void notifyLoadedFromMemoryCache(Resource*); |
187 | 192 |
188 void garbageCollectDocumentResourcesTimerFired(Timer<ResourceFetcher>*); | 193 void garbageCollectDocumentResourcesTimerFired(Timer<ResourceFetcher>*); |
189 void performPostLoadActions(); | 194 void performPostLoadActions(); |
190 | 195 |
191 bool clientDefersImage(const KURL&) const; | 196 bool clientDefersImage(const KURL&) const; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 m_loader->m_allowStaleResources = m_previousState; | 244 m_loader->m_allowStaleResources = m_previousState; |
240 } | 245 } |
241 private: | 246 private: |
242 ResourceFetcher* m_loader; | 247 ResourceFetcher* m_loader; |
243 bool m_previousState; | 248 bool m_previousState; |
244 }; | 249 }; |
245 | 250 |
246 } // namespace WebCore | 251 } // namespace WebCore |
247 | 252 |
248 #endif | 253 #endif |
OLD | NEW |