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

Side by Side Diff: components/ntp_snippets/content_suggestions_service.h

Issue 2355393002: New snippets now replace old snippets and do not merge (Closed)
Patch Set: Minor polish Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const std::set<GURL>& favicon_urls) override; 205 const std::set<GURL>& favicon_urls) override;
206 void HistoryServiceBeingDeleted( 206 void HistoryServiceBeingDeleted(
207 history::HistoryService* history_service) override; 207 history::HistoryService* history_service) override;
208 208
209 // Registers the given |provider| for the given |category|, unless it is 209 // Registers the given |provider| for the given |category|, unless it is
210 // already registered. Returns true if the category was newly registered or 210 // already registered. Returns true if the category was newly registered or
211 // false if it was present before. 211 // false if it was present before.
212 bool RegisterCategoryIfRequired(ContentSuggestionsProvider* provider, 212 bool RegisterCategoryIfRequired(ContentSuggestionsProvider* provider,
213 Category category); 213 Category category);
214 214
215 // Removes a suggestion from the local stores |id_category_map_| and 215 // Removes a suggestion from the local store |suggestions_by_category_|, if it
216 // |suggestions_by_category_|, if it exists. Returns true if a suggestion was 216 // exists. Returns true if a suggestion was removed.
217 // removed.
218 bool RemoveSuggestionByID(Category category, 217 bool RemoveSuggestionByID(Category category,
219 const std::string& suggestion_id); 218 const std::string& suggestion_id);
220 219
221 // Fires the OnCategoryStatusChanged event for the given |category|. 220 // Fires the OnCategoryStatusChanged event for the given |category|.
222 void NotifyCategoryStatusChanged(Category category); 221 void NotifyCategoryStatusChanged(Category category);
223 222
224 void SortCategories(); 223 void SortCategories();
225 224
226 // Whether the content suggestions feature is enabled. 225 // Whether the content suggestions feature is enabled.
227 State state_; 226 State state_;
(...skipping 16 matching lines...) Expand all
244 // |providers_by_category_|. 243 // |providers_by_category_|.
245 std::vector<Category> categories_; 244 std::vector<Category> categories_;
246 245
247 // All current suggestions grouped by category. This contains an entry for 246 // All current suggestions grouped by category. This contains an entry for
248 // every category in |categories_| whose status is an available status. It may 247 // every category in |categories_| whose status is an available status. It may
249 // contain an empty vector if the category is available but empty (or still 248 // contain an empty vector if the category is available but empty (or still
250 // loading). 249 // loading).
251 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID> 250 std::map<Category, std::vector<ContentSuggestion>, Category::CompareByID>
252 suggestions_by_category_; 251 suggestions_by_category_;
253 252
254 // Map used to determine the category of a suggestion (of which only the ID
255 // is available). This also determines the provider that delivered the
256 // suggestion.
257 std::map<std::string, Category> id_category_map_;
258
259 // Observer for the HistoryService. All providers are notified when history is 253 // Observer for the HistoryService. All providers are notified when history is
260 // deleted. 254 // deleted.
261 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 255 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
262 history_service_observer_; 256 history_service_observer_;
263 257
264 base::ObserverList<Observer> observers_; 258 base::ObserverList<Observer> observers_;
265 259
266 const std::vector<ContentSuggestion> no_suggestions_; 260 const std::vector<ContentSuggestion> no_suggestions_;
267 261
268 // Keep a direct reference to this special provider to redirect scheduling, 262 // Keep a direct reference to this special provider to redirect scheduling,
269 // background fetching and debugging calls to it. If the NTPSnippetsService is 263 // background fetching and debugging calls to it. If the NTPSnippetsService is
270 // loaded, it is also present in |providers_|, otherwise this is a nullptr. 264 // loaded, it is also present in |providers_|, otherwise this is a nullptr.
271 NTPSnippetsService* ntp_snippets_service_; 265 NTPSnippetsService* ntp_snippets_service_;
272 266
273 UserClassifier user_classifier_; 267 UserClassifier user_classifier_;
274 268
275 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService); 269 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsService);
276 }; 270 };
277 271
278 } // namespace ntp_snippets 272 } // namespace ntp_snippets
279 273
280 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_ 274 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698