| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/blob_data_builder.h" | 5 #include "storage/browser/blob/blob_data_builder.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "net/disk_cache/disk_cache.h" | 10 #include "net/disk_cache/disk_cache.h" |
| 11 #include "storage/browser/blob/shareable_file_reference.h" | |
| 12 | 11 |
| 13 namespace storage { | 12 namespace storage { |
| 14 | 13 |
| 15 const char BlobDataBuilder::kAppendFutureFileTemporaryFileName[] = | 14 const char BlobDataBuilder::kAppendFutureFileTemporaryFileName[] = |
| 16 "kFakeFilenameToBeChangedByPopulateFutureFile"; | 15 "kFakeFilenameToBeChangedByPopulateFutureFile"; |
| 17 | 16 |
| 18 BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) { | 17 BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) { |
| 19 } | 18 } |
| 20 BlobDataBuilder::~BlobDataBuilder() { | 19 BlobDataBuilder::~BlobDataBuilder() { |
| 21 } | 20 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 uint64_t offset, | 134 uint64_t offset, |
| 136 uint64_t length, | 135 uint64_t length, |
| 137 const base::Time& expected_modification_time) { | 136 const base::Time& expected_modification_time) { |
| 138 scoped_ptr<DataElement> element(new DataElement()); | 137 scoped_ptr<DataElement> element(new DataElement()); |
| 139 element->SetToFilePathRange(file_path, offset, length, | 138 element->SetToFilePathRange(file_path, offset, length, |
| 140 expected_modification_time); | 139 expected_modification_time); |
| 141 items_.push_back( | 140 items_.push_back( |
| 142 new BlobDataItem(element.Pass(), ShareableFileReference::Get(file_path))); | 141 new BlobDataItem(element.Pass(), ShareableFileReference::Get(file_path))); |
| 143 } | 142 } |
| 144 | 143 |
| 144 void BlobDataBuilder::AppendShareableFileReference( |
| 145 const scoped_refptr<ShareableFileReference> file, |
| 146 uint64_t offset, |
| 147 uint64_t length, |
| 148 const base::Time& expected_modification_time) { |
| 149 scoped_ptr<DataElement> element(new DataElement()); |
| 150 element->SetToFilePathRange(file->path(), offset, length, |
| 151 expected_modification_time); |
| 152 items_.push_back(new BlobDataItem(element.Pass(), file)); |
| 153 } |
| 154 |
| 145 void BlobDataBuilder::AppendBlob(const std::string& uuid, | 155 void BlobDataBuilder::AppendBlob(const std::string& uuid, |
| 146 uint64_t offset, | 156 uint64_t offset, |
| 147 uint64_t length) { | 157 uint64_t length) { |
| 148 DCHECK_GT(length, 0ul); | 158 DCHECK_GT(length, 0ul); |
| 149 scoped_ptr<DataElement> element(new DataElement()); | 159 scoped_ptr<DataElement> element(new DataElement()); |
| 150 element->SetToBlobRange(uuid, offset, length); | 160 element->SetToBlobRange(uuid, offset, length); |
| 151 items_.push_back(new BlobDataItem(element.Pass())); | 161 items_.push_back(new BlobDataItem(element.Pass())); |
| 152 } | 162 } |
| 153 | 163 |
| 154 void BlobDataBuilder::AppendBlob(const std::string& uuid) { | 164 void BlobDataBuilder::AppendBlob(const std::string& uuid) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 << ", content_type: " << x.content_type_ | 204 << ", content_type: " << x.content_type_ |
| 195 << ", content_disposition: " << x.content_disposition_ << ", items: ["; | 205 << ", content_disposition: " << x.content_disposition_ << ", items: ["; |
| 196 for (const auto& item : x.items_) { | 206 for (const auto& item : x.items_) { |
| 197 PrintTo(*item, os); | 207 PrintTo(*item, os); |
| 198 *os << ", "; | 208 *os << ", "; |
| 199 } | 209 } |
| 200 *os << "]}"; | 210 *os << "]}"; |
| 201 } | 211 } |
| 202 | 212 |
| 203 } // namespace storage | 213 } // namespace storage |
| OLD | NEW |