OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ | |
6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ | |
7 | |
8 #include <stddef.h> | |
Marc Treib
2016/07/28 11:41:45
Was this added automatically by Eclipse or somethi
Philipp Keck
2016/07/28 13:50:54
This indirectly comes from ntp_snippets_service.h,
| |
9 | |
10 #include <map> | |
11 #include <vector> | |
12 | |
13 #include "base/macros.h" | |
14 #include "components/ntp_snippets/content_suggestions_category.h" | |
15 | |
16 namespace ntp_snippets { | |
17 | |
18 // Creates and orders instances of ContentSuggestionsCategory. | |
19 class ContentSuggestionsCategoryFactory { | |
20 public: | |
21 ContentSuggestionsCategoryFactory(); | |
22 ~ContentSuggestionsCategoryFactory(); | |
23 | |
24 ContentSuggestionsCategory FromKnownCategory( | |
25 KnownSuggestionsCategories known_category); | |
26 ContentSuggestionsCategory FromRemoteCategory(int remote_id); | |
tschumann
2016/07/28 12:50:14
i think passing in the index from the server respo
Philipp Keck
2016/07/28 13:50:54
We can add that once we need it. Currently, the se
tschumann
2016/07/28 15:03:45
The problem i'm seeing is: Keeping the order as we
Marc Treib
2016/07/28 15:13:26
Or, alternatively: Document that remote categories
Philipp Keck
2016/07/28 15:15:25
We could document the way it works in this file. I
Philipp Keck
2016/07/28 15:25:58
Agree. I documented it here and on CompareCategori
tschumann
2016/07/28 15:36:10
yes, hence the different type and factory function
tschumann
2016/07/28 15:36:10
just read-up on the implementation (didn't have a
Philipp Keck
2016/07/28 16:59:58
Acknowledged.
Philipp Keck
2016/07/28 16:59:58
Ok, I renamed it.
| |
27 ContentSuggestionsCategory FromIDValue(int id); | |
Marc Treib
2016/07/28 11:41:45
Please add comments for these. E.g. what must |rem
Philipp Keck
2016/07/28 13:50:54
Done.
| |
28 | |
29 bool CompareCategories(const ContentSuggestionsCategory& left, | |
Marc Treib
2016/07/28 11:41:45
Please add a comment on what exactly this does - I
Philipp Keck
2016/07/28 13:50:54
Done.
| |
30 const ContentSuggestionsCategory& right) const; | |
31 | |
32 private: | |
33 void AddKnownCategory(KnownSuggestionsCategories known_category); | |
34 ContentSuggestionsCategory InternalFromID(int id); | |
35 | |
36 std::vector<ContentSuggestionsCategory> categories_; | |
Marc Treib
2016/07/28 11:41:46
Add a comment saying that these are in order?
Philipp Keck
2016/07/28 13:50:54
Done.
| |
37 std::map<int, ContentSuggestionsCategory> categories_by_id_; | |
Marc Treib
2016/07/28 11:41:45
Hm. We could also leave this out and just do std::
Philipp Keck
2016/07/28 13:50:54
That's possible. I was hoping that the map is fast
Marc Treib
2016/07/28 14:31:17
Rule of thumb: For < 100 small elements, vector wi
Philipp Keck
2016/07/28 14:55:47
I changed it and introduced a CategoryExists helpe
| |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsCategoryFactory); | |
40 }; | |
41 | |
42 } // namespace ntp_snippets | |
43 | |
44 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ | |
OLD | NEW |