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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class ResourcePtrBase; | 46 class ResourcePtrBase; |
47 class ResourceFetcher; | 47 class ResourceFetcher; |
48 class InspectorResource; | 48 class InspectorResource; |
49 class ResourceLoader; | 49 class ResourceLoader; |
50 class SecurityOrigin; | 50 class SecurityOrigin; |
51 class SharedBuffer; | 51 class SharedBuffer; |
52 | 52 |
53 // A resource that is held in the cache. Classes who want to use this object sho
uld derive | 53 // A resource that is held in the cache. Classes who want to use this object sho
uld derive |
54 // from ResourceClient, to get the function calls in case the requested data has
arrived. | 54 // from ResourceClient, to get the function calls in case the requested data has
arrived. |
55 // This class also does the actual communication with the loader to obtain the r
esource from the network. | 55 // This class also does the actual communication with the loader to obtain the r
esource from the network. |
56 class Resource { | 56 class Resource : public NoBaseWillBeGarbageCollectedFinalized<Resource> { |
57 WTF_MAKE_NONCOPYABLE(Resource); WTF_MAKE_FAST_ALLOCATED; | 57 WTF_MAKE_NONCOPYABLE(Resource); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
58 friend class InspectorResource; | 58 friend class InspectorResource; |
59 | 59 |
60 public: | 60 public: |
61 enum Type { | 61 enum Type { |
62 MainResource, | 62 MainResource, |
63 Image, | 63 Image, |
64 CSSStyleSheet, | 64 CSSStyleSheet, |
65 Script, | 65 Script, |
66 Font, | 66 Font, |
67 Raw, | 67 Raw, |
68 SVGDocument, | 68 SVGDocument, |
69 XSLStyleSheet, | 69 XSLStyleSheet, |
70 LinkPrefetch, | 70 LinkPrefetch, |
71 LinkSubresource, | 71 LinkSubresource, |
72 TextTrack, | 72 TextTrack, |
73 ImportResource, | 73 ImportResource, |
74 Media // Audio or video file requested by a HTML5 media element | 74 Media // Audio or video file requested by a HTML5 media element |
75 }; | 75 }; |
76 | 76 |
77 enum Status { | 77 enum Status { |
78 Unknown, // let cache decide what to do with it | 78 Unknown, // let cache decide what to do with it |
79 Pending, // only partially loaded | 79 Pending, // only partially loaded |
80 Cached, // regular case | 80 Cached, // regular case |
81 LoadError, | 81 LoadError, |
82 DecodeError | 82 DecodeError |
83 }; | 83 }; |
84 | 84 |
85 Resource(const ResourceRequest&, Type); | 85 Resource(const ResourceRequest&, Type); |
| 86 #if ENABLE(OILPAN) |
86 virtual ~Resource(); | 87 virtual ~Resource(); |
| 88 #else |
| 89 protected: |
| 90 // Only deleteIfPossible should delete this. |
| 91 virtual ~Resource(); |
| 92 public: |
| 93 #endif |
87 virtual void dispose(); | 94 virtual void dispose(); |
| 95 virtual void trace(Visitor*); |
88 | 96 |
89 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); | 97 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); |
90 | 98 |
91 virtual void setEncoding(const String&) { } | 99 virtual void setEncoding(const String&) { } |
92 virtual String encoding() const { return String(); } | 100 virtual String encoding() const { return String(); } |
93 virtual void appendData(const char*, int); | 101 virtual void appendData(const char*, int); |
94 virtual void error(Resource::Status); | 102 virtual void error(Resource::Status); |
95 | 103 |
96 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } | 104 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } |
97 | 105 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 unsigned m_needsSynchronousCacheHit : 1; | 379 unsigned m_needsSynchronousCacheHit : 1; |
372 | 380 |
373 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 381 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
374 bool m_deleted; | 382 bool m_deleted; |
375 #endif | 383 #endif |
376 | 384 |
377 // If this field is non-null we are using the resource as a proxy for checki
ng whether an existing resource is still up to date | 385 // If this field is non-null we are using the resource as a proxy for checki
ng whether an existing resource is still up to date |
378 // using HTTP If-Modified-Since/If-None-Match headers. If the response is 30
4 all clients of this resource are moved | 386 // using HTTP If-Modified-Since/If-None-Match headers. If the response is 30
4 all clients of this resource are moved |
379 // to to be clients of m_resourceToRevalidate and the resource is deleted. I
f not, the field is zeroed and this | 387 // to to be clients of m_resourceToRevalidate and the resource is deleted. I
f not, the field is zeroed and this |
380 // resources becomes normal resource load. | 388 // resources becomes normal resource load. |
381 Resource* m_resourceToRevalidate; | 389 RawPtrWillBeMember<Resource> m_resourceToRevalidate; |
382 | 390 |
383 // If this field is non-null, the resource has a proxy for checking whether
it is still up to date (see m_resourceToRevalidate). | 391 // If this field is non-null, the resource has a proxy for checking whether
it is still up to date (see m_resourceToRevalidate). |
384 Resource* m_proxyResource; | 392 RawPtrWillBeMember<Resource> m_proxyResource; |
385 | 393 |
386 // These handles will need to be updated to point to the m_resourceToRevalid
ate in case we get 304 response. | 394 // These handles will need to be updated to point to the m_resourceToRevalid
ate in case we get 304 response. |
387 HashSet<ResourcePtrBase*> m_handlesToRevalidate; | 395 HashSet<ResourcePtrBase*> m_handlesToRevalidate; |
388 | 396 |
389 // Ordered list of all redirects followed while fetching this resource. | 397 // Ordered list of all redirects followed while fetching this resource. |
390 Vector<RedirectPair> m_redirectChain; | 398 Vector<RedirectPair> m_redirectChain; |
391 }; | 399 }; |
392 | 400 |
393 #if !LOG_DISABLED | 401 #if !LOG_DISABLED |
394 // Intended to be used in LOG statements. | 402 // Intended to be used in LOG statements. |
395 const char* ResourceTypeName(Resource::Type); | 403 const char* ResourceTypeName(Resource::Type); |
396 #endif | 404 #endif |
397 | 405 |
398 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 406 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
399 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ | 407 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() =
= Resource::typeName, resource.type() == Resource::typeName); \ |
400 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } | 408 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource
>& ptr) { return to##typeName##Resource(ptr.get()); } |
401 | 409 |
402 } | 410 } |
403 | 411 |
404 #endif | 412 #endif |
OLD | NEW |