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

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

Issue 1528233004: [Blob] Blob paging to disk patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-disk1
Patch Set: Created 5 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
« no previous file with comments | « storage/browser/blob/blob_storage_context.h ('k') | storage/browser/blob/shareable_blob_data_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/blob_storage_context.cc
diff --git a/storage/browser/blob/blob_storage_context.cc b/storage/browser/blob/blob_storage_context.cc
index cf190aaba43e8d7370209e295da81f23a9758fb5..53924642ffdfd749a153f4ad2e775916663b0763 100644
--- a/storage/browser/blob/blob_storage_context.cc
+++ b/storage/browser/blob/blob_storage_context.cc
@@ -27,7 +27,13 @@ namespace storage {
using BlobRegistryEntry = BlobStorageRegistry::Entry;
using BlobState = BlobStorageRegistry::BlobState;
-BlobStorageContext::BlobStorageContext() : memory_usage_(0) {}
+BlobStorageContext::BlobStorageContext() {}
+
+BlobStorageContext::BlobStorageContext(
+ bool enable_disk,
+ const base::FilePath& blob_storage_dir,
+ scoped_refptr<base::TaskRunner> file_runner)
+ : memory_controller_(enable_disk, blob_storage_dir, file_runner) {}
BlobStorageContext::~BlobStorageContext() {
}
@@ -221,6 +227,11 @@ void BlobStorageContext::DecrementBlobRefCount(const std::string& uuid) {
}
DCHECK_LE(memory_freeing, memory_usage_);
memory_usage_ -= memory_freeing;
+ for (const auto& item_refptr : entry->data->items_) {
+ if (item_refptr->num_referencing_blob() == 0) {
+ memory_controller_.RemoveBlobItemInRecents(item_refptr->item_id());
+ }
+ }
registry_.DeleteEntry(uuid);
}
}
@@ -268,8 +279,8 @@ bool BlobStorageContext::AppendAllocatedBlobItem(
break;
}
memory_usage_ += length;
- target_blob_builder->AppendSharedBlobItem(
- new ShareableBlobDataItem(target_blob_uuid, blob_item));
+ target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
+ target_blob_uuid, GetAndIncrementItemId(), blob_item));
break;
case DataElement::TYPE_FILE: {
bool full_file = (length == std::numeric_limits<uint64>::max());
@@ -278,8 +289,8 @@ bool BlobStorageContext::AppendAllocatedBlobItem(
UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.File",
(length - offset) / 1024);
}
- target_blob_builder->AppendSharedBlobItem(
- new ShareableBlobDataItem(target_blob_uuid, blob_item));
+ target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
+ target_blob_uuid, GetAndIncrementItemId(), blob_item));
break;
}
case DataElement::TYPE_FILE_FILESYSTEM: {
@@ -290,8 +301,8 @@ bool BlobStorageContext::AppendAllocatedBlobItem(
UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.FileSystem",
(length - offset) / 1024);
}
- target_blob_builder->AppendSharedBlobItem(
- new ShareableBlobDataItem(target_blob_uuid, blob_item));
+ target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
+ target_blob_uuid, GetAndIncrementItemId(), blob_item));
break;
}
case DataElement::TYPE_BLOB: {
@@ -312,8 +323,8 @@ bool BlobStorageContext::AppendAllocatedBlobItem(
case DataElement::TYPE_DISK_CACHE_ENTRY: {
UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.CacheEntry",
(length - offset) / 1024);
- target_blob_builder->AppendSharedBlobItem(
- new ShareableBlobDataItem(target_blob_uuid, blob_item));
+ target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
+ target_blob_uuid, GetAndIncrementItemId(), blob_item));
break;
}
case DataElement::TYPE_BYTES_DESCRIPTION:
@@ -378,8 +389,9 @@ bool BlobStorageContext::AppendBlob(
element->SetToBytes(item.bytes() + offset,
static_cast<int64>(new_length));
memory_usage_ += new_length;
- target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
- target_blob_uuid, new BlobDataItem(element.Pass())));
+ target_blob_builder->AppendSharedBlobItem(
+ new ShareableBlobDataItem(target_blob_uuid, GetAndIncrementItemId(),
+ new BlobDataItem(element.Pass())));
} break;
case DataElement::TYPE_FILE: {
DCHECK_NE(item.length(), std::numeric_limits<uint64>::max())
@@ -391,7 +403,7 @@ bool BlobStorageContext::AppendBlob(
new_length,
item.expected_modification_time());
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
- target_blob_uuid,
+ target_blob_uuid, GetAndIncrementItemId(),
new BlobDataItem(element.Pass(), item.data_handle_)));
} break;
case DataElement::TYPE_FILE_FILESYSTEM: {
@@ -401,15 +413,16 @@ bool BlobStorageContext::AppendBlob(
element->SetToFileSystemUrlRange(item.filesystem_url(),
item.offset() + offset, new_length,
item.expected_modification_time());
- target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
- target_blob_uuid, new BlobDataItem(element.Pass())));
+ target_blob_builder->AppendSharedBlobItem(
+ new ShareableBlobDataItem(target_blob_uuid, GetAndIncrementItemId(),
+ new BlobDataItem(element.Pass())));
} break;
case DataElement::TYPE_DISK_CACHE_ENTRY: {
scoped_ptr<DataElement> element(new DataElement());
element->SetToDiskCacheEntryRange(item.offset() + offset,
new_length);
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
- target_blob_uuid,
+ target_blob_uuid, GetAndIncrementItemId(),
new BlobDataItem(element.Pass(), item.data_handle_,
item.disk_cache_entry(),
item.disk_cache_stream_index())));
@@ -476,4 +489,14 @@ bool BlobStorageContext::CleanupCanceledAsyncBlobTransfer(
return true;
}
+uint64_t BlobStorageContext::GetAndIncrementItemId() {
+ return next_item_id_++;
+}
+
+void BlobStorageContext::UpdateItemsInRecents(BlobRegistryEntry* entry) {
+ for (const auto& item_refptr : entry->data->items_) {
+ memory_controller_.UpdateBlobItemInRecents(item_refptr.get());
+ }
+}
+
} // namespace storage
« no previous file with comments | « storage/browser/blob/blob_storage_context.h ('k') | storage/browser/blob/shareable_blob_data_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698