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 WEBKIT_COMMON_DATA_ELEMENT_H_ | 5 #ifndef WEBKIT_COMMON_DATA_ELEMENT_H_ |
6 #define WEBKIT_COMMON_DATA_ELEMENT_H_ | 6 #define WEBKIT_COMMON_DATA_ELEMENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Note: Identifying blobs by url is being deprecated, but while | 41 // Note: Identifying blobs by url is being deprecated, but while |
42 // transitioning, there's a little of both going on in the project. | 42 // transitioning, there's a little of both going on in the project. |
43 const std::string& blob_uuid() const { return blob_uuid_; } | 43 const std::string& blob_uuid() const { return blob_uuid_; } |
44 const GURL& blob_url() const { return blob_url_; } | 44 const GURL& blob_url() const { return blob_url_; } |
45 uint64 offset() const { return offset_; } | 45 uint64 offset() const { return offset_; } |
46 uint64 length() const { return length_; } | 46 uint64 length() const { return length_; } |
47 const base::Time& expected_modification_time() const { | 47 const base::Time& expected_modification_time() const { |
48 return expected_modification_time_; | 48 return expected_modification_time_; |
49 } | 49 } |
50 | 50 |
51 // TODO(michaeln): fixup callers to use filesytem_url() and blob_uuid(). | |
52 const GURL& url() const { | |
53 if (type_ == TYPE_FILE_FILESYSTEM) | |
54 return filesystem_url_; | |
55 return blob_url_; | |
56 } | |
57 | |
58 // 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. |
59 void SetToBytes(const char* bytes, int bytes_len) { | 52 void SetToBytes(const char* bytes, int bytes_len) { |
60 type_ = TYPE_BYTES; | 53 type_ = TYPE_BYTES; |
61 buf_.assign(bytes, bytes + bytes_len); | 54 buf_.assign(bytes, bytes + bytes_len); |
62 length_ = buf_.size(); | 55 length_ = buf_.size(); |
63 } | 56 } |
64 | 57 |
65 // Sets TYPE_BYTES data. This does NOT copy the given data and the caller | 58 // Sets TYPE_BYTES data. This does NOT copy the given data and the caller |
66 // should make sure the data is alive when this element is accessed. | 59 // should make sure the data is alive when this element is accessed. |
67 void SetToSharedBytes(const char* bytes, int bytes_len) { | 60 void SetToSharedBytes(const char* bytes, int bytes_len) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 130 } |
138 | 131 |
139 inline bool operator!=(const DataElement& a, const DataElement& b) { | 132 inline bool operator!=(const DataElement& a, const DataElement& b) { |
140 return !(a == b); | 133 return !(a == b); |
141 } | 134 } |
142 #endif // defined(UNIT_TEST) | 135 #endif // defined(UNIT_TEST) |
143 | 136 |
144 } // namespace webkit_common | 137 } // namespace webkit_common |
145 | 138 |
146 #endif // WEBKIT_COMMON_DATA_ELEMENT_H_ | 139 #endif // WEBKIT_COMMON_DATA_ELEMENT_H_ |
OLD | NEW |