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

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

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: comments from Marijn 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
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 #include "storage/browser/blob/blob_memory_controller.h" 5 #include "storage/browser/blob/blob_memory_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items, 485 std::vector<scoped_refptr<ShareableBlobDataItem>> unreserved_file_items,
486 const FileQuotaRequestCallback& done_callback) { 486 const FileQuotaRequestCallback& done_callback) {
487 pending_file_quota_tasks_.push_back(base::MakeUnique<FileQuotaAllocationTask>( 487 pending_file_quota_tasks_.push_back(base::MakeUnique<FileQuotaAllocationTask>(
488 this, std::move(unreserved_file_items), done_callback)); 488 this, std::move(unreserved_file_items), done_callback));
489 pending_file_quota_tasks_.back()->set_my_list_position( 489 pending_file_quota_tasks_.back()->set_my_list_position(
490 --pending_file_quota_tasks_.end()); 490 --pending_file_quota_tasks_.end());
491 return pending_file_quota_tasks_.back()->GetWeakPtr(); 491 return pending_file_quota_tasks_.back()->GetWeakPtr();
492 } 492 }
493 493
494 void BlobMemoryController::NotifyMemoryItemsUsed( 494 void BlobMemoryController::NotifyMemoryItemsUsed(
495 std::vector<scoped_refptr<ShareableBlobDataItem>>& items) { 495 const std::vector<scoped_refptr<ShareableBlobDataItem>>& items) {
496 for (const auto& item : items) { 496 for (const auto& item : items) {
497 DCHECK_EQ(DataElement::TYPE_BYTES, item->item()->type()); 497 if (item->item()->type() != DataElement::TYPE_BYTES ||
498 DCHECK_EQ(ShareableBlobDataItem::POPULATED_WITH_QUOTA, item->state()); 498 item->state() != ShareableBlobDataItem::POPULATED_WITH_QUOTA) {
499 continue;
500 }
499 // We don't want to re-add the item if we're currently paging it to disk. 501 // We don't want to re-add the item if we're currently paging it to disk.
500 if (items_paging_to_file_.find(item->item_id()) != 502 if (items_paging_to_file_.find(item->item_id()) !=
501 items_paging_to_file_.end()) { 503 items_paging_to_file_.end()) {
502 return; 504 return;
503 } 505 }
504 auto iterator = populated_memory_items_.Get(item->item_id()); 506 auto iterator = populated_memory_items_.Get(item->item_id());
505 if (iterator == populated_memory_items_.end()) { 507 if (iterator == populated_memory_items_.end()) {
506 populated_memory_items_bytes_ += 508 populated_memory_items_bytes_ +=
507 static_cast<size_t>(item->item()->length()); 509 static_cast<size_t>(item->item()->length());
508 populated_memory_items_.Put(item->item_id(), item.get()); 510 populated_memory_items_.Put(item->item_id(), item.get());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 MaybeGrantPendingMemoryRequests(); 723 MaybeGrantPendingMemoryRequests();
722 } 724 }
723 725
724 void BlobMemoryController::OnBlobFileDelete(uint64_t size, 726 void BlobMemoryController::OnBlobFileDelete(uint64_t size,
725 const FilePath& path) { 727 const FilePath& path) {
726 DCHECK_LE(size, disk_used_); 728 DCHECK_LE(size, disk_used_);
727 disk_used_ -= size; 729 disk_used_ -= size;
728 } 730 }
729 731
730 } // namespace storage 732 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698