Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: third_party/WebKit/Source/core/fetch/Resource.h

Issue 2393113002: ImageResource: Reset the encoded image size after receiving all data (Closed)
Patch Set: Rename encodedSizeMemoryUsage -> encodedSizeMemoryUsageForTesting Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/Resource.h
diff --git a/third_party/WebKit/Source/core/fetch/Resource.h b/third_party/WebKit/Source/core/fetch/Resource.h
index 02b238927bb2a71c675b2c57e7b01f890ca571a3..86e6185daaabdce9fe726b664f7f41baedc58afe 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.h
+++ b/third_party/WebKit/Source/core/fetch/Resource.h
@@ -169,7 +169,24 @@ class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource>,
void setStatus(Status status) { m_status = status; }
size_t size() const { return encodedSize() + decodedSize() + overheadSize(); }
+
+ // Returns the size of content (response body) before decoding. Adding a new
+ // usage of this function is not recommended (See the TODO below).
+ //
+ // TODO(hiroshige): Now encodedSize/decodedSize states are inconsistent and
+ // need to be refactored (crbug/643135).
size_t encodedSize() const { return m_encodedSize; }
+
+ // Returns the current memory usage for the encoded data. Adding a new usage
+ // of this function is not recommended as the same reason as |encodedSize()|.
+ //
+ // |encodedSize()| and |encodedSizeMemoryUsageForTesting()| can return
+ // different values, e.g., when ImageResource purges encoded image data after
+ // finishing loading.
+ size_t encodedSizeMemoryUsageForTesting() const {
+ return m_encodedSizeMemoryUsage;
+ }
+
size_t decodedSize() const { return m_decodedSize; }
size_t overheadSize() const { return m_overheadSize; }
@@ -319,6 +336,7 @@ class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource>,
virtual void destroyDecodedDataForFailedRevalidation() {}
void setEncodedSize(size_t);
+ void setEncodedSizeMemoryUsage(size_t);
void setDecodedSize(size_t);
void didAccessDecodedData();
@@ -401,6 +419,7 @@ class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource>,
unsigned long m_identifier;
size_t m_encodedSize;
+ size_t m_encodedSizeMemoryUsage;
size_t m_decodedSize;
// Resource::calculateOverheadSize() is affected by changes in
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698