Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Unified Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1699143002: [NTP Snippets] Schedule periodic fetching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippets_feature
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..baa2b99426338315ded31f1b8614eff85a08fa30 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -14,6 +14,11 @@
namespace ntp_snippets {
+namespace {
+
+// TODO(treib): Add a command line param to control this.
+const int kDefaultFetchingIntervalSeconds = 30 * 60;
Bernhard Bauer 2016/02/16 16:19:08 TBH, while we are testing this feature, I would re
Marc Treib 2016/02/16 16:54:27 Eh, IMO the value doesn't really matter yet - I wa
+
std::string ReadFileToString(const base::FilePath& path) {
std::string data;
bool success = base::ReadFileToString(path, &data);
@@ -21,13 +26,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 +46,15 @@ NTPSnippetsService::NTPSnippetsService(
NTPSnippetsService::~NTPSnippetsService() {}
+void NTPSnippetsService::Init(bool enabled) {
+ if (scheduler_) {
Bernhard Bauer 2016/02/16 16:19:08 When would the scheduler be null?
Marc Treib 2016/02/16 16:54:27 I was vaguely thinking of iOS, which has an NTPSni
+ if (enabled)
+ scheduler_->Schedule(kDefaultFetchingIntervalSeconds);
+ else
+ scheduler_->Unschedule();
+ }
+}
+
void NTPSnippetsService::Shutdown() {
FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_,
NTPSnippetsServiceShutdown(this));
« chrome/browser/profiles/profile_manager.cc ('K') | « components/ntp_snippets/ntp_snippets_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698