| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 static const int kLastResourceType = Manifest + 1; | 79 static const int kLastResourceType = Manifest + 1; |
| 80 | 80 |
| 81 enum Status { | 81 enum Status { |
| 82 NotStarted, | 82 NotStarted, |
| 83 Pending, // load in progress | 83 Pending, // load in progress |
| 84 Cached, // load completed successfully | 84 Cached, // load completed successfully |
| 85 LoadError, | 85 LoadError, |
| 86 DecodeError | 86 DecodeError |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // Whether a resource client for a preload should mark the preload as |
| 90 // referenced. |
| 91 enum PreloadReferencePolicy { |
| 92 MarkAsReferenced, |
| 93 DontMarkAsReferenced, |
| 94 }; |
| 95 |
| 89 // Exposed for testing. | 96 // Exposed for testing. |
| 90 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) | 97 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) |
| 91 { | 98 { |
| 92 return new Resource(request, type, options); | 99 return new Resource(request, type, options); |
| 93 } | 100 } |
| 94 virtual ~Resource(); | 101 virtual ~Resource(); |
| 95 | 102 |
| 96 DECLARE_VIRTUAL_TRACE(); | 103 DECLARE_VIRTUAL_TRACE(); |
| 97 | 104 |
| 98 virtual void setEncoding(const String&) { } | 105 virtual void setEncoding(const String&) { } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 124 | 131 |
| 125 // This url can have a fragment, but it can match resources that differ by t
he fragment only. | 132 // This url can have a fragment, but it can match resources that differ by t
he fragment only. |
| 126 const KURL& url() const { return m_resourceRequest.url();} | 133 const KURL& url() const { return m_resourceRequest.url();} |
| 127 Type getType() const { return static_cast<Type>(m_type); } | 134 Type getType() const { return static_cast<Type>(m_type); } |
| 128 const ResourceLoaderOptions& options() const { return m_options; } | 135 const ResourceLoaderOptions& options() const { return m_options; } |
| 129 ResourceLoaderOptions& mutableOptions() { return m_options; } | 136 ResourceLoaderOptions& mutableOptions() { return m_options; } |
| 130 | 137 |
| 131 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 138 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
| 132 virtual ResourcePriority priorityFromObservers() { return ResourcePriority()
; } | 139 virtual ResourcePriority priorityFromObservers() { return ResourcePriority()
; } |
| 133 | 140 |
| 134 void addClient(ResourceClient*); | 141 // The reference policy indicates that the client should not affect whether |
| 142 // a preload is considered referenced or not. This allows for "passive" |
| 143 // resource clients that simply observe the resource. |
| 144 void addClient(ResourceClient*, PreloadReferencePolicy = MarkAsReferenced); |
| 135 void removeClient(ResourceClient*); | 145 void removeClient(ResourceClient*); |
| 136 virtual bool hasClientsOrObservers() const { return !m_clients.isEmpty() ||
!m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); } | 146 virtual bool hasClientsOrObservers() const { return !m_clients.isEmpty() ||
!m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); } |
| 137 | 147 |
| 138 enum PreloadResult { | 148 enum PreloadResult { |
| 139 PreloadNotReferenced, | 149 PreloadNotReferenced, |
| 140 PreloadReferenced, | 150 PreloadReferenced, |
| 141 PreloadReferencedWhileLoading, | 151 PreloadReferencedWhileLoading, |
| 142 PreloadReferencedWhileComplete | 152 PreloadReferencedWhileComplete |
| 143 }; | 153 }; |
| 144 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m
_preloadResult); } | 154 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m
_preloadResult); } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 261 |
| 252 virtual void destroyDecodedDataForFailedRevalidation() { } | 262 virtual void destroyDecodedDataForFailedRevalidation() { } |
| 253 | 263 |
| 254 void setEncodedSize(size_t); | 264 void setEncodedSize(size_t); |
| 255 void setDecodedSize(size_t); | 265 void setDecodedSize(size_t); |
| 256 void didAccessDecodedData(); | 266 void didAccessDecodedData(); |
| 257 | 267 |
| 258 void finishPendingClients(); | 268 void finishPendingClients(); |
| 259 | 269 |
| 260 virtual void didAddClient(ResourceClient*); | 270 virtual void didAddClient(ResourceClient*); |
| 261 void willAddClientOrObserver(); | 271 void willAddClientOrObserver(PreloadReferencePolicy); |
| 262 | 272 |
| 263 // |this| object may be dead after didRemoveClientOrObserver(). | 273 // |this| object may be dead after didRemoveClientOrObserver(). |
| 264 void didRemoveClientOrObserver(); | 274 void didRemoveClientOrObserver(); |
| 265 virtual void allClientsAndObserversRemoved(); | 275 virtual void allClientsAndObserversRemoved(); |
| 266 | 276 |
| 267 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } | 277 bool hasClient(ResourceClient* client) { return m_clients.contains(client) |
| m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien
t); } |
| 268 | 278 |
| 269 struct RedirectPair { | 279 struct RedirectPair { |
| 270 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 280 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 271 public: | 281 public: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 381 |
| 372 Resource::Type m_type; | 382 Resource::Type m_type; |
| 373 }; | 383 }; |
| 374 | 384 |
| 375 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 385 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 376 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); | 386 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); |
| 377 | 387 |
| 378 } // namespace blink | 388 } // namespace blink |
| 379 | 389 |
| 380 #endif | 390 #endif |
| OLD | NEW |