Index: components/ntp_snippets/content_suggestions_category_factory.h |
diff --git a/components/ntp_snippets/content_suggestions_category_factory.h b/components/ntp_snippets/content_suggestions_category_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b55d9a175e3c4791ed5a788368c72e89397cf4b2 |
--- /dev/null |
+++ b/components/ntp_snippets/content_suggestions_category_factory.h |
@@ -0,0 +1,44 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ |
+#define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ |
+ |
+#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,
|
+ |
+#include <map> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "components/ntp_snippets/content_suggestions_category.h" |
+ |
+namespace ntp_snippets { |
+ |
+// Creates and orders instances of ContentSuggestionsCategory. |
+class ContentSuggestionsCategoryFactory { |
+ public: |
+ ContentSuggestionsCategoryFactory(); |
+ ~ContentSuggestionsCategoryFactory(); |
+ |
+ ContentSuggestionsCategory FromKnownCategory( |
+ KnownSuggestionsCategories known_category); |
+ 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.
|
+ 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.
|
+ |
+ 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.
|
+ const ContentSuggestionsCategory& right) const; |
+ |
+ private: |
+ void AddKnownCategory(KnownSuggestionsCategories known_category); |
+ ContentSuggestionsCategory InternalFromID(int id); |
+ |
+ 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.
|
+ 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
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ContentSuggestionsCategoryFactory); |
+}; |
+ |
+} // namespace ntp_snippets |
+ |
+#endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_FACTORY_H_ |