Index: chrome/browser/search/suggestions/suggestions_service.h |
diff --git a/chrome/browser/search/suggestions/suggestions_service.h b/chrome/browser/search/suggestions/suggestions_service.h |
index a23be99635c311d97b7618b670c843d3018a07f7..42b936d6ee3b4be65ffb4a0f5906ec596a692daf 100644 |
--- a/chrome/browser/search/suggestions/suggestions_service.h |
+++ b/chrome/browser/search/suggestions/suggestions_service.h |
@@ -30,6 +30,7 @@ class PrefRegistrySyncable; |
namespace suggestions { |
+class BlacklistStore; |
class SuggestionsStore; |
extern const char kSuggestionsFieldTrialName[]; |
@@ -45,7 +46,8 @@ class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; |
SuggestionsService(Profile* profile, |
- scoped_ptr<SuggestionsStore> suggestions_store); |
+ scoped_ptr<SuggestionsStore> suggestions_store, |
+ scoped_ptr<BlacklistStore> blacklist_store); |
virtual ~SuggestionsService(); |
// Whether this service is enabled. |
@@ -70,7 +72,19 @@ class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
// Issue a blacklist request. If there is already a blacklist request |
// in flight, the new blacklist request is ignored. |
- void BlacklistURL(const GURL& candidate_url, ResponseCallback callback); |
+ void BlacklistURL(const GURL& candidate_url, |
+ const ResponseCallback& callback); |
+ |
+ // If the local blacklist isn't empty, pick a URL from it and issue a |
+ // blacklist request for it. |
+ void UploadBlacklist(); |
Mathieu
2014/06/17 14:51:15
can this be private? Also, name implies the whole
manzagop (departed)
2014/06/17 15:42:24
Done.
|
+ |
+ // Determines whether |request| is a blacklisting request. |
+ static bool IsBlacklistRequest(const net::URLFetcher& request); |
Mathieu
2014/06/17 14:51:15
Let's make this private and encourage people to on
manzagop (departed)
2014/06/17 15:42:24
Yup, already removed.
|
+ |
+ // Determines which url a blacklist request was for, irrespective of the |
Mathieu
2014/06/17 14:51:15
*URL
manzagop (departed)
2014/06/17 15:42:24
Done.
|
+ // request's status. Returns false if |request| is not a blacklist request. |
+ static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); |
// Register SuggestionsService related prefs in the Profile prefs. |
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
@@ -90,18 +104,29 @@ class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
// KeyedService implementation. |
virtual void Shutdown() OVERRIDE; |
- // Determines whether |request| is a blacklisting request. |
- bool IsBlacklistRequest(net::URLFetcher* request) const; |
- |
// Creates a request to the suggestions service, properly setting headers. |
net::URLFetcher* CreateSuggestionsRequest(const GURL& url); |
+ // Issue a request. |
+ void IssueRequest(const GURL& url); |
+ |
// Load the cached suggestions and service the requestors with them. |
void ServeFromCache(); |
+ // Apply the local blacklist to |suggestions|, then serve the requestors. |
+ void FilterAndServe(SuggestionsProfile* suggestions); |
+ |
+ // Schedule a blacklisting request if the local blacklist isn't empty. |
+ // |last_request_successful| is used for exponentially backing off when |
+ // requests fail. |
+ void ScheduleBlacklistUpload(bool last_request_successful); |
+ |
// The cache for the suggestions. |
scoped_ptr<SuggestionsStore> suggestions_store_; |
+ // The local cache for temporary blacklist, until uploaded to the server. |
+ scoped_ptr<BlacklistStore> blacklist_store_; |
+ |
// Contains the current suggestions fetch request. Will only have a value |
// while a request is pending, and will be reset by |OnURLFetchComplete|. |
scoped_ptr<net::URLFetcher> pending_request_; |
@@ -128,6 +153,9 @@ class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
Profile* profile_; |
+ // Delay used when scheduling a blacklisting task. |
+ int blacklist_delay_sec_; |
+ |
// For callbacks may be run after destruction. |
base::WeakPtrFactory<SuggestionsService> weak_ptr_factory_; |