Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6a9030a79d46e640fc730d371ea16c468a6f3495 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryItem.java |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.history; |
| + |
| +import android.text.TextUtils; |
| + |
| +import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem; |
| + |
| +/** Contains information about a single browsing history item. */ |
| +public class HistoryItem extends TimedItem { |
| + private String mUrl; |
|
gone
2016/12/02 19:34:37
Can any of these things be final?
Theresa
2016/12/02 20:49:32
Done.
|
| + private String mDomain; |
| + private String mTitle; |
| + private long mTimestamp; |
| + private Long mStableId; |
| + |
| + /** |
| + * @param url The url for this item. |
| + * @param domain The string to display for the item's domain. |
| + * @param title The string to display for the item's title. |
| + * @param timestamp The timestamp for this item. |
| + */ |
| + public HistoryItem(String url, String domain, String title, long timestamp) { |
| + mUrl = url; |
| + mDomain = domain; |
| + mTitle = TextUtils.isEmpty(title) ? url : title; |
| + mTimestamp = timestamp; |
| + } |
| + |
| + /** @return The string to display for the item's domain. */ |
| + public String getDomain() { |
| + return mDomain; |
| + } |
| + |
| + /** @return The string to display for the item's title. */ |
| + public String getTitle() { |
| + return mTitle; |
| + } |
| + |
| + @Override |
| + public long getTimestamp() { |
| + return mTimestamp; |
| + } |
| + |
| + @Override |
| + public long getStableId() { |
| + if (mStableId == null) { |
| + // Generate a stable ID that combines the timestamp and the URL. |
| + mStableId = (long) mUrl.hashCode(); |
| + mStableId = (mStableId << 32) + (getTimestamp() & 0x0FFFFFFFF); |
| + } |
| + return mStableId; |
| + } |
| +} |