Chromium Code Reviews| 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..cbd6a42c7df05ad19fb07020474f4efd4cc6173a 100644 |
| --- a/components/ntp_snippets/ntp_snippets_service.h |
| +++ b/components/ntp_snippets/ntp_snippets_service.h |
| @@ -11,17 +11,20 @@ |
| #include <vector> |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.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>>; |
| using const_iterator = |
| @@ -31,9 +34,15 @@ 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); |
| + NTPSnippetsService(scoped_refptr<base::SequencedTaskRunner> file_task_runner, |
| + const std::string& application_language_code, |
| + NTPSnippetsFetcher* snippets_fetcher); |
|
Marc Treib
2016/02/10 10:44:43
scoped_ptr<NTPSnippetsFetcher>
to make clear that
May
2016/02/10 18:16:47
Done.
|
| ~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; |
| @@ -72,15 +81,33 @@ class NTPSnippetsService : public KeyedService { |
| } |
| private: |
| + void OnFileReadDone(const std::string& json); |
| + void OnSnippetsDownloaded(const base::FilePath download_path); |
|
Marc Treib
2016/02/10 10:44:43
&
May
2016/02/10 18:16:47
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_; |
| + |
| + // The callback from the snippets fetcher |
| + scoped_ptr<NTPSnippetsFetcher::NTPSnippetsFetcherCallbackList::Subscription> |
| + snippets_fetcher_callback_; |
| + |
| + base::WeakPtrFactory<NTPSnippetsService> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(NTPSnippetsService); |
| }; |