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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 XSLStyleSheet, | 70 XSLStyleSheet, |
71 LinkPrefetch, | 71 LinkPrefetch, |
72 LinkPreload, | 72 LinkPreload, |
73 TextTrack, | 73 TextTrack, |
74 ImportResource, | 74 ImportResource, |
75 Media, // Audio or video file requested by a HTML5 media element | 75 Media, // Audio or video file requested by a HTML5 media element |
76 Manifest | 76 Manifest |
77 }; | 77 }; |
78 | 78 |
79 enum Status { | 79 enum Status { |
80 Unknown, // let cache decide what to do with it | 80 NotStarted, |
81 Pending, // only partially loaded | 81 LoadStartScheduled, // scheduled but not yet started, only used by fonts
. |
82 Cached, // regular case | 82 Pending, // load in progress |
| 83 Cached, // load completed successfully |
83 LoadError, | 84 LoadError, |
84 DecodeError | 85 DecodeError |
85 }; | 86 }; |
86 | 87 |
87 // Exposed for testing. | 88 // Exposed for testing. |
88 static PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& reques
t, Type type) | 89 static PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& reques
t, Type type) |
89 { | 90 { |
90 return adoptRefWillBeNoop(new Resource(request, type)); | 91 return adoptRefWillBeNoop(new Resource(request, type)); |
91 } | 92 } |
92 virtual ~Resource(); | 93 virtual ~Resource(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 unsigned count() const { return m_clients.size(); } | 149 unsigned count() const { return m_clients.size(); } |
149 | 150 |
150 Status getStatus() const { return static_cast<Status>(m_status); } | 151 Status getStatus() const { return static_cast<Status>(m_status); } |
151 void setStatus(Status status) { m_status = status; } | 152 void setStatus(Status status) { m_status = status; } |
152 | 153 |
153 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} | 154 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} |
154 size_t encodedSize() const { return m_encodedSize; } | 155 size_t encodedSize() const { return m_encodedSize; } |
155 size_t decodedSize() const { return m_decodedSize; } | 156 size_t decodedSize() const { return m_decodedSize; } |
156 size_t overheadSize() const; | 157 size_t overheadSize() const; |
157 | 158 |
158 bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccu
rate. Loading might not have started yet. | 159 bool isLoaded() const { return m_status > Pending; } |
159 | 160 |
160 bool isLoading() const { return m_loading; } | 161 bool isLoading() const { return m_status == Pending; } |
161 void setLoading(bool b) { m_loading = b; } | 162 bool stillNeedsLoad() const { return m_status < Pending; } |
162 virtual bool stillNeedsLoad() const { return false; } | |
163 | 163 |
164 ResourceLoader* loader() const { return m_loader.get(); } | 164 ResourceLoader* loader() const { return m_loader.get(); } |
165 | 165 |
166 virtual bool isImage() const { return false; } | 166 virtual bool isImage() const { return false; } |
167 bool shouldBlockLoadEvent() const; | 167 bool shouldBlockLoadEvent() const; |
168 bool isLoadEventBlockingResourceType() const; | 168 bool isLoadEventBlockingResourceType() const; |
169 | 169 |
170 // Computes the status of an object after loading. | 170 // Computes the status of an object after loading. |
171 // Updates the expire date on the cache entry file | 171 // Updates the expire date on the cache entry file |
172 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } | 172 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 unsigned long m_identifier; | 350 unsigned long m_identifier; |
351 | 351 |
352 size_t m_encodedSize; | 352 size_t m_encodedSize; |
353 size_t m_decodedSize; | 353 size_t m_decodedSize; |
354 unsigned m_preloadCount; | 354 unsigned m_preloadCount; |
355 | 355 |
356 String m_cacheIdentifier; | 356 String m_cacheIdentifier; |
357 | 357 |
358 unsigned m_preloadResult : 2; // PreloadResult | 358 unsigned m_preloadResult : 2; // PreloadResult |
359 unsigned m_requestedFromNetworkingLayer : 1; | |
360 | |
361 unsigned m_loading : 1; | |
362 | |
363 unsigned m_type : 4; // Type | 359 unsigned m_type : 4; // Type |
364 unsigned m_status : 3; // Status | 360 unsigned m_status : 3; // Status |
365 | 361 |
366 unsigned m_needsSynchronousCacheHit : 1; | 362 unsigned m_needsSynchronousCacheHit : 1; |
367 unsigned m_linkPreload : 1; | 363 unsigned m_linkPreload : 1; |
368 | 364 |
369 // Ordered list of all redirects followed while fetching this resource. | 365 // Ordered list of all redirects followed while fetching this resource. |
370 Vector<RedirectPair> m_redirectChain; | 366 Vector<RedirectPair> m_redirectChain; |
371 }; | 367 }; |
372 | 368 |
373 class ResourceFactory { | 369 class ResourceFactory { |
374 STACK_ALLOCATED(); | 370 STACK_ALLOCATED(); |
375 public: | 371 public: |
376 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t String&) const = 0; | 372 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t String&) const = 0; |
377 Resource::Type type() const { return m_type; } | 373 Resource::Type type() const { return m_type; } |
378 | 374 |
379 protected: | 375 protected: |
380 ResourceFactory(Resource::Type type) : m_type(type) { } | 376 ResourceFactory(Resource::Type type) : m_type(type) { } |
381 | 377 |
382 Resource::Type m_type; | 378 Resource::Type m_type; |
383 }; | 379 }; |
384 | 380 |
385 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 381 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
386 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ | 382 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ |
387 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } | 383 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } |
388 | 384 |
389 } // namespace blink | 385 } // namespace blink |
390 | 386 |
391 #endif | 387 #endif |
OLD | NEW |