| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/internal_blob_data.h" | 5 #include "storage/browser/blob/internal_blob_data.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 DCHECK(data_); | 25 DCHECK(data_); |
| 26 data_->items_.push_back(item); | 26 data_->items_.push_back(item); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void InternalBlobData::Builder::RemoveBlobFromShareableItems( | 29 void InternalBlobData::Builder::RemoveBlobFromShareableItems( |
| 30 const std::string& blob_uuid) { | 30 const std::string& blob_uuid) { |
| 31 DCHECK(data_); | 31 DCHECK(data_); |
| 32 data_->RemoveBlobFromShareableItems(blob_uuid); | 32 data_->RemoveBlobFromShareableItems(blob_uuid); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void InternalBlobData::Builder::set_content_type( | |
| 36 const std::string& content_type) { | |
| 37 DCHECK(data_); | |
| 38 data_->content_type_ = content_type; | |
| 39 } | |
| 40 | |
| 41 void InternalBlobData::Builder::set_content_disposition( | |
| 42 const std::string& content_disposition) { | |
| 43 DCHECK(data_); | |
| 44 data_->content_disposition_ = content_disposition; | |
| 45 } | |
| 46 | |
| 47 size_t InternalBlobData::Builder::GetNonsharedMemoryUsage() const { | 35 size_t InternalBlobData::Builder::GetNonsharedMemoryUsage() const { |
| 48 DCHECK(data_); | 36 DCHECK(data_); |
| 49 return data_->GetUnsharedMemoryUsage(); | 37 return data_->GetUnsharedMemoryUsage(); |
| 50 } | 38 } |
| 51 | 39 |
| 52 scoped_ptr<InternalBlobData> InternalBlobData::Builder::Build() { | 40 scoped_ptr<InternalBlobData> InternalBlobData::Builder::Build() { |
| 53 DCHECK(data_); | 41 DCHECK(data_); |
| 54 return std::move(data_); | 42 return std::move(data_); |
| 55 } | 43 } |
| 56 | 44 |
| 57 InternalBlobData::InternalBlobData() { | 45 InternalBlobData::InternalBlobData() { |
| 58 } | 46 } |
| 59 | 47 |
| 60 InternalBlobData::~InternalBlobData() { | 48 InternalBlobData::~InternalBlobData() { |
| 61 } | 49 } |
| 62 | 50 |
| 63 const std::vector<scoped_refptr<ShareableBlobDataItem>>& | 51 const std::vector<scoped_refptr<ShareableBlobDataItem>>& |
| 64 InternalBlobData::items() const { | 52 InternalBlobData::items() const { |
| 65 return items_; | 53 return items_; |
| 66 } | 54 } |
| 67 const std::string& InternalBlobData::content_type() const { | |
| 68 return content_type_; | |
| 69 } | |
| 70 const std::string& InternalBlobData::content_disposition() const { | |
| 71 return content_disposition_; | |
| 72 } | |
| 73 | 55 |
| 74 void InternalBlobData::RemoveBlobFromShareableItems( | 56 void InternalBlobData::RemoveBlobFromShareableItems( |
| 75 const std::string& blob_uuid) { | 57 const std::string& blob_uuid) { |
| 76 for (auto& data_item : items_) { | 58 for (auto& data_item : items_) { |
| 77 data_item->referencing_blobs().erase(blob_uuid); | 59 data_item->referencing_blobs().erase(blob_uuid); |
| 78 } | 60 } |
| 79 } | 61 } |
| 80 | 62 |
| 81 size_t InternalBlobData::GetUnsharedMemoryUsage() const { | 63 size_t InternalBlobData::GetUnsharedMemoryUsage() const { |
| 82 size_t memory = 0; | 64 size_t memory = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 if (data_item->referencing_blobs().size() == 1 && | 86 if (data_item->referencing_blobs().size() == 1 && |
| 105 seen_items.find(data_item.get()) == seen_items.end()) { | 87 seen_items.find(data_item.get()) == seen_items.end()) { |
| 106 *unshared_memory += data_item->item()->length(); | 88 *unshared_memory += data_item->item()->length(); |
| 107 seen_items.insert(data_item.get()); | 89 seen_items.insert(data_item.get()); |
| 108 } | 90 } |
| 109 } | 91 } |
| 110 } | 92 } |
| 111 } | 93 } |
| 112 | 94 |
| 113 } // namespace storage | 95 } // namespace storage |
| OLD | NEW |