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

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

Issue 2552153002: [BlobStorage] Enabling disk paging and direct storage. (Closed)
Patch Set: fixed windows build Created 4 years 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: 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 6f9e15f277b75c8122930bb622ba2c668788bafc..a388c2bf777fccb88bb1dd893db8853c53a8fd13 100644
--- a/storage/browser/blob/blob_memory_controller.h
+++ b/storage/browser/blob/blob_memory_controller.h
@@ -16,7 +16,7 @@
#include <utility>
#include <vector>
-#include "base/callback.h"
+#include "base/callback_forward.h"
#include "base/callback_helpers.h"
#include "base/containers/mru_cache.h"
#include "base/files/file.h"
@@ -156,11 +156,27 @@ class STORAGE_EXPORT BlobMemoryController {
size_t memory_usage() const { return blob_memory_used_; }
uint64_t disk_usage() const { return disk_used_; }
+ // Schedules a task on the file runner to calculate blob storage quota limits.
+ void CalculateBlobStorageLimits();
+
+ base::WeakPtr<BlobMemoryController> GetWeakPtr();
+
const BlobStorageLimits& limits() const { return limits_; }
void set_limits_for_testing(const BlobStorageLimits& limits) {
+ manual_limits_set_ = true;
limits_ = limits;
}
+ class DiskSpaceTestGetter {
michaeln 2017/01/06 20:58:52 class for this might be overkill, would a function
dmurph 2017/01/06 22:24:30 Done.
+ public:
+ virtual ~DiskSpaceTestGetter() {}
+ virtual int64_t AmountOfFreeDiskSpace() const = 0;
+ };
+
+ void set_testing_disk_space(DiskSpaceTestGetter* disk_space_interface) {
+ disk_space_test_getter_ = disk_space_interface;
+ }
+
private:
class FileQuotaAllocationTask;
class MemoryQuotaAllocationTask;
@@ -170,6 +186,12 @@ class STORAGE_EXPORT BlobMemoryController {
using PendingFileQuotaTaskList =
std::list<std::unique_ptr<FileQuotaAllocationTask>>;
+ void OnStorageLimitsCalculated(BlobStorageLimits limits);
+
+ // Adjusts the effective disk usage based on the available space. We try to
+ // keep at least BlobSorageLimits::min_available_disk_space() free.
+ void AdjustDiskUsage(uint64_t avail_disk_space);
+
base::WeakPtr<QuotaAllocationTask> AppendMemoryTask(
uint64_t total_bytes_needed,
std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_memory_items,
@@ -189,7 +211,7 @@ class STORAGE_EXPORT BlobMemoryController {
scoped_refptr<ShareableFileReference> file_reference,
std::vector<scoped_refptr<ShareableBlobDataItem>> items,
size_t total_items_size,
- FileCreationInfo result);
+ std::pair<FileCreationInfo, int64_t> result);
size_t GetAvailableMemoryForBlobs() const;
uint64_t GetAvailableFileSpaceForBlobs() const;
@@ -209,6 +231,9 @@ class STORAGE_EXPORT BlobMemoryController {
// changes.
void RecordTracingCounters() const;
+ // Store that we set manual limits so we don't accidentally override them with
+ // our configuration task.
+ bool manual_limits_set_ = false;
BlobStorageLimits limits_;
// Memory bookkeeping. These numbers are all disjoint.
@@ -233,6 +258,9 @@ class STORAGE_EXPORT BlobMemoryController {
bool file_paging_enabled_ = false;
base::FilePath blob_storage_dir_;
scoped_refptr<base::TaskRunner> file_runner_;
+ // This is only set when we're in a test, and we assume the lifetime is longer
+ // than our class and the file operations.
+ DiskSpaceTestGetter* disk_space_test_getter_ = nullptr;
// Lifetime of the ShareableBlobDataItem objects is handled externally in the
// BlobStorageContext class.

Powered by Google App Engine
This is Rietveld 408576698