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

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

Issue 913303002: Fixed IndexedDB blob retention (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « storage/browser/blob/blob_data_builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time/time.h" 7 #include "base/time/time.h"
8 #include "storage/browser/blob/shareable_file_reference.h"
8 9
9 namespace storage { 10 namespace storage {
10 11
11 BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) { 12 BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) {
12 } 13 }
13 BlobDataBuilder::~BlobDataBuilder() { 14 BlobDataBuilder::~BlobDataBuilder() {
14 } 15 }
15 16
16 void BlobDataBuilder::AppendData(const char* data, size_t length) { 17 void BlobDataBuilder::AppendData(const char* data, size_t length) {
17 DCHECK(length > 0); 18 DCHECK(length > 0);
18 scoped_ptr<DataElement> element(new DataElement()); 19 scoped_ptr<DataElement> element(new DataElement());
19 element->SetToBytes(data, length); 20 element->SetToBytes(data, length);
20 items_.push_back(new BlobDataItem(element.Pass())); 21 items_.push_back(new BlobDataItem(element.Pass()));
21 } 22 }
22 23
23 void BlobDataBuilder::AppendFile(const base::FilePath& file_path, 24 void BlobDataBuilder::AppendFile(const base::FilePath& file_path,
24 uint64_t offset, 25 uint64_t offset,
25 uint64_t length, 26 uint64_t length,
26 const base::Time& expected_modification_time) { 27 const base::Time& expected_modification_time) {
27 DCHECK(length > 0); 28 DCHECK(length > 0);
28 scoped_ptr<DataElement> element(new DataElement()); 29 scoped_ptr<DataElement> element(new DataElement());
29 element->SetToFilePathRange(file_path, offset, length, 30 element->SetToFilePathRange(file_path, offset, length,
30 expected_modification_time); 31 expected_modification_time);
31 items_.push_back(new BlobDataItem(element.Pass())); 32 items_.push_back(
32 } 33 new BlobDataItem(element.Pass(), ShareableFileReference::Get(file_path)));
33
34 void BlobDataBuilder::AppendFile(
35 const base::FilePath& file_path,
36 uint64_t offset,
37 uint64_t length,
38 const base::Time& expected_modification_time,
39 scoped_refptr<ShareableFileReference> shareable_file) {
40 DCHECK(length > 0);
41 scoped_ptr<DataElement> element(new DataElement());
42 element->SetToFilePathRange(file_path, offset, length,
43 expected_modification_time);
44 items_.push_back(new BlobDataItem(element.Pass(), shareable_file));
45 } 34 }
46 35
47 void BlobDataBuilder::AppendBlob(const std::string& uuid, 36 void BlobDataBuilder::AppendBlob(const std::string& uuid,
48 uint64_t offset, 37 uint64_t offset,
49 uint64_t length) { 38 uint64_t length) {
50 DCHECK_GT(length, 0ul); 39 DCHECK_GT(length, 0ul);
51 scoped_ptr<DataElement> element(new DataElement()); 40 scoped_ptr<DataElement> element(new DataElement());
52 element->SetToBlobRange(uuid, offset, length); 41 element->SetToBlobRange(uuid, offset, length);
53 items_.push_back(new BlobDataItem(element.Pass())); 42 items_.push_back(new BlobDataItem(element.Pass()));
54 } 43 }
(...skipping 10 matching lines...) Expand all
65 uint64_t length, 54 uint64_t length,
66 const base::Time& expected_modification_time) { 55 const base::Time& expected_modification_time) {
67 DCHECK(length > 0); 56 DCHECK(length > 0);
68 scoped_ptr<DataElement> element(new DataElement()); 57 scoped_ptr<DataElement> element(new DataElement());
69 element->SetToFileSystemUrlRange(url, offset, length, 58 element->SetToFileSystemUrlRange(url, offset, length,
70 expected_modification_time); 59 expected_modification_time);
71 items_.push_back(new BlobDataItem(element.Pass())); 60 items_.push_back(new BlobDataItem(element.Pass()));
72 } 61 }
73 62
74 } // namespace storage 63 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/blob/blob_data_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698