OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef STORAGE_COMMON_DATA_ELEMENT_H_ | 5 #ifndef STORAGE_COMMON_DATA_ELEMENT_H_ |
6 #define STORAGE_COMMON_DATA_ELEMENT_H_ | 6 #define STORAGE_COMMON_DATA_ELEMENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 TYPE_BYTES, | 26 TYPE_BYTES, |
27 TYPE_FILE, | 27 TYPE_FILE, |
28 TYPE_BLOB, | 28 TYPE_BLOB, |
29 TYPE_FILE_FILESYSTEM, | 29 TYPE_FILE_FILESYSTEM, |
30 }; | 30 }; |
31 | 31 |
32 DataElement(); | 32 DataElement(); |
33 ~DataElement(); | 33 ~DataElement(); |
34 | 34 |
35 Type type() const { return type_; } | 35 Type type() const { return type_; } |
36 const char* bytes() const { return bytes_ ? bytes_ : &buf_[0]; } | 36 const char* bytes() const { |
| 37 if (length_) |
| 38 return bytes_ ? bytes_ : &buf_[0]; |
| 39 else |
| 40 return nullptr; |
| 41 } |
37 const base::FilePath& path() const { return path_; } | 42 const base::FilePath& path() const { return path_; } |
38 const GURL& filesystem_url() const { return filesystem_url_; } | 43 const GURL& filesystem_url() const { return filesystem_url_; } |
39 const std::string& blob_uuid() const { return blob_uuid_; } | 44 const std::string& blob_uuid() const { return blob_uuid_; } |
40 uint64 offset() const { return offset_; } | 45 uint64 offset() const { return offset_; } |
41 uint64 length() const { return length_; } | 46 uint64 length() const { return length_; } |
42 const base::Time& expected_modification_time() const { | 47 const base::Time& expected_modification_time() const { |
43 return expected_modification_time_; | 48 return expected_modification_time_; |
44 } | 49 } |
45 | 50 |
46 // Sets TYPE_BYTES data. This copies the given data into the element. | 51 // Sets TYPE_BYTES data. This copies the given data into the element. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 143 } |
139 | 144 |
140 inline bool operator!=(const DataElement& a, const DataElement& b) { | 145 inline bool operator!=(const DataElement& a, const DataElement& b) { |
141 return !(a == b); | 146 return !(a == b); |
142 } | 147 } |
143 #endif // defined(UNIT_TEST) | 148 #endif // defined(UNIT_TEST) |
144 | 149 |
145 } // namespace storage | 150 } // namespace storage |
146 | 151 |
147 #endif // STORAGE_COMMON_DATA_ELEMENT_H_ | 152 #endif // STORAGE_COMMON_DATA_ELEMENT_H_ |
OLD | NEW |