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

Unified Diff: cc/tiles/gpu_image_decode_controller.h

Issue 2367953002: Implement OnMemoryStateChange for Various CC Classes (Closed)
Patch Set: feedback Created 4 years, 3 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
« no previous file with comments | « cc/resources/resource_pool_unittest.cc ('k') | cc/tiles/gpu_image_decode_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/gpu_image_decode_controller.h
diff --git a/cc/tiles/gpu_image_decode_controller.h b/cc/tiles/gpu_image_decode_controller.h
index 5a202ee700a5d8815d3537944f652e4a553e2fee..f49e206cf7810d35283d0b920995627f75e2785a 100644
--- a/cc/tiles/gpu_image_decode_controller.h
+++ b/cc/tiles/gpu_image_decode_controller.h
@@ -125,6 +125,9 @@ class CC_EXPORT GpuImageDecodeController
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
+ // base::MemoryCoordinatorClient overrides.
+ void OnMemoryStateChange(base::MemoryState state) override;
+
// Called by Decode / Upload tasks.
void DecodeImage(const DrawImage& image);
void UploadImage(const DrawImage& image);
@@ -134,13 +137,13 @@ class CC_EXPORT GpuImageDecodeController
void OnImageUploadTaskCompleted(const DrawImage& image);
// For testing only.
- void SetCachedItemLimitForTesting(size_t limit) {
- cached_items_limit_ = limit;
- }
void SetCachedBytesLimitForTesting(size_t limit) {
cached_bytes_limit_ = limit;
}
size_t GetBytesUsedForTesting() const { return bytes_used_; }
+ size_t GetNumCacheEntriesForTesting() const {
+ return persistent_cache_.size();
+ }
size_t GetDrawImageSizeForTesting(const DrawImage& image);
void SetImageDecodingFailedForTesting(const DrawImage& image);
bool DiscardableIsLockedForTesting(const DrawImage& image);
@@ -300,9 +303,6 @@ class CC_EXPORT GpuImageDecodeController
ImageData* image_data);
void DeletePendingImages();
- // Overriden from base::MemoryCoordinatorClient.
- void OnMemoryStateChange(base::MemoryState state) override;
-
const ResourceFormat format_;
ContextProvider* context_;
sk_sp<GrContextThreadSafeProxy> context_threadsafe_proxy_;
@@ -320,10 +320,10 @@ class CC_EXPORT GpuImageDecodeController
using InUseCache = std::unordered_map<InUseCacheKey, InUseCacheEntry>;
InUseCache in_use_cache_;
- size_t cached_items_limit_;
- size_t cached_bytes_limit_;
- size_t bytes_used_;
- const size_t max_gpu_image_bytes_;
+ const size_t normal_max_gpu_image_bytes_;
+ size_t cached_bytes_limit_ = normal_max_gpu_image_bytes_;
+ size_t bytes_used_ = 0;
+ base::MemoryState memory_state_ = base::MemoryState::NORMAL;
// We can't release GPU backed SkImages without holding the context lock,
// so we add them to this list and defer deletion until the next time the lock
« no previous file with comments | « cc/resources/resource_pool_unittest.cc ('k') | cc/tiles/gpu_image_decode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698