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

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

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « storage/browser/blob/blob_memory_controller.h ('k') | storage/browser/blob/blob_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/blob_memory_controller.cc
diff --git a/storage/browser/blob/blob_memory_controller.cc b/storage/browser/blob/blob_memory_controller.cc
index 422cddf748963812aef5869e5d7e35cb3c10fd28..6cc6c3f291f72005a32f017737a24984faece169 100644
--- a/storage/browser/blob/blob_memory_controller.cc
+++ b/storage/browser/blob/blob_memory_controller.cc
@@ -492,10 +492,12 @@ base::WeakPtr<QuotaAllocationTask> BlobMemoryController::ReserveFileQuota(
}
void BlobMemoryController::NotifyMemoryItemsUsed(
- std::vector<scoped_refptr<ShareableBlobDataItem>>& items) {
+ const std::vector<scoped_refptr<ShareableBlobDataItem>>& items) {
for (const auto& item : items) {
- DCHECK_EQ(DataElement::TYPE_BYTES, item->item()->type());
- DCHECK_EQ(ShareableBlobDataItem::POPULATED_WITH_QUOTA, item->state());
+ if (item->item()->type() != DataElement::TYPE_BYTES ||
+ item->state() != ShareableBlobDataItem::POPULATED_WITH_QUOTA) {
+ continue;
+ }
// We don't want to re-add the item if we're currently paging it to disk.
if (items_paging_to_file_.find(item->item_id()) !=
items_paging_to_file_.end()) {
@@ -699,7 +701,14 @@ uint64_t BlobMemoryController::GetAvailableFileSpaceForBlobs() const {
void BlobMemoryController::GrantMemoryAllocations(
std::vector<scoped_refptr<ShareableBlobDataItem>>* items,
size_t total_bytes) {
+ // These metrics let us calculate the global distribution of blob storage by
+ // subtracting the histograms.
+ UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeBeforeAppend",
+ blob_memory_used_ / 1024);
blob_memory_used_ += total_bytes;
+ UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeAfterAppend",
+ blob_memory_used_ / 1024);
+
for (auto& item : *items) {
item->set_state(ShareableBlobDataItem::QUOTA_GRANTED);
item->set_memory_allocation(base::MakeUnique<MemoryAllocation>(
@@ -711,7 +720,15 @@ void BlobMemoryController::GrantMemoryAllocations(
void BlobMemoryController::RevokeMemoryAllocation(uint64_t item_id,
size_t length) {
DCHECK_LE(length, blob_memory_used_);
+
+ // These metrics let us calculate the global distribution of blob storage by
+ // subtracting the histograms.
+ UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeBeforeAppend",
+ blob_memory_used_ / 1024);
blob_memory_used_ -= length;
+ UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeAfterAppend",
+ blob_memory_used_ / 1024);
+
auto iterator = populated_memory_items_.Get(item_id);
if (iterator != populated_memory_items_.end()) {
DCHECK_GE(populated_memory_items_bytes_, length);
« no previous file with comments | « storage/browser/blob/blob_memory_controller.h ('k') | storage/browser/blob/blob_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698