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

Side by Side Diff: components/suggestions/blacklist_store.h

Issue 1259123002: SuggestionsService support for Desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/suggestions/suggestions_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_ 5 #ifndef COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_
6 #define COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_ 6 #define COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 20 matching lines...) Expand all
31 public: 31 public:
32 BlacklistStore( 32 BlacklistStore(
33 PrefService* profile_prefs, 33 PrefService* profile_prefs,
34 const base::TimeDelta& upload_delay = base::TimeDelta::FromSeconds(15)); 34 const base::TimeDelta& upload_delay = base::TimeDelta::FromSeconds(15));
35 virtual ~BlacklistStore(); 35 virtual ~BlacklistStore();
36 36
37 // Returns true if successful or |url| was already in the blacklist. If |url| 37 // Returns true if successful or |url| was already in the blacklist. If |url|
38 // was already in the blacklist, its blacklisting timestamp gets updated. 38 // was already in the blacklist, its blacklisting timestamp gets updated.
39 virtual bool BlacklistUrl(const GURL& url); 39 virtual bool BlacklistUrl(const GURL& url);
40 40
41 // Clears any blacklist data from the profile's preferences.
42 virtual void ClearBlacklist();
43
41 // Gets the time until any URL is ready for upload. Returns false if the 44 // Gets the time until any URL is ready for upload. Returns false if the
42 // blacklist is empty. 45 // blacklist is empty.
43 virtual bool GetTimeUntilReadyForUpload(base::TimeDelta* delta); 46 virtual bool GetTimeUntilReadyForUpload(base::TimeDelta* delta);
44 47
45 // Gets the time until |url| is ready for upload. Returns false if |url| is 48 // Gets the time until |url| is ready for upload. Returns false if |url| is
46 // not part of the blacklist. 49 // not part of the blacklist.
47 virtual bool GetTimeUntilURLReadyForUpload(const GURL& url, 50 virtual bool GetTimeUntilURLReadyForUpload(const GURL& url,
48 base::TimeDelta* delta); 51 base::TimeDelta* delta);
49 52
50 // Sets |url| to a URL from the blacklist that is candidate for upload. 53 // Sets |url| to a URL from the blacklist that is candidate for upload.
(...skipping 18 matching lines...) Expand all
69 // Loads the blacklist data from the Profile preferences into 72 // Loads the blacklist data from the Profile preferences into
70 // |blacklist|. If there is a problem with loading, the pref value is 73 // |blacklist|. If there is a problem with loading, the pref value is
71 // cleared, false is returned and |blacklist| is cleared. If successful, 74 // cleared, false is returned and |blacklist| is cleared. If successful,
72 // |blacklist| will contain the loaded data and true is returned. 75 // |blacklist| will contain the loaded data and true is returned.
73 bool LoadBlacklist(SuggestionsBlacklist* blacklist); 76 bool LoadBlacklist(SuggestionsBlacklist* blacklist);
74 77
75 // Stores the provided |blacklist| to the Profile preferences, using 78 // Stores the provided |blacklist| to the Profile preferences, using
76 // a base64 encoding of its protobuf serialization. 79 // a base64 encoding of its protobuf serialization.
77 bool StoreBlacklist(const SuggestionsBlacklist& blacklist); 80 bool StoreBlacklist(const SuggestionsBlacklist& blacklist);
78 81
79 // Clears any blacklist data from the profile's preferences.
80 void ClearBlacklist();
81
82 private: 82 private:
83 // The pref service used to persist the suggestions blacklist. 83 // The pref service used to persist the suggestions blacklist.
84 PrefService* pref_service_; 84 PrefService* pref_service_;
85 85
86 // Delay after which a URL becomes candidate for upload, measured from the 86 // Delay after which a URL becomes candidate for upload, measured from the
87 // last time the URL was added. 87 // last time the URL was added.
88 base::TimeDelta upload_delay_; 88 base::TimeDelta upload_delay_;
89 89
90 // The times at which URLs were blacklisted. Used to determine when a URL is 90 // The times at which URLs were blacklisted. Used to determine when a URL is
91 // valid for server upload. Guaranteed to contain URLs that are not ready for 91 // valid for server upload. Guaranteed to contain URLs that are not ready for
92 // upload. Might not contain URLs that are ready for upload. 92 // upload. Might not contain URLs that are ready for upload.
93 std::map<std::string, base::TimeTicks> blacklist_times_; 93 std::map<std::string, base::TimeTicks> blacklist_times_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(BlacklistStore); 95 DISALLOW_COPY_AND_ASSIGN(BlacklistStore);
96 }; 96 };
97 97
98 } // namespace suggestions 98 } // namespace suggestions
99 99
100 #endif // COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_ 100 #endif // COMPONENTS_SUGGESTIONS_BLACKLIST_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | components/suggestions/suggestions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698