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 26 matching lines...) Expand all Loading... |
37 class SuggestionsStore; | 37 class SuggestionsStore; |
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 extern const int64 kDefaultExpiryUsec; |
47 | 48 |
48 // An interface to fetch server suggestions asynchronously. | 49 // An interface to fetch server suggestions asynchronously. |
49 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { | 50 class SuggestionsService : public KeyedService, public net::URLFetcherDelegate { |
50 public: | 51 public: |
51 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; | 52 typedef base::Callback<void(const SuggestionsProfile&)> ResponseCallback; |
52 | 53 |
53 SuggestionsService( | 54 SuggestionsService( |
54 net::URLRequestContextGetter* url_request_context, | 55 net::URLRequestContextGetter* url_request_context, |
55 scoped_ptr<SuggestionsStore> suggestions_store, | 56 scoped_ptr<SuggestionsStore> suggestions_store, |
56 scoped_ptr<ImageManager> thumbnail_manager, | 57 scoped_ptr<ImageManager> thumbnail_manager, |
(...skipping 28 matching lines...) Expand all Loading... |
85 void BlacklistURL(const GURL& candidate_url, | 86 void BlacklistURL(const GURL& candidate_url, |
86 const ResponseCallback& callback); | 87 const ResponseCallback& callback); |
87 | 88 |
88 // Determines which URL a blacklist request was for, irrespective of the | 89 // Determines which URL a blacklist request was for, irrespective of the |
89 // request's status. Returns false if |request| is not a blacklist request. | 90 // request's status. Returns false if |request| is not a blacklist request. |
90 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); | 91 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); |
91 | 92 |
92 // Register SuggestionsService related prefs in the Profile prefs. | 93 // Register SuggestionsService related prefs in the Profile prefs. |
93 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 94 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
94 | 95 |
| 96 // Sets default timestamp for suggestions which do not have expiry timestamp. |
| 97 void SetDefaultExpiryTimestamp(SuggestionsProfile* suggestions, |
| 98 int64 timestamp_usec); |
95 private: | 99 private: |
96 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLFails); | 100 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLFails); |
97 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData); | 101 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData); |
98 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay); | 102 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay); |
99 | 103 |
100 // Issue a request. | 104 // Issue a request. |
101 void IssueRequest(const GURL& url); | 105 void IssueRequest(const GURL& url); |
102 | 106 |
103 // Creates a request to the suggestions service, properly setting headers. | 107 // Creates a request to the suggestions service, properly setting headers. |
104 net::URLFetcher* CreateSuggestionsRequest(const GURL& url); | 108 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 | 184 // Timeout (in ms) before serving requestors after a fetch suggestions request |
181 // has been issued. | 185 // has been issued. |
182 int request_timeout_ms_; | 186 int request_timeout_ms_; |
183 | 187 |
184 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 188 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
185 }; | 189 }; |
186 | 190 |
187 } // namespace suggestions | 191 } // namespace suggestions |
188 | 192 |
189 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 193 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |