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/blob/blob_data.h" | 5 #include "webkit/blob/blob_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 | 11 |
12 namespace webkit_blob { | 12 namespace webkit_blob { |
13 | 13 |
14 BlobData::BlobData() {} | 14 BlobData::BlobData() {} |
15 | 15 |
16 BlobData::~BlobData() {} | 16 BlobData::~BlobData() {} |
17 | 17 |
18 void BlobData::AppendData(const char* data, size_t length) { | 18 void BlobData::AppendData(const char* data, size_t length) { |
19 DCHECK(length > 0); | 19 DCHECK(length > 0); |
20 items_.push_back(Item()); | 20 items_.push_back(Item()); |
21 items_.back().SetToBytes(data, length); | 21 items_.back().SetToBytes(data, length); |
22 } | 22 } |
23 | 23 |
24 void BlobData::AppendFile(const FilePath& file_path, | 24 void BlobData::AppendFile(const base::FilePath& file_path, |
25 uint64 offset, uint64 length, | 25 uint64 offset, uint64 length, |
26 const base::Time& expected_modification_time) { | 26 const base::Time& expected_modification_time) { |
27 DCHECK(length > 0); | 27 DCHECK(length > 0); |
28 items_.push_back(Item()); | 28 items_.push_back(Item()); |
29 items_.back().SetToFilePathRange(file_path, offset, length, | 29 items_.back().SetToFilePathRange(file_path, offset, length, |
30 expected_modification_time); | 30 expected_modification_time); |
31 } | 31 } |
32 | 32 |
33 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { | 33 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { |
34 DCHECK(length > 0); | 34 DCHECK(length > 0); |
(...skipping 15 matching lines...) Expand all Loading... |
50 int64 memory = 0; | 50 int64 memory = 0; |
51 for (std::vector<Item>::const_iterator iter = items_.begin(); | 51 for (std::vector<Item>::const_iterator iter = items_.begin(); |
52 iter != items_.end(); ++iter) { | 52 iter != items_.end(); ++iter) { |
53 if (iter->type() == Item::TYPE_BYTES) | 53 if (iter->type() == Item::TYPE_BYTES) |
54 memory += iter->length(); | 54 memory += iter->length(); |
55 } | 55 } |
56 return memory; | 56 return memory; |
57 } | 57 } |
58 | 58 |
59 } // namespace webkit_blob | 59 } // namespace webkit_blob |
OLD | NEW |