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

Unified Diff: components/suggestions/blacklist_store.h

Issue 766053010: SuggestionsService undo blacklist functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix uninitialized test variable Created 6 years 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
« no previous file with comments | « chrome/browser/android/most_visited_sites.cc ('k') | components/suggestions/blacklist_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/suggestions/blacklist_store.h
diff --git a/components/suggestions/blacklist_store.h b/components/suggestions/blacklist_store.h
index 072e3f69c0e2b3120b847c9c3d733f0113401686..6d1bc732311acbb91d3834878dbfc1837c1ab2b7 100644
--- a/components/suggestions/blacklist_store.h
+++ b/components/suggestions/blacklist_store.h
@@ -5,7 +5,11 @@
#ifndef COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_
#define COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_
+#include <map>
+#include <string>
+
#include "base/macros.h"
+#include "base/time/time.h"
#include "components/suggestions/proto/suggestions.pb.h"
#include "url/gurl.h"
@@ -17,23 +21,39 @@ class PrefRegistrySyncable;
namespace suggestions {
-// A helper class for reading, writing and modifying a small blacklist stored
-// in the Profile preferences. It also handles SuggestionsProfile
-// filtering based on the stored blacklist.
+// A helper class for reading, writing, modifying and applying a small URL
+// blacklist, pending upload to the server. The class has a concept of time
+// duration before which a blacklisted URL becomes candidate for upload to the
+// server. Keep in mind most of the operations involve interaction with the disk
+// (the profile's preferences). Note that the class should be used as a
+// singleton for the upload candidacy to work properly.
class BlacklistStore {
public:
- explicit BlacklistStore(PrefService* profile_prefs);
+ BlacklistStore(
+ PrefService* profile_prefs,
+ const base::TimeDelta& upload_delay = base::TimeDelta::FromSeconds(15));
virtual ~BlacklistStore();
- // Returns true if successful or |url| was already in the blacklist.
+ // Returns true if successful or |url| was already in the blacklist. If |url|
+ // was already in the blacklist, its blacklisting timestamp gets updated.
virtual bool BlacklistUrl(const GURL& url);
- // Sets |url| to the first URL from the blacklist. Returns false if the
+ // Gets the time until any URL is ready for upload. Returns false if the
// blacklist is empty.
- virtual bool GetFirstUrlFromBlacklist(GURL* url);
+ virtual bool GetTimeUntilReadyForUpload(base::TimeDelta* delta);
+
+ // Gets the time until |url| is ready for upload. Returns false if |url| is
+ // not part of the blacklist.
+ virtual bool GetTimeUntilURLReadyForUpload(const GURL& url,
+ base::TimeDelta* delta);
+
+ // Sets |url| to a URL from the blacklist that is candidate for upload.
+ // Returns false if there is no candidate for upload.
+ virtual bool GetCandidateForUpload(GURL* url);
- // Removes |url| from the stored blacklist. Returns true if successful or if
- // |url| is not in the blacklist.
+ // Removes |url| from the stored blacklist. Returns true if successful, false
+ // on failure or if |url| was not in the blacklist. Note that this function
+ // does not enforce a minimum time since blacklist before removal.
virtual bool RemoveUrl(const GURL& url);
// Applies the blacklist to |suggestions|.
@@ -44,7 +64,7 @@ class BlacklistStore {
protected:
// Test seam. For simplicity of mock creation.
- BlacklistStore() {}
+ BlacklistStore();
// Loads the blacklist data from the Profile preferences into
// |blacklist|. If there is a problem with loading, the pref value is
@@ -63,6 +83,15 @@ class BlacklistStore {
// The pref service used to persist the suggestions blacklist.
PrefService* pref_service_;
+ // Delay after which a URL becomes candidate for upload, measured from the
+ // last time the URL was added.
+ base::TimeDelta upload_delay_;
+
+ // The times at which URLs were blacklisted. Used to determine when a URL is
+ // valid for server upload. Guaranteed to contain URLs that are not ready for
+ // upload. Might not contain URLs that are ready for upload.
+ std::map<std::string, base::TimeTicks> blacklist_times_;
+
DISALLOW_COPY_AND_ASSIGN(BlacklistStore);
};
« no previous file with comments | « chrome/browser/android/most_visited_sites.cc ('k') | components/suggestions/blacklist_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698