Chromium Code Reviews| Index: storage/common/data_element.cc |
| diff --git a/storage/common/data_element.cc b/storage/common/data_element.cc |
| index f26058b7fb42875343474391d615fc11c2d546bf..8213dd886cb2a14b336de4d4d18be59981a2de37 100644 |
| --- a/storage/common/data_element.cc |
| +++ b/storage/common/data_element.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <iomanip> |
| + |
| #include "storage/common/data_element.h" |
| namespace storage { |
| @@ -52,4 +54,41 @@ void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) { |
| length_ = length; |
| } |
| +std::ostream& operator<<(std::ostream& os, const DataElement& x) { |
|
michaeln
2015/08/18 03:04:41
is this for logging?
dmurph
2015/09/15 01:12:12
Yes. I'm being a good citizen with the basic data
|
| + os << "<DataElement>{type: "; |
| + switch (x.type()) { |
| + case DataElement::TYPE_BYTES: { |
| + auto flags = os.flags(); |
| + os << "TYPE_BYTES, data: [" << std::hex; |
| + for (size_t i = 0; i < x.length(); i++) { |
| + os << std::setfill('0') << std::setw(2) << +(x.bytes()[i]) << ' '; |
|
michaeln
2015/08/18 03:04:41
not sure a hexdump of the contents of a blob is ve
dmurph
2015/09/15 01:12:12
Yes, I think I'll add a cap of 40 bytes.
|
| + } |
| + os.flags(flags); |
| + os << "]"; |
| + break; |
| + } |
| + case DataElement::TYPE_FILE: |
| + os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe() |
| + << ", expected_modification_time: " << x.expected_modification_time(); |
| + break; |
| + case DataElement::TYPE_BLOB: |
| + os << "TYPE_BLOB, uuid: " << x.blob_uuid(); |
| + break; |
| + case DataElement::TYPE_FILE_FILESYSTEM: |
| + os << "TYPE_FILE_FILESYSTEM, filesystem_url: " << x.filesystem_url(); |
| + break; |
| + case DataElement::TYPE_DISK_CACHE_ENTRY: |
| + os << "TYPE_DISK_CACHE_ENTRY"; |
| + break; |
| + case DataElement::TYPE_BYTES_DESCRIPTION: |
| + os << "TYPE_BYTES_DESCRIPTION"; |
| + break; |
| + case DataElement::TYPE_UNKNOWN: |
| + os << "TYPE_UNKNOWN"; |
| + break; |
| + } |
| + os << ", length: " << x.length() << ", offset: " << x.offset() << "}"; |
| + return os; |
| +} |
| + |
| } // namespace storage |