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

Unified Diff: storage/browser/blob/blob_async_transport_strategy.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_async_transport_strategy.h ('k') | storage/browser/blob/blob_data_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/blob_async_transport_strategy.cc
diff --git a/storage/browser/blob/blob_async_transport_strategy.cc b/storage/browser/blob/blob_async_transport_strategy.cc
index 8dbe52ed9a33712d33a5466dc7a6b1439dc5fdb0..ce86cc93ae549802ad994e7b3636bf2e8a91287a 100644
--- a/storage/browser/blob/blob_async_transport_strategy.cc
+++ b/storage/browser/blob/blob_async_transport_strategy.cc
@@ -190,96 +190,60 @@ void ForEachWithSegment(const std::vector<DataElement>& elements,
BlobAsyncTransportStrategy::RendererMemoryItemRequest::
RendererMemoryItemRequest()
- : browser_item_index(0), browser_item_offset(0), received(false) {}
+ : browser_item_index(0), browser_item_offset(0) {}
BlobAsyncTransportStrategy::BlobAsyncTransportStrategy()
: error_(BlobAsyncTransportStrategy::ERROR_NONE), total_bytes_size_(0) {}
BlobAsyncTransportStrategy::~BlobAsyncTransportStrategy() {}
-// if total_blob_size > |memory_available| (say 400MB)
-// Request all data in files
-// (Segment all of the existing data into
-// file blocks, of <= |max_file_size|)
-// else if total_blob_size > |max_ipc_memory_size| (say 150KB)
-// Request all data in shared memory
-// (Segment all of the existing data into
-// shared memory blocks, of <= |max_shared_memory_size|)
-// else
-// Request all data to be sent over IPC
-void BlobAsyncTransportStrategy::Initialize(
- size_t max_ipc_memory_size,
- size_t max_shared_memory_size,
+// Initializes the transport strategy for file requests.
+void BlobAsyncTransportStrategy::InitializeForFileRequests(
size_t max_file_size,
- uint64_t disk_space_left,
- size_t memory_available,
const std::string& uuid,
- const std::vector<DataElement>& blob_item_infos) {
- DCHECK(handle_sizes_.empty());
+ uint64_t blob_total_size,
+ const std::vector<DataElement>& blob_item_infos,
+ BlobDataBuilder* builder) {
DCHECK(requests_.empty());
- DCHECK(!builder_.get());
- builder_.reset(new BlobDataBuilder(uuid));
- error_ = BlobAsyncTransportStrategy::ERROR_NONE;
-
- size_t memory_items = 0;
- base::CheckedNumeric<uint64_t> total_size_checked = 0;
- for (const auto& info : blob_item_infos) {
- if (!IsBytes(info.type())) {
- continue;
- }
- total_size_checked += info.length();
- ++memory_items;
- }
-
- if (!total_size_checked.IsValid()) {
- DVLOG(1) << "Impossible total size of all memory elements.";
- error_ = BlobAsyncTransportStrategy::ERROR_INVALID_PARAMS;
- return;
- }
-
- total_bytes_size_ = total_size_checked.ValueOrDie();
-
- // See if we have enough memory.
- if (total_bytes_size_ >
- disk_space_left + static_cast<uint64_t>(memory_available)) {
- error_ = BlobAsyncTransportStrategy::ERROR_TOO_LARGE;
- return;
- }
-
- // If we're more than the available memory, then we're going straight to disk.
- if (total_bytes_size_ > memory_available) {
- if (total_bytes_size_ > disk_space_left) {
- error_ = BlobAsyncTransportStrategy::ERROR_TOO_LARGE;
- return;
- }
- ComputeHandleSizes(total_bytes_size_, max_file_size, &handle_sizes_);
- FileStorageStrategy strategy(&requests_, builder_.get());
- ForEachWithSegment(blob_item_infos, static_cast<uint64_t>(max_file_size),
- &strategy);
- return;
- }
+ total_bytes_size_ = blob_total_size;
+ ComputeHandleSizes(total_bytes_size_, max_file_size, &file_handle_sizes_);
+ FileStorageStrategy strategy(&requests_, builder);
+ ForEachWithSegment(blob_item_infos, static_cast<uint64_t>(max_file_size),
+ &strategy);
+}
- if (total_bytes_size_ > max_ipc_memory_size) {
- // Note: The size must be <= std::numeric_limits<size_t>::max(). Otherwise
- // we are guarenteed to be caught by the if statement above,
- // |total_bytes_size_ > memory_available|.
- ComputeHandleSizes(total_bytes_size_, max_shared_memory_size,
- &handle_sizes_);
- SharedMemoryStorageStrategy strategy(max_shared_memory_size, &requests_,
- builder_.get());
- ForEachWithSegment(blob_item_infos,
- static_cast<uint64_t>(max_shared_memory_size),
- &strategy);
- return;
- }
+void BlobAsyncTransportStrategy::InitializeForSharedMemoryRequests(
+ size_t max_shared_memory_size,
+ const std::string& uuid,
+ uint64_t blob_total_size,
+ const std::vector<DataElement>& blob_item_infos,
+ BlobDataBuilder* builder) {
+ DCHECK(requests_.empty());
+ DCHECK(blob_total_size <= std::numeric_limits<size_t>::max());
+ total_bytes_size_ = blob_total_size;
+ ComputeHandleSizes(total_bytes_size_, max_shared_memory_size,
+ &shared_memory_handle_sizes_);
+ SharedMemoryStorageStrategy strategy(max_shared_memory_size, &requests_,
+ builder);
+ ForEachWithSegment(blob_item_infos,
+ static_cast<uint64_t>(max_shared_memory_size), &strategy);
+}
- // Since they can all fit in IPC memory, we don't need to segment anything,
- // and just request them straight in IPC.
+void BlobAsyncTransportStrategy::InitializeForIPCTransportation(
+ size_t max_ipc_memory_size,
+ const std::string& uuid,
+ uint64_t blob_total_size,
+ const std::vector<DataElement>& blob_item_infos,
+ BlobDataBuilder* builder) {
+ DCHECK(requests_.empty());
+ // We don't ssegment anything, and just request the memory items directly
+ // in IPC.
size_t items_length = blob_item_infos.size();
+ total_bytes_size_ = blob_total_size;
for (size_t i = 0; i < items_length; i++) {
const auto& info = blob_item_infos.at(i);
if (!IsBytes(info.type())) {
- builder_->AppendIPCDataElement(info);
+ builder->AppendIPCDataElement(info);
continue;
}
BlobAsyncTransportStrategy::RendererMemoryItemRequest request;
@@ -291,7 +255,7 @@ void BlobAsyncTransportStrategy::Initialize(
request.message.renderer_item_offset = 0;
request.message.size = info.length();
requests_.push_back(request);
- builder_->AppendFutureData(info.length());
+ builder->AppendFutureData(info.length());
}
}
« no previous file with comments | « storage/browser/blob/blob_async_transport_strategy.h ('k') | storage/browser/blob/blob_data_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698