Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_SUGGESTIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| 6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 extern const char kSuggestionsFieldTrialName[]; | 39 extern const char kSuggestionsFieldTrialName[]; |
| 40 extern const char kSuggestionsFieldTrialURLParam[]; | 40 extern const char kSuggestionsFieldTrialURLParam[]; |
| 41 extern const char kSuggestionsFieldTrialCommonParamsParam[]; | 41 extern const char kSuggestionsFieldTrialCommonParamsParam[]; |
| 42 extern const char kSuggestionsFieldTrialBlacklistPathParam[]; | 42 extern const char kSuggestionsFieldTrialBlacklistPathParam[]; |
| 43 extern const char kSuggestionsFieldTrialBlacklistUrlParam[]; | 43 extern const char kSuggestionsFieldTrialBlacklistUrlParam[]; |
| 44 extern const char kSuggestionsFieldTrialStateParam[]; | 44 extern const char kSuggestionsFieldTrialStateParam[]; |
| 45 extern const char kSuggestionsFieldTrialControlParam[]; | 45 extern const char kSuggestionsFieldTrialControlParam[]; |
| 46 extern const char kSuggestionsFieldTrialStateEnabled[]; | 46 extern const char kSuggestionsFieldTrialStateEnabled[]; |
| 47 | 47 |
| 48 extern const int64 kDefaultExpiryUsec; | |
| 49 | |
| 48 // An interface to fetch server suggestions asynchronously. | 50 // An interface to fetch server suggestions asynchronously. |
| 49 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { | 51 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
| 50 public: | 52 public: |
| 51 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; | 53 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; |
| 52 | 54 |
| 53 SuggestionsService( | 55 SuggestionsService( |
| 54 net::URLRequestContextGetter* url_request_context, | 56 net::URLRequestContextGetter* url_request_context, |
| 55 scoped_ptr<SuggestionsStore> suggestions_store, | 57 scoped_ptr<SuggestionsStore> suggestions_store, |
| 56 scoped_ptr<ImageManager> thumbnail_manager, | 58 scoped_ptr<ImageManager> thumbnail_manager, |
| 57 scoped_ptr<BlacklistStore> blacklist_store); | 59 scoped_ptr<BlacklistStore> blacklist_store); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 85 void BlacklistURL(const GURL& candidate_url, | 87 void BlacklistURL(const GURL& candidate_url, |
| 86 const ResponseCallback& callback); | 88 const ResponseCallback& callback); |
| 87 | 89 |
| 88 // Determines which URL a blacklist request was for, irrespective of the | 90 // Determines which URL a blacklist request was for, irrespective of the |
| 89 // request's status. Returns false if |request| is not a blacklist request. | 91 // request's status. Returns false if |request| is not a blacklist request. |
| 90 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); | 92 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); |
| 91 | 93 |
| 92 // Register SuggestionsService related prefs in the Profile prefs. | 94 // Register SuggestionsService related prefs in the Profile prefs. |
| 93 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 95 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 94 | 96 |
| 97 // Sets default timestamp for suggestions which do not have expiry timestamp. | |
| 98 void SetDefaultExpiryTimestamps(SuggestionsProfile* suggestions, | |
| 99 int64 timestamp_usec); | |
|
manzagop (departed)
2014/08/04 19:02:59
nit: I'd align this with SuggestionsProfile.
gayane -on leave until 09-2017
2014/08/04 19:26:44
Done.
| |
| 95 private: | 100 private: |
| 96 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLFails); | 101 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLFails); |
| 97 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData); | 102 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData); |
| 98 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay); | 103 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay); |
| 99 | 104 |
| 100 // Issue a request. | 105 // Issue a request. |
| 101 void IssueRequest(const GURL& url); | 106 void IssueRequest(const GURL& url); |
| 102 | 107 |
| 103 // Creates a request to the suggestions service, properly setting headers. | 108 // Creates a request to the suggestions service, properly setting headers. |
| 104 net::URLFetcher* CreateSuggestionsRequest(const GURL& url); | 109 net::URLFetcher* CreateSuggestionsRequest(const GURL& url); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 // Timeout (in ms) before serving requestors after a fetch suggestions request | 185 // Timeout (in ms) before serving requestors after a fetch suggestions request |
| 181 // has been issued. | 186 // has been issued. |
| 182 int request_timeout_ms_; | 187 int request_timeout_ms_; |
| 183 | 188 |
| 184 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 189 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
| 185 }; | 190 }; |
| 186 | 191 |
| 187 } // namespace suggestions | 192 } // namespace suggestions |
| 188 | 193 |
| 189 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 194 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
| OLD | NEW |