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

Unified Diff: components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java

Issue 2768953002: Initial work to move downloads to ContentIds (Closed)
Patch Set: Rebase because of a conflict... with a single. import. :( Created 3 years, 9 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
Index: components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java
diff --git a/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java b/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java
index 045618ba9dc19998a017dc4f6c20f7b0b2f581be..1ceafe874ce51a9ee732c47fadbd490a7a49b9f1 100644
--- a/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java
+++ b/components/offline_items_collection/core/android/java/src/org/chromium/components/offline_items_collection/ContentId.java
@@ -4,6 +4,8 @@
package org.chromium.components.offline_items_collection;
+import android.text.TextUtils;
+
/**
* This class is a Java counterpart to the C++ ContentId
* (components/offline_items_collection/core/offline_item.h) class.
@@ -17,7 +19,27 @@ public class ContentId {
public ContentId() {}
public ContentId(String namespace, String id) {
- this.namespace = namespace;
- this.id = id;
+ assert namespace == null || !namespace.contains(",");
+ this.namespace = namespace != null ? namespace : "";
+ this.id = id != null ? id : "";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ContentId)) return false;
+
+ ContentId rhs = (ContentId) o;
+ return TextUtils.equals(namespace, rhs.namespace) && TextUtils.equals(id, rhs.id);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 61;
+
+ result = 31 * result + (namespace == null ? 0 : namespace.hashCode());
+ result = 31 * result + (id == null ? 0 : id.hashCode());
+
+ return result;
}
}

Powered by Google App Engine
This is Rietveld 408576698