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

Unified Diff: ios/chrome/browser/reading_list/reading_list_entry.h

Issue 2338133010: Add a TimeUntilNextTry to reading list (Closed)
Patch Set: fixes Created 4 years, 3 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: ios/chrome/browser/reading_list/reading_list_entry.h
diff --git a/ios/chrome/browser/reading_list/reading_list_entry.h b/ios/chrome/browser/reading_list/reading_list_entry.h
index 4201a0a9146a0ab77c8b66b8a70b47abde29847b..9423ddd643e628b514d0c35afeeda21847ee248c 100644
--- a/ios/chrome/browser/reading_list/reading_list_entry.h
+++ b/ios/chrome/browser/reading_list/reading_list_entry.h
@@ -7,6 +7,8 @@
#include <string>
+#include "base/time/tick_clock.h"
+#include "base/time/time.h"
#include "url/gurl.h"
// An entry in the reading list. The URL is a unique identifier for an entry, as
@@ -15,6 +17,11 @@
class ReadingListEntry {
public:
ReadingListEntry(const GURL& url, const std::string& title);
+ // The lifetime of |clock| must enclose lifetime of ReadingListEntry, the
+ // pointer can be null.
+ ReadingListEntry(const GURL& url,
+ const std::string& title,
+ base::TickClock* clock);
ReadingListEntry(const ReadingListEntry& entry);
~ReadingListEntry();
@@ -27,12 +34,15 @@ class ReadingListEntry {
// The URL of the page the user would like to read later.
const GURL& URL() const;
// The title of the entry. Might be empty.
- const std::string Title() const;
+ const std::string& Title() const;
// What state this entry is in.
DistillationState DistilledState() const;
// The local file URL for the distilled version of the page. This should only
// be called if the state is "PROCESSED".
const GURL& DistilledURL() const;
+ // The time before the next try. This is automatically increased when the
+ // state is set to WILL_RETRY or ERROR.
+ base::TimeDelta TimeUntilNextTry() const;
ReadingListEntry& operator=(const ReadingListEntry& other);
bool operator==(const ReadingListEntry& other) const;
@@ -45,10 +55,20 @@ class ReadingListEntry {
void SetDistilledState(DistillationState distilled_state);
private:
+ // Calculates the delta until the next retry based of the
+ // |currentWaitingTime|. This implementation doubles it.
+ static base::TimeDelta NextWaitingTime(base::TimeDelta currentWaitingTime);
+ // Get the current time using the clock or base::TimeTicks::Now() if no clock
+ // is provided.
+ base::TimeTicks GetTimeTicksNow() const;
+
GURL url_;
std::string title_;
GURL distilled_url_;
DistillationState distilled_state_;
+ base::TimeTicks time_to_retry_;
+ base::TimeDelta current_waiting_time_;
+ base::TickClock* clock_;
};
#endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_ENTRY_H_

Powered by Google App Engine
This is Rietveld 408576698