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

Unified Diff: storage/browser/blob/blob_memory_controller.h

Issue 2857283002: Add memory pressure listener to Blob storage (Closed)
Patch Set: Rename constant, use base::Uma function and add base attribute. Created 3 years, 7 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 | « no previous file | storage/browser/blob/blob_memory_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/blob_memory_controller.h
diff --git a/storage/browser/blob/blob_memory_controller.h b/storage/browser/blob/blob_memory_controller.h
index eb29518a15e25194c5ac0ca2599549451c44ddbe..7c72d0f9a1ac12ccdf14cae99a4173d94c83c63b 100644
--- a/storage/browser/blob/blob_memory_controller.h
+++ b/storage/browser/blob/blob_memory_controller.h
@@ -21,7 +21,9 @@
#include "base/containers/mru_cache.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
+#include "base/memory/memory_pressure_listener.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
@@ -178,6 +180,7 @@ class STORAGE_EXPORT BlobMemoryController {
class FileQuotaAllocationTask;
class MemoryQuotaAllocationTask;
+ FRIEND_TEST_ALL_PREFIXES(BlobMemoryControllerTest, OnMemoryPressure);
// So this (and only this) class can call CalculateBlobStorageLimits().
friend class content::ChromeBlobStorageContext;
@@ -205,10 +208,12 @@ class STORAGE_EXPORT BlobMemoryController {
void MaybeGrantPendingMemoryRequests();
size_t CollectItemsForEviction(
- std::vector<scoped_refptr<ShareableBlobDataItem>>* output);
+ std::vector<scoped_refptr<ShareableBlobDataItem>>* output,
+ uint64_t min_page_file_size);
// Schedule paging until our memory usage is below our memory limit.
- void MaybeScheduleEvictionUntilSystemHealthy();
+ void MaybeScheduleEvictionUntilSystemHealthy(
+ base::MemoryPressureListener::MemoryPressureLevel level);
// Called when we've completed evicting a list of items to disk. This is where
// we swap the bytes items for file items, and update our bookkeeping.
@@ -216,7 +221,12 @@ class STORAGE_EXPORT BlobMemoryController {
scoped_refptr<ShareableFileReference> file_reference,
std::vector<scoped_refptr<ShareableBlobDataItem>> items,
size_t total_items_size,
- std::pair<FileCreationInfo, int64_t /* disk_avail */> result);
+ const char* evict_reason,
+ size_t memory_usage_before_eviction,
+ std::pair<FileCreationInfo, int64_t /* avail_disk */> result);
+
+ void OnMemoryPressure(
+ base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
size_t GetAvailableMemoryForBlobs() const;
uint64_t GetAvailableFileSpaceForBlobs() const;
@@ -265,6 +275,7 @@ class STORAGE_EXPORT BlobMemoryController {
scoped_refptr<base::TaskRunner> file_runner_;
// This defaults to calling base::SysInfo::AmountOfFreeDiskSpace.
DiskSpaceFuncPtr disk_space_function_;
+ base::TimeTicks last_eviction_time_;
// Lifetime of the ShareableBlobDataItem objects is handled externally in the
// BlobStorageContext class.
@@ -275,6 +286,8 @@ class STORAGE_EXPORT BlobMemoryController {
// item to the recent_item_cache_ above.
std::unordered_set<uint64_t> items_paging_to_file_;
+ base::MemoryPressureListener memory_pressure_listener_;
+
base::WeakPtrFactory<BlobMemoryController> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(BlobMemoryController);
« no previous file with comments | « no previous file | storage/browser/blob/blob_memory_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698