Chromium Code Reviews| 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 #include <iomanip> | |
| 6 | |
| 5 #include "storage/common/data_element.h" | 7 #include "storage/common/data_element.h" |
| 6 | 8 |
| 7 namespace storage { | 9 namespace storage { |
| 8 | 10 |
| 9 DataElement::DataElement() | 11 DataElement::DataElement() |
| 10 : type_(TYPE_UNKNOWN), | 12 : type_(TYPE_UNKNOWN), |
| 11 bytes_(NULL), | 13 bytes_(NULL), |
| 12 offset_(0), | 14 offset_(0), |
| 13 length_(kuint64max) { | 15 length_(kuint64max) { |
| 14 } | 16 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 45 length_ = length; | 47 length_ = length; |
| 46 expected_modification_time_ = expected_modification_time; | 48 expected_modification_time_ = expected_modification_time; |
| 47 } | 49 } |
| 48 | 50 |
| 49 void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) { | 51 void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) { |
| 50 type_ = TYPE_DISK_CACHE_ENTRY; | 52 type_ = TYPE_DISK_CACHE_ENTRY; |
| 51 offset_ = offset; | 53 offset_ = offset; |
| 52 length_ = length; | 54 length_ = length; |
| 53 } | 55 } |
| 54 | 56 |
| 57 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
| |
| 58 os << "<DataElement>{type: "; | |
| 59 switch (x.type()) { | |
| 60 case DataElement::TYPE_BYTES: { | |
| 61 auto flags = os.flags(); | |
| 62 os << "TYPE_BYTES, data: [" << std::hex; | |
| 63 for (size_t i = 0; i < x.length(); i++) { | |
| 64 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.
| |
| 65 } | |
| 66 os.flags(flags); | |
| 67 os << "]"; | |
| 68 break; | |
| 69 } | |
| 70 case DataElement::TYPE_FILE: | |
| 71 os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe() | |
| 72 << ", expected_modification_time: " << x.expected_modification_time(); | |
| 73 break; | |
| 74 case DataElement::TYPE_BLOB: | |
| 75 os << "TYPE_BLOB, uuid: " << x.blob_uuid(); | |
| 76 break; | |
| 77 case DataElement::TYPE_FILE_FILESYSTEM: | |
| 78 os << "TYPE_FILE_FILESYSTEM, filesystem_url: " << x.filesystem_url(); | |
| 79 break; | |
| 80 case DataElement::TYPE_DISK_CACHE_ENTRY: | |
| 81 os << "TYPE_DISK_CACHE_ENTRY"; | |
| 82 break; | |
| 83 case DataElement::TYPE_BYTES_DESCRIPTION: | |
| 84 os << "TYPE_BYTES_DESCRIPTION"; | |
| 85 break; | |
| 86 case DataElement::TYPE_UNKNOWN: | |
| 87 os << "TYPE_UNKNOWN"; | |
| 88 break; | |
| 89 } | |
| 90 os << ", length: " << x.length() << ", offset: " << x.offset() << "}"; | |
| 91 return os; | |
| 92 } | |
| 93 | |
| 55 } // namespace storage | 94 } // namespace storage |
| OLD | NEW |