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

Unified Diff: storage/common/data_element.cc

Issue 1292523002: [BlobAsync] Patch 3: Renderer Classes & Logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async2
Patch Set: comments and test 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') | no next file » | 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 c9bbf0e4b837aeb5380f7c23af403699b83cf3c3..fe003ebf89e788b9dbcf5c8312d99a95337b19c4 100644
--- a/storage/common/data_element.cc
+++ b/storage/common/data_element.cc
@@ -93,4 +93,35 @@ void PrintTo(const DataElement& x, std::ostream* os) {
*os << ", length: " << x.length() << ", offset: " << x.offset() << "}";
}
+bool operator==(const DataElement& a, const DataElement& b) {
+ if (a.type() != b.type() || a.offset() != b.offset() ||
+ a.length() != b.length())
+ return false;
+ switch (a.type()) {
+ case DataElement::TYPE_BYTES:
+ return memcmp(a.bytes(), b.bytes(), b.length()) == 0;
+ case DataElement::TYPE_FILE:
+ return a.path() == b.path() &&
+ a.expected_modification_time() == b.expected_modification_time();
+ case DataElement::TYPE_BLOB:
+ return a.blob_uuid() == b.blob_uuid();
+ case DataElement::TYPE_FILE_FILESYSTEM:
+ return a.filesystem_url() == b.filesystem_url();
+ case DataElement::TYPE_DISK_CACHE_ENTRY:
+ // We compare only length and offset; we trust the entry itself was
+ // compared at some higher level such as in BlobDataItem.
+ return true;
+ case DataElement::TYPE_BYTES_DESCRIPTION:
+ return true;
+ case DataElement::TYPE_UNKNOWN:
+ NOTREACHED();
+ return false;
+ }
+ return false;
+}
+
+bool operator!=(const DataElement& a, const DataElement& b) {
+ return !(a == b);
+}
+
} // namespace storage
« no previous file with comments | « storage/common/data_element.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698