| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 class ResourceTimingInfo; | 50 class ResourceTimingInfo; |
| 51 class ResourceLoader; | 51 class ResourceLoader; |
| 52 class SecurityOrigin; | 52 class SecurityOrigin; |
| 53 class SharedBuffer; | 53 class SharedBuffer; |
| 54 | 54 |
| 55 // A resource that is held in the cache. Classes who want to use this object sho
uld derive | 55 // A resource that is held in the cache. Classes who want to use this object sho
uld derive |
| 56 // from ResourceClient, to get the function calls in case the requested data has
arrived. | 56 // from ResourceClient, to get the function calls in case the requested data has
arrived. |
| 57 // This class also does the actual communication with the loader to obtain the r
esource from the network. | 57 // This class also does the actual communication with the loader to obtain the r
esource from the network. |
| 58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { | 58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { |
| 59 WTF_MAKE_NONCOPYABLE(Resource); | 59 WTF_MAKE_NONCOPYABLE(Resource); |
| 60 USING_PRE_FINALIZER(Resource, willDestroyResource); |
| 60 public: | 61 public: |
| 61 enum Type { | 62 enum Type { |
| 62 MainResource, | 63 MainResource, |
| 63 Image, | 64 Image, |
| 64 CSSStyleSheet, | 65 CSSStyleSheet, |
| 65 Script, | 66 Script, |
| 66 Font, | 67 Font, |
| 67 Raw, | 68 Raw, |
| 68 SVGDocument, | 69 SVGDocument, |
| 69 XSLStyleSheet, | 70 XSLStyleSheet, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 83 DecodeError | 84 DecodeError |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 // Exposed for testing. | 87 // Exposed for testing. |
| 87 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) | 88 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) |
| 88 { | 89 { |
| 89 return new Resource(request, type, options); | 90 return new Resource(request, type, options); |
| 90 } | 91 } |
| 91 virtual ~Resource(); | 92 virtual ~Resource(); |
| 92 | 93 |
| 93 virtual void removedFromMemoryCache(); | 94 void willDestroyResource(); |
| 94 DECLARE_VIRTUAL_TRACE(); | 95 DECLARE_VIRTUAL_TRACE(); |
| 95 | 96 |
| 96 void load(ResourceFetcher*); | 97 void load(ResourceFetcher*); |
| 97 | 98 |
| 98 virtual void setEncoding(const String&) { } | 99 virtual void setEncoding(const String&) { } |
| 99 virtual String encoding() const { return String(); } | 100 virtual String encoding() const { return String(); } |
| 100 virtual void appendData(const char*, size_t); | 101 virtual void appendData(const char*, size_t); |
| 101 virtual void error(const ResourceError&); | 102 virtual void error(const ResourceError&); |
| 102 virtual void setCORSFailed() { } | 103 virtual void setCORSFailed() { } |
| 103 | 104 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 257 |
| 257 void finishPendingClients(); | 258 void finishPendingClients(); |
| 258 | 259 |
| 259 virtual void didAddClient(ResourceClient*); | 260 virtual void didAddClient(ResourceClient*); |
| 260 void willAddClientOrObserver(); | 261 void willAddClientOrObserver(); |
| 261 | 262 |
| 262 // |this| object may be dead after didRemoveClientOrObserver(). | 263 // |this| object may be dead after didRemoveClientOrObserver(). |
| 263 void didRemoveClientOrObserver(); | 264 void didRemoveClientOrObserver(); |
| 264 virtual void allClientsAndObserversRemoved(); | 265 virtual void allClientsAndObserversRemoved(); |
| 265 | 266 |
| 267 virtual void willDestroyResourceInternal() { } |
| 268 |
| 266 HashCountedSet<ResourceClient*> m_clients; | 269 HashCountedSet<ResourceClient*> m_clients; |
| 267 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; | 270 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; |
| 268 HashCountedSet<ResourceClient*> m_finishedClients; | 271 HashCountedSet<ResourceClient*> m_finishedClients; |
| 269 | 272 |
| 270 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } | 273 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } |
| 271 | 274 |
| 272 struct RedirectPair { | 275 struct RedirectPair { |
| 273 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 276 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 274 public: | 277 public: |
| 275 explicit RedirectPair(const ResourceRequest& request, const ResourceResp
onse& redirectResponse) | 278 explicit RedirectPair(const ResourceRequest& request, const ResourceResp
onse& redirectResponse) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 366 |
| 364 Resource::Type m_type; | 367 Resource::Type m_type; |
| 365 }; | 368 }; |
| 366 | 369 |
| 367 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 370 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 368 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); | 371 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); |
| 369 | 372 |
| 370 } // namespace blink | 373 } // namespace blink |
| 371 | 374 |
| 372 #endif | 375 #endif |
| OLD | NEW |