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

Side by Side Diff: storage/browser/blob/blob_memory_controller.h

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: comments Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « storage/browser/blob/blob_entry.cc ('k') | storage/browser/blob/blob_memory_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_ 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_ 6 #define STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 27 matching lines...) Expand all
38 class ShareableBlobDataItem; 38 class ShareableBlobDataItem;
39 class ShareableFileReference; 39 class ShareableFileReference;
40 40
41 // This class's main responsibility is deciding how blob data gets stored. 41 // This class's main responsibility is deciding how blob data gets stored.
42 // This encompasses: 42 // This encompasses:
43 // * Keeping track of memory & file quota, 43 // * Keeping track of memory & file quota,
44 // * How to transport the blob data from the renderer (DetermineStrategy), 44 // * How to transport the blob data from the renderer (DetermineStrategy),
45 // * Allocating memory & file quota (ReserveMemoryQuota, ReserveFileQuota) 45 // * Allocating memory & file quota (ReserveMemoryQuota, ReserveFileQuota)
46 // * Paging memory quota to disk when we're nearing our memory limit, and 46 // * Paging memory quota to disk when we're nearing our memory limit, and
47 // * Maintaining an LRU of memory items to choose candidates to page to disk 47 // * Maintaining an LRU of memory items to choose candidates to page to disk
48 // (NotifyMemoryItemUsed). 48 // (NotifyMemoryItemsUsed).
49 // This class can only be interacted with on the IO thread. 49 // This class can only be interacted with on the IO thread.
50 class STORAGE_EXPORT BlobMemoryController { 50 class STORAGE_EXPORT BlobMemoryController {
51 public: 51 public:
52 enum class Strategy { 52 enum class Strategy {
53 // We don't have enough memory for this blob. 53 // We don't have enough memory for this blob.
54 TOO_LARGE, 54 TOO_LARGE,
55 // There isn't any memory that needs transporting. 55 // There isn't any memory that needs transporting.
56 NONE_NEEDED, 56 NONE_NEEDED,
57 // Transportation strategies. 57 // Transportation strategies.
58 IPC, 58 IPC,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // |done_callback|. 145 // |done_callback|.
146 // Returns a task handle for cancellation. 146 // Returns a task handle for cancellation.
147 // NOTE: We don't inspect quota limits and assume the user checked 147 // NOTE: We don't inspect quota limits and assume the user checked
148 // CanReserveQuota before calling this. 148 // CanReserveQuota before calling this.
149 base::WeakPtr<QuotaAllocationTask> ReserveFileQuota( 149 base::WeakPtr<QuotaAllocationTask> ReserveFileQuota(
150 std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items, 150 std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
151 const FileQuotaRequestCallback& done_callback); 151 const FileQuotaRequestCallback& done_callback);
152 152
153 // Called when initially populated or upon later access. 153 // Called when initially populated or upon later access.
154 void NotifyMemoryItemsUsed( 154 void NotifyMemoryItemsUsed(
155 std::vector<scoped_refptr<ShareableBlobDataItem>>& items); 155 const std::vector<scoped_refptr<ShareableBlobDataItem>>& items);
156 156
157 size_t memory_usage() const { return blob_memory_used_; } 157 size_t memory_usage() const { return blob_memory_used_; }
158 uint64_t disk_usage() const { return disk_used_; } 158 uint64_t disk_usage() const { return disk_used_; }
159 159
160 const BlobStorageLimits& limits() const { return limits_; } 160 const BlobStorageLimits& limits() const { return limits_; }
161 void set_limits_for_testing(const BlobStorageLimits& limits) { 161 void set_limits_for_testing(const BlobStorageLimits& limits) {
162 limits_ = limits; 162 limits_ = limits;
163 } 163 }
164 164
165 private: 165 private:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // another blob successfully grabs a ref, we can prevent it from adding the 243 // another blob successfully grabs a ref, we can prevent it from adding the
244 // item to the recent_item_cache_ above. 244 // item to the recent_item_cache_ above.
245 std::unordered_set<uint64_t> items_paging_to_file_; 245 std::unordered_set<uint64_t> items_paging_to_file_;
246 246
247 base::WeakPtrFactory<BlobMemoryController> weak_factory_; 247 base::WeakPtrFactory<BlobMemoryController> weak_factory_;
248 248
249 DISALLOW_COPY_AND_ASSIGN(BlobMemoryController); 249 DISALLOW_COPY_AND_ASSIGN(BlobMemoryController);
250 }; 250 };
251 } // namespace storage 251 } // namespace storage
252 #endif // STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_ 252 #endif // STORAGE_BROWSER_BLOB_BLOB_MEMORY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « storage/browser/blob/blob_entry.cc ('k') | storage/browser/blob/blob_memory_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698