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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | 6 rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 PreloadReferencedWhileComplete | 162 PreloadReferencedWhileComplete |
163 }; | 163 }; |
164 PreloadResult getPreloadResult() const { | 164 PreloadResult getPreloadResult() const { |
165 return static_cast<PreloadResult>(m_preloadResult); | 165 return static_cast<PreloadResult>(m_preloadResult); |
166 } | 166 } |
167 | 167 |
168 Status getStatus() const { return static_cast<Status>(m_status); } | 168 Status getStatus() const { return static_cast<Status>(m_status); } |
169 void setStatus(Status status) { m_status = status; } | 169 void setStatus(Status status) { m_status = status; } |
170 | 170 |
171 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); } | 171 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); } |
| 172 |
| 173 // Returns the size of content (response body) before decoding. Adding a new |
| 174 // usage of this function is not recommended (See the TODO below). |
| 175 // |
| 176 // TODO(hiroshige): Now encodedSize/decodedSize states are inconsistent and |
| 177 // need to be refactored (crbug/643135). |
172 size_t encodedSize() const { return m_encodedSize; } | 178 size_t encodedSize() const { return m_encodedSize; } |
| 179 |
| 180 // Returns the current memory usage for the encoded data. Adding a new usage |
| 181 // of this function is not recommended as the same reason as |encodedSize()|. |
| 182 // |
| 183 // |encodedSize()| and |encodedSizeMemoryUsageForTesting()| can return |
| 184 // different values, e.g., when ImageResource purges encoded image data after |
| 185 // finishing loading. |
| 186 size_t encodedSizeMemoryUsageForTesting() const { |
| 187 return m_encodedSizeMemoryUsage; |
| 188 } |
| 189 |
173 size_t decodedSize() const { return m_decodedSize; } | 190 size_t decodedSize() const { return m_decodedSize; } |
174 size_t overheadSize() const { return m_overheadSize; } | 191 size_t overheadSize() const { return m_overheadSize; } |
175 | 192 |
176 bool isLoaded() const { return m_status > Pending; } | 193 bool isLoaded() const { return m_status > Pending; } |
177 | 194 |
178 bool isLoading() const { return m_status == Pending; } | 195 bool isLoading() const { return m_status == Pending; } |
179 bool stillNeedsLoad() const { return m_status < Pending; } | 196 bool stillNeedsLoad() const { return m_status < Pending; } |
180 | 197 |
181 void setLoader(ResourceLoader*); | 198 void setLoader(ResourceLoader*); |
182 ResourceLoader* loader() const { return m_loader.get(); } | 199 ResourceLoader* loader() const { return m_loader.get(); } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 void notifyClientsInternal(MarkFinishedOption); | 329 void notifyClientsInternal(MarkFinishedOption); |
313 void markClientFinished(ResourceClient*); | 330 void markClientFinished(ResourceClient*); |
314 | 331 |
315 virtual bool hasClientsOrObservers() const { | 332 virtual bool hasClientsOrObservers() const { |
316 return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || | 333 return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || |
317 !m_finishedClients.isEmpty(); | 334 !m_finishedClients.isEmpty(); |
318 } | 335 } |
319 virtual void destroyDecodedDataForFailedRevalidation() {} | 336 virtual void destroyDecodedDataForFailedRevalidation() {} |
320 | 337 |
321 void setEncodedSize(size_t); | 338 void setEncodedSize(size_t); |
| 339 void setEncodedSizeMemoryUsage(size_t); |
322 void setDecodedSize(size_t); | 340 void setDecodedSize(size_t); |
323 void didAccessDecodedData(); | 341 void didAccessDecodedData(); |
324 | 342 |
325 void finishPendingClients(); | 343 void finishPendingClients(); |
326 | 344 |
327 virtual void didAddClient(ResourceClient*); | 345 virtual void didAddClient(ResourceClient*); |
328 void willAddClientOrObserver(PreloadReferencePolicy); | 346 void willAddClientOrObserver(PreloadReferencePolicy); |
329 | 347 |
330 // |this| object may be dead after didRemoveClientOrObserver(). | 348 // |this| object may be dead after didRemoveClientOrObserver(). |
331 void didRemoveClientOrObserver(); | 349 void didRemoveClientOrObserver(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 Member<CachedMetadataHandlerImpl> m_cacheHandler; | 412 Member<CachedMetadataHandlerImpl> m_cacheHandler; |
395 RefPtr<SecurityOrigin> m_fetcherSecurityOrigin; | 413 RefPtr<SecurityOrigin> m_fetcherSecurityOrigin; |
396 | 414 |
397 ResourceError m_error; | 415 ResourceError m_error; |
398 | 416 |
399 double m_loadFinishTime; | 417 double m_loadFinishTime; |
400 | 418 |
401 unsigned long m_identifier; | 419 unsigned long m_identifier; |
402 | 420 |
403 size_t m_encodedSize; | 421 size_t m_encodedSize; |
| 422 size_t m_encodedSizeMemoryUsage; |
404 size_t m_decodedSize; | 423 size_t m_decodedSize; |
405 | 424 |
406 // Resource::calculateOverheadSize() is affected by changes in | 425 // Resource::calculateOverheadSize() is affected by changes in |
407 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after | 426 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after |
408 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation | 427 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation |
409 // and thus potential bugs. crbug.com/594644 | 428 // and thus potential bugs. crbug.com/594644 |
410 const size_t m_overheadSize; | 429 const size_t m_overheadSize; |
411 | 430 |
412 unsigned m_preloadCount; | 431 unsigned m_preloadCount; |
413 | 432 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 }; | 483 }; |
465 | 484 |
466 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 485 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
467 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ | 486 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ |
468 resource->getType() == Resource::typeName, \ | 487 resource->getType() == Resource::typeName, \ |
469 resource.getType() == Resource::typeName); | 488 resource.getType() == Resource::typeName); |
470 | 489 |
471 } // namespace blink | 490 } // namespace blink |
472 | 491 |
473 #endif | 492 #endif |
OLD | NEW |