Index: components/ntp_snippets/ntp_snippets_service.h |
diff --git a/components/ntp_snippets/ntp_snippets_service.h b/components/ntp_snippets/ntp_snippets_service.h |
index 76cb3d3be853bca2f9e274d841878437ec683a3e..0f0adba2de0f8071f2d1ba216b2fc31a8f201f8b 100644 |
--- a/components/ntp_snippets/ntp_snippets_service.h |
+++ b/components/ntp_snippets/ntp_snippets_service.h |
@@ -12,16 +12,18 @@ |
#include "base/macros.h" |
#include "base/observer_list.h" |
+#include "base/sequenced_task_runner.h" |
#include "components/keyed_service/core/keyed_service.h" |
#include "components/ntp_snippets/inner_iterator.h" |
#include "components/ntp_snippets/ntp_snippet.h" |
+#include "components/ntp_snippets/ntp_snippets_fetcher.h" |
namespace ntp_snippets { |
class NTPSnippetsServiceObserver; |
// Stores and vend fresh content data for the NTP. |
-class NTPSnippetsService : public KeyedService { |
+class NTPSnippetsService : public KeyedService, NTPSnippetsFetcher::Observer { |
public: |
using NTPSnippetStorage = std::vector<std::unique_ptr<NTPSnippet>>; |
Bernhard Bauer
2016/02/08 18:19:27
This should use scoped_ptr, not std::unique_ptr.
May
2016/02/09 17:38:54
Why should it be a scoped_ptr? We construct the NT
Marc Treib
2016/02/10 10:44:43
scoped_ptr and unique_ptr are essentially the same
Bernhard Bauer
2016/02/10 10:48:44
Yup, but it's just that we usually use scoped_ptr
May
2016/02/10 18:16:46
Done.
|
using const_iterator = |
@@ -31,9 +33,16 @@ class NTPSnippetsService : public KeyedService { |
// 'en' or 'en-US'. Note that this code should only specify the language, not |
// the locale, so 'en_US' (english language with US locale) and 'en-GB_US' |
// (British english person in the US) are not language code. |
- explicit NTPSnippetsService(const std::string& application_language_code); |
+ explicit NTPSnippetsService( |
Bernhard Bauer
2016/02/08 18:19:27
`explicit` is only necessary for single-argument c
May
2016/02/09 17:38:54
Done.
|
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner, |
+ const std::string& application_language_code, |
+ NTPSnippetsFetcher* snippets_fetcher); |
~NTPSnippetsService() override; |
+ // Fetches snippets from the server. |overwrite| is true if existing snippets |
+ // should be overwritten. |
+ void FetchSnippets(bool overwrite); |
+ |
// Inherited from KeyedService. |
void Shutdown() override; |
@@ -71,16 +80,30 @@ class NTPSnippetsService : public KeyedService { |
return const_iterator(snippets_.end()); |
} |
+ // NTPSnippetsFetcher::Observer overrides: |
+ void OnNTPSnippetsDownloaded(); |
Bernhard Bauer
2016/02/08 18:19:27
If this really overrides a method, it should have
May
2016/02/09 17:38:54
No idea why it didn't complain. But anyway I remov
|
+ |
private: |
+ void OnFileReadDone(std::string& json); |
Marc Treib
2016/02/09 09:17:54
const std::string&
May
2016/02/09 17:38:54
Done.
|
+ |
// True if the suggestions are loaded. |
bool loaded_; |
+ |
+ // The SequencedTaskRunner on which file system operations will be run. |
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
+ |
// All the suggestions. |
NTPSnippetStorage snippets_; |
+ |
// The ISO 639-1 code of the language used by the application. |
const std::string application_language_code_; |
+ |
// The observers. |
base::ObserverList<NTPSnippetsServiceObserver> observers_; |
+ // The snippets fetcher |
+ scoped_ptr<NTPSnippetsFetcher> snippets_fetcher_; |
+ |
DISALLOW_COPY_AND_ASSIGN(NTPSnippetsService); |
}; |