| 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, const ResourceLoaderOptions& options = ResourceLoaderOptions()) | 89 static PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& reques
t, Type type, const ResourceLoaderOptions& options = ResourceLoaderOptions()) |
| 89 { | 90 { |
| 90 return adoptRefWillBeNoop(new Resource(request, type, options)); | 91 return adoptRefWillBeNoop(new Resource(request, type, options)); |
| 91 } | 92 } |
| 92 virtual ~Resource(); | 93 virtual ~Resource(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 unsigned count() const { return m_clients.size(); } | 148 unsigned count() const { return m_clients.size(); } |
| 148 | 149 |
| 149 Status getStatus() const { return static_cast<Status>(m_status); } | 150 Status getStatus() const { return static_cast<Status>(m_status); } |
| 150 void setStatus(Status status) { m_status = status; } | 151 void setStatus(Status status) { m_status = status; } |
| 151 | 152 |
| 152 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} | 153 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} |
| 153 size_t encodedSize() const { return m_encodedSize; } | 154 size_t encodedSize() const { return m_encodedSize; } |
| 154 size_t decodedSize() const { return m_decodedSize; } | 155 size_t decodedSize() const { return m_decodedSize; } |
| 155 size_t overheadSize() const; | 156 size_t overheadSize() const; |
| 156 | 157 |
| 157 bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccu
rate. Loading might not have started yet. | 158 bool isLoaded() const { return m_status > Pending; } |
| 158 | 159 |
| 159 bool isLoading() const { return m_loading; } | 160 bool isLoading() const { return m_status == Pending; } |
| 160 void setLoading(bool b) { m_loading = b; } | 161 bool stillNeedsLoad() const { return m_status < Pending; } |
| 161 virtual bool stillNeedsLoad() const { return false; } | |
| 162 | 162 |
| 163 ResourceLoader* loader() const { return m_loader.get(); } | 163 ResourceLoader* loader() const { return m_loader.get(); } |
| 164 | 164 |
| 165 virtual bool isImage() const { return false; } | 165 virtual bool isImage() const { return false; } |
| 166 bool shouldBlockLoadEvent() const; | 166 bool shouldBlockLoadEvent() const; |
| 167 bool isLoadEventBlockingResourceType() const; | 167 bool isLoadEventBlockingResourceType() const; |
| 168 | 168 |
| 169 // Computes the status of an object after loading. | 169 // Computes the status of an object after loading. |
| 170 // Updates the expire date on the cache entry file | 170 // Updates the expire date on the cache entry file |
| 171 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } | 171 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 unsigned long m_identifier; | 349 unsigned long m_identifier; |
| 350 | 350 |
| 351 size_t m_encodedSize; | 351 size_t m_encodedSize; |
| 352 size_t m_decodedSize; | 352 size_t m_decodedSize; |
| 353 unsigned m_preloadCount; | 353 unsigned m_preloadCount; |
| 354 | 354 |
| 355 String m_cacheIdentifier; | 355 String m_cacheIdentifier; |
| 356 | 356 |
| 357 unsigned m_preloadResult : 2; // PreloadResult | 357 unsigned m_preloadResult : 2; // PreloadResult |
| 358 unsigned m_requestedFromNetworkingLayer : 1; | |
| 359 | |
| 360 unsigned m_loading : 1; | |
| 361 | |
| 362 unsigned m_type : 4; // Type | 358 unsigned m_type : 4; // Type |
| 363 unsigned m_status : 3; // Status | 359 unsigned m_status : 3; // Status |
| 364 | 360 |
| 365 unsigned m_needsSynchronousCacheHit : 1; | 361 unsigned m_needsSynchronousCacheHit : 1; |
| 366 unsigned m_linkPreload : 1; | 362 unsigned m_linkPreload : 1; |
| 367 | 363 |
| 368 // Ordered list of all redirects followed while fetching this resource. | 364 // Ordered list of all redirects followed while fetching this resource. |
| 369 Vector<RedirectPair> m_redirectChain; | 365 Vector<RedirectPair> m_redirectChain; |
| 370 }; | 366 }; |
| 371 | 367 |
| 372 class ResourceFactory { | 368 class ResourceFactory { |
| 373 STACK_ALLOCATED(); | 369 STACK_ALLOCATED(); |
| 374 public: | 370 public: |
| 375 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t ResourceLoaderOptions&, const String&) const = 0; | 371 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t ResourceLoaderOptions&, const String&) const = 0; |
| 376 Resource::Type type() const { return m_type; } | 372 Resource::Type type() const { return m_type; } |
| 377 | 373 |
| 378 protected: | 374 protected: |
| 379 ResourceFactory(Resource::Type type) : m_type(type) { } | 375 ResourceFactory(Resource::Type type) : m_type(type) { } |
| 380 | 376 |
| 381 Resource::Type m_type; | 377 Resource::Type m_type; |
| 382 }; | 378 }; |
| 383 | 379 |
| 384 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 380 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 385 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ | 381 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ |
| 386 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } | 382 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } |
| 387 | 383 |
| 388 } // namespace blink | 384 } // namespace blink |
| 389 | 385 |
| 390 #endif | 386 #endif |
| OLD | NEW |