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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « storage/common/data_element.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "storage/common/data_element.h" 5 #include "storage/common/data_element.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case DataElement::TYPE_BYTES_DESCRIPTION: 86 case DataElement::TYPE_BYTES_DESCRIPTION:
87 *os << "TYPE_BYTES_DESCRIPTION"; 87 *os << "TYPE_BYTES_DESCRIPTION";
88 break; 88 break;
89 case DataElement::TYPE_UNKNOWN: 89 case DataElement::TYPE_UNKNOWN:
90 *os << "TYPE_UNKNOWN"; 90 *os << "TYPE_UNKNOWN";
91 break; 91 break;
92 } 92 }
93 *os << ", length: " << x.length() << ", offset: " << x.offset() << "}"; 93 *os << ", length: " << x.length() << ", offset: " << x.offset() << "}";
94 } 94 }
95 95
96 bool operator==(const DataElement& a, const DataElement& b) {
97 if (a.type() != b.type() || a.offset() != b.offset() ||
98 a.length() != b.length())
99 return false;
100 switch (a.type()) {
101 case DataElement::TYPE_BYTES:
102 return memcmp(a.bytes(), b.bytes(), b.length()) == 0;
103 case DataElement::TYPE_FILE:
104 return a.path() == b.path() &&
105 a.expected_modification_time() == b.expected_modification_time();
106 case DataElement::TYPE_BLOB:
107 return a.blob_uuid() == b.blob_uuid();
108 case DataElement::TYPE_FILE_FILESYSTEM:
109 return a.filesystem_url() == b.filesystem_url();
110 case DataElement::TYPE_DISK_CACHE_ENTRY:
111 // We compare only length and offset; we trust the entry itself was
112 // compared at some higher level such as in BlobDataItem.
113 return true;
114 case DataElement::TYPE_BYTES_DESCRIPTION:
115 return true;
116 case DataElement::TYPE_UNKNOWN:
117 NOTREACHED();
118 return false;
119 }
120 return false;
121 }
122
123 bool operator!=(const DataElement& a, const DataElement& b) {
124 return !(a == b);
125 }
126
96 } // namespace storage 127 } // namespace storage
OLDNEW
« 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