Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: storage/common/data_element.cc

Issue 1288373002: [BlobAsync] Patch 2: Common Constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async1
Patch Set: comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « storage/common/data_element.h ('k') | storage/storage_common.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/common/data_element.cc
diff --git a/storage/common/data_element.cc b/storage/common/data_element.cc
index f26058b7fb42875343474391d615fc11c2d546bf..c9bbf0e4b837aeb5380f7c23af403699b83cf3c3 100644
--- a/storage/common/data_element.cc
+++ b/storage/common/data_element.cc
@@ -4,6 +4,10 @@
#include "storage/common/data_element.h"
+#include <algorithm>
+
+#include "base/strings/string_number_conversions.h"
+
namespace storage {
DataElement::DataElement()
@@ -52,4 +56,41 @@ void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) {
length_ = length;
}
+void PrintTo(const DataElement& x, std::ostream* os) {
+ const uint64 kMaxDataPrintLength = 40;
+ *os << "<DataElement>{type: ";
+ switch (x.type()) {
+ case DataElement::TYPE_BYTES: {
+ uint64 length = std::min(x.length(), kMaxDataPrintLength);
+ *os << "TYPE_BYTES, data: ["
+ << base::HexEncode(x.bytes(), static_cast<size_t>(length));
+ if (length < x.length()) {
+ *os << "<...truncated due to length...>";
+ }
+ *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() << "}";
+}
+
} // namespace storage
« no previous file with comments | « storage/common/data_element.h ('k') | storage/storage_common.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698