| 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); | |
| 61 public: | 60 public: |
| 62 enum Type { | 61 enum Type { |
| 63 MainResource, | 62 MainResource, |
| 64 Image, | 63 Image, |
| 65 CSSStyleSheet, | 64 CSSStyleSheet, |
| 66 Script, | 65 Script, |
| 67 Font, | 66 Font, |
| 68 Raw, | 67 Raw, |
| 69 SVGDocument, | 68 SVGDocument, |
| 70 XSLStyleSheet, | 69 XSLStyleSheet, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 DecodeError | 83 DecodeError |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 // Exposed for testing. | 86 // Exposed for testing. |
| 88 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) | 87 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) |
| 89 { | 88 { |
| 90 return new Resource(request, type, options); | 89 return new Resource(request, type, options); |
| 91 } | 90 } |
| 92 virtual ~Resource(); | 91 virtual ~Resource(); |
| 93 | 92 |
| 94 void willDestroyResource(); | |
| 95 DECLARE_VIRTUAL_TRACE(); | 93 DECLARE_VIRTUAL_TRACE(); |
| 96 | 94 |
| 97 void load(ResourceFetcher*); | 95 void load(ResourceFetcher*); |
| 98 | 96 |
| 99 virtual void setEncoding(const String&) { } | 97 virtual void setEncoding(const String&) { } |
| 100 virtual String encoding() const { return String(); } | 98 virtual String encoding() const { return String(); } |
| 101 virtual void appendData(const char*, size_t); | 99 virtual void appendData(const char*, size_t); |
| 102 virtual void error(const ResourceError&); | 100 virtual void error(const ResourceError&); |
| 103 virtual void setCORSFailed() { } | 101 virtual void setCORSFailed() { } |
| 104 | 102 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 253 |
| 256 void finishPendingClients(); | 254 void finishPendingClients(); |
| 257 | 255 |
| 258 virtual void didAddClient(ResourceClient*); | 256 virtual void didAddClient(ResourceClient*); |
| 259 void willAddClientOrObserver(); | 257 void willAddClientOrObserver(); |
| 260 | 258 |
| 261 // |this| object may be dead after didRemoveClientOrObserver(). | 259 // |this| object may be dead after didRemoveClientOrObserver(). |
| 262 void didRemoveClientOrObserver(); | 260 void didRemoveClientOrObserver(); |
| 263 virtual void allClientsAndObserversRemoved(); | 261 virtual void allClientsAndObserversRemoved(); |
| 264 | 262 |
| 265 virtual void willDestroyResourceInternal() { } | |
| 266 | |
| 267 HashCountedSet<ResourceClient*> m_clients; | 263 HashCountedSet<ResourceClient*> m_clients; |
| 268 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; | 264 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; |
| 269 HashCountedSet<ResourceClient*> m_finishedClients; | 265 HashCountedSet<ResourceClient*> m_finishedClients; |
| 270 | 266 |
| 271 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } | 267 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } |
| 272 | 268 |
| 273 struct RedirectPair { | 269 struct RedirectPair { |
| 274 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 270 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 275 public: | 271 public: |
| 276 explicit RedirectPair(const ResourceRequest& request, const ResourceResp
onse& redirectResponse) | 272 explicit RedirectPair(const ResourceRequest& request, const ResourceResp
onse& redirectResponse) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 357 |
| 362 Resource::Type m_type; | 358 Resource::Type m_type; |
| 363 }; | 359 }; |
| 364 | 360 |
| 365 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 361 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 366 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); | 362 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); |
| 367 | 363 |
| 368 } // namespace blink | 364 } // namespace blink |
| 369 | 365 |
| 370 #endif | 366 #endif |
| OLD | NEW |