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

Unified Diff: components/reading_list/ios/reading_list_entry.h

Issue 2525663002: Refactor Reading List Model to use URL as key. (Closed)
Patch Set: feedback Created 4 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 side-by-side diff with in-line comments
Download patch
Index: components/reading_list/ios/reading_list_entry.h
diff --git a/components/reading_list/ios/reading_list_entry.h b/components/reading_list/ios/reading_list_entry.h
index 0f87c1487a17582570dda9aed55d4fdec676cc05..21c2fea9886f97c5fffcff9af22f2d4786e35e74 100644
--- a/components/reading_list/ios/reading_list_entry.h
+++ b/components/reading_list/ios/reading_list_entry.h
@@ -6,6 +6,7 @@
#define COMPONENTS_READING_LIST_IOS_READING_LIST_ENTRY_H_
#include <string>
+#include <unordered_map>
#include "base/files/file_path.h"
#include "base/macros.h"
@@ -21,8 +22,17 @@ namespace sync_pb {
class ReadingListSpecifics;
}
+// The hashing structure to create unorder_map<GURL, ReadingListEntry>.
+struct GURLHasher {
+ std::size_t operator()(const GURL& k) const {
+ return std::hash<std::string>()(k.spec());
+ }
+};
+
class ReadingListEntry;
-using ReadingListEntries = std::vector<ReadingListEntry>;
+
+using ReadingListEntries =
+ std::unordered_map<GURL, ReadingListEntry, GURLHasher>;
noyau (Ping after 24h) 2016/11/28 15:29:31 Why is this here actually? It is not used in this
Olivier 2016/11/28 15:38:10 If I move it, I must move it in ReadingListModel,
Olivier 2016/11/30 09:15:22 Moved it (replaced by std::map as performances sho
// An entry in the reading list. The URL is a unique identifier for an entry, as
// such it should not be empty and is the only thing considered when comparing
@@ -60,6 +70,8 @@ class ReadingListEntry {
// automatically increased when the state is set to WILL_RETRY or ERROR from a
// non-error state.
int FailedDownloadCounter() const;
+ // The read status of the entry.
+ bool IsRead() const;
// The last update time of the entry. This value may be used to sort the
// entries. The value is in microseconds since Jan 1st 1970.
@@ -74,12 +86,10 @@ class ReadingListEntry {
// Returns a protobuf encoding the content of this ReadingListEntry for local
// storage.
- std::unique_ptr<reading_list::ReadingListLocal> AsReadingListLocal(
- bool read) const;
+ std::unique_ptr<reading_list::ReadingListLocal> AsReadingListLocal() const;
// Returns a protobuf encoding the content of this ReadingListEntry for sync.
- std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics(
- bool read) const;
+ std::unique_ptr<sync_pb::ReadingListSpecifics> AsReadingListSpecifics() const;
// Created a ReadingListEntry from the protobuf format.
static std::unique_ptr<ReadingListEntry> FromReadingListLocal(
@@ -110,10 +120,13 @@ class ReadingListEntry {
void SetDistilledPath(const base::FilePath& path);
// Sets the state to one of PROCESSING, WILL_RETRY or ERROR.
void SetDistilledState(DistillationState distilled_state);
+ // Sets the read stat of the entry. Will set the UpdateTime of the entry.
+ void SetRead(bool read);
private:
ReadingListEntry(const GURL& url,
const std::string& title,
+ bool read,
int64_t creation_time,
int64_t update_time,
ReadingListEntry::DistillationState distilled_state,
@@ -122,6 +135,7 @@ class ReadingListEntry {
std::unique_ptr<net::BackoffEntry> backoff);
GURL url_;
std::string title_;
+ bool read_;
base::FilePath distilled_path_;
DistillationState distilled_state_;
« no previous file with comments | « no previous file | components/reading_list/ios/reading_list_entry.cc » ('j') | components/reading_list/ios/reading_list_model.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698