| Index: components/ntp_snippets/ntp_snippets_service.cc
|
| diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
|
| index 3271af1b496d68392bd0f1e0c7c648247462e920..67b6a2d7b5c585ea5d6df983739e905c2c693095 100644
|
| --- a/components/ntp_snippets/ntp_snippets_service.cc
|
| +++ b/components/ntp_snippets/ntp_snippets_service.cc
|
| @@ -14,6 +14,12 @@
|
|
|
| namespace ntp_snippets {
|
|
|
| +namespace {
|
| +
|
| +// TODO(treib): This is an extremely small value, for ease of development.
|
| +// Replace it by something sensible and add a command line param to control it.
|
| +const int kDefaultFetchingIntervalSeconds = 60;
|
| +
|
| std::string ReadFileToString(const base::FilePath& path) {
|
| std::string data;
|
| bool success = base::ReadFileToString(path, &data);
|
| @@ -21,13 +27,17 @@ std::string ReadFileToString(const base::FilePath& path) {
|
| return data;
|
| }
|
|
|
| +} // namespace
|
| +
|
| NTPSnippetsService::NTPSnippetsService(
|
| scoped_refptr<base::SequencedTaskRunner> file_task_runner,
|
| const std::string& application_language_code,
|
| + NTPSnippetsScheduler* scheduler,
|
| scoped_ptr<NTPSnippetsFetcher> snippets_fetcher)
|
| : loaded_(false),
|
| file_task_runner_(file_task_runner),
|
| application_language_code_(application_language_code),
|
| + scheduler_(scheduler),
|
| snippets_fetcher_(std::move(snippets_fetcher)),
|
| weak_ptr_factory_(this) {
|
| snippets_fetcher_callback_ = snippets_fetcher_->AddCallback(
|
| @@ -37,6 +47,13 @@ NTPSnippetsService::NTPSnippetsService(
|
|
|
| NTPSnippetsService::~NTPSnippetsService() {}
|
|
|
| +void NTPSnippetsService::Init(bool enabled) {
|
| + if (enabled)
|
| + scheduler_->Schedule(kDefaultFetchingIntervalSeconds);
|
| + else
|
| + scheduler_->Unschedule();
|
| +}
|
| +
|
| void NTPSnippetsService::Shutdown() {
|
| FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_,
|
| NTPSnippetsServiceShutdown(this));
|
|
|