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..0238381d8b091bf0a50965c6f44e00b267a0e20c 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,11 @@ 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(bool on_memory_pressure); |
dmurph
2017/05/09 21:57:33
Please make the argument MemoryPressureLevel inste
ssid
2017/05/10 00:21:38
Done.
|
// 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 +220,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 +274,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 +285,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); |