OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/common/blob/blob_data.h" | 5 #include "webkit/common/blob/blob_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 void BlobData::AppendFile(const base::FilePath& file_path, | 27 void BlobData::AppendFile(const base::FilePath& file_path, |
28 uint64 offset, uint64 length, | 28 uint64 offset, uint64 length, |
29 const base::Time& expected_modification_time) { | 29 const base::Time& expected_modification_time) { |
30 DCHECK(length > 0); | 30 DCHECK(length > 0); |
31 items_.push_back(Item()); | 31 items_.push_back(Item()); |
32 items_.back().SetToFilePathRange(file_path, offset, length, | 32 items_.back().SetToFilePathRange(file_path, offset, length, |
33 expected_modification_time); | 33 expected_modification_time); |
34 } | 34 } |
35 | 35 |
36 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { | |
37 DCHECK_GT(length, 0ul); | |
38 items_.push_back(Item()); | |
39 items_.back().SetToBlobUrlRange(blob_url, offset, length); | |
40 } | |
41 | |
42 void BlobData::AppendBlob(const std::string& uuid, | 36 void BlobData::AppendBlob(const std::string& uuid, |
43 uint64 offset, uint64 length) { | 37 uint64 offset, uint64 length) { |
44 DCHECK_GT(length, 0ul); | 38 DCHECK_GT(length, 0ul); |
45 items_.push_back(Item()); | 39 items_.push_back(Item()); |
46 items_.back().SetToBlobRange(uuid, offset, length); | 40 items_.back().SetToBlobRange(uuid, offset, length); |
47 } | 41 } |
48 | 42 |
49 void BlobData::AppendFileSystemFile( | 43 void BlobData::AppendFileSystemFile( |
50 const GURL& url, uint64 offset, | 44 const GURL& url, uint64 offset, |
51 uint64 length, | 45 uint64 length, |
52 const base::Time& expected_modification_time) { | 46 const base::Time& expected_modification_time) { |
53 DCHECK(length > 0); | 47 DCHECK(length > 0); |
54 items_.push_back(Item()); | 48 items_.push_back(Item()); |
55 items_.back().SetToFileSystemUrlRange(url, offset, length, | 49 items_.back().SetToFileSystemUrlRange(url, offset, length, |
56 expected_modification_time); | 50 expected_modification_time); |
57 } | 51 } |
58 | 52 |
59 int64 BlobData::GetMemoryUsage() const { | 53 int64 BlobData::GetMemoryUsage() const { |
60 int64 memory = 0; | 54 int64 memory = 0; |
61 for (std::vector<Item>::const_iterator iter = items_.begin(); | 55 for (std::vector<Item>::const_iterator iter = items_.begin(); |
62 iter != items_.end(); ++iter) { | 56 iter != items_.end(); ++iter) { |
63 if (iter->type() == Item::TYPE_BYTES) | 57 if (iter->type() == Item::TYPE_BYTES) |
64 memory += iter->length(); | 58 memory += iter->length(); |
65 } | 59 } |
66 return memory; | 60 return memory; |
67 } | 61 } |
68 | 62 |
69 } // namespace webkit_blob | 63 } // namespace webkit_blob |
OLD | NEW |