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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.h

Issue 1869323003: [NTP Snippets] Scheduler: Fetch on Wifi (without charging) only 6AM-10PM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snippets_merge_controller
Patch Set: remove fudge Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 // Inherited from KeyedService. 73 // Inherited from KeyedService.
74 void Shutdown() override; 74 void Shutdown() override;
75 75
76 // Fetches snippets from the server and adds them to the current ones. 76 // Fetches snippets from the server and adds them to the current ones.
77 void FetchSnippets(); 77 void FetchSnippets();
78 // Fetches snippets from the server for specified hosts (overriding 78 // Fetches snippets from the server for specified hosts (overriding
79 // suggestions from the suggestion service) and adds them to the current ones. 79 // suggestions from the suggestion service) and adds them to the current ones.
80 void FetchSnippetsFromHosts(const std::set<std::string>& hosts); 80 void FetchSnippetsFromHosts(const std::set<std::string>& hosts);
81 81
82 // (Re)schedules the periodic fetching of snippets. This is necessary because
83 // the schedule depends on the time of day
84 void RescheduleFetching();
85
82 // Deletes all currently stored snippets. 86 // Deletes all currently stored snippets.
83 void ClearSnippets(); 87 void ClearSnippets();
84 88
85 // Discards the snippet with the given |url|, if it exists. Returns true iff 89 // Discards the snippet with the given |url|, if it exists. Returns true iff
86 // a snippet was discarded. 90 // a snippet was discarded.
87 bool DiscardSnippet(const GURL& url); 91 bool DiscardSnippet(const GURL& url);
88 92
89 // Returns the lists of snippets previously discarded by the user (that are 93 // Returns the lists of snippets previously discarded by the user (that are
90 // not expired yet). 94 // not expired yet).
91 const NTPSnippetStorage& discarded_snippets() const { 95 const NTPSnippetStorage& discarded_snippets() const {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void LoadDiscardedSnippetsFromPrefs(); 145 void LoadDiscardedSnippetsFromPrefs();
142 void StoreDiscardedSnippetsToPrefs(); 146 void StoreDiscardedSnippetsToPrefs();
143 147
144 std::set<std::string> GetSnippetHostsFromPrefs() const; 148 std::set<std::string> GetSnippetHostsFromPrefs() const;
145 void StoreSnippetHostsToPrefs(const std::set<std::string>& hosts); 149 void StoreSnippetHostsToPrefs(const std::set<std::string>& hosts);
146 150
147 bool HasDiscardedSnippet(const GURL& url) const; 151 bool HasDiscardedSnippet(const GURL& url) const;
148 152
149 void RemoveExpiredSnippets(); 153 void RemoveExpiredSnippets();
150 154
155 bool enabled_;
156
151 PrefService* pref_service_; 157 PrefService* pref_service_;
152 158
153 suggestions::SuggestionsService* suggestions_service_; 159 suggestions::SuggestionsService* suggestions_service_;
154 160
155 // The SequencedTaskRunner on which file system operations will be run. 161 // The SequencedTaskRunner on which file system operations will be run.
156 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; 162 scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
157 163
158 // All current suggestions (i.e. not discarded ones). 164 // All current suggestions (i.e. not discarded ones).
159 NTPSnippetStorage snippets_; 165 NTPSnippetStorage snippets_;
160 166
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Sent when the service is shutting down. 208 // Sent when the service is shutting down.
203 virtual void NTPSnippetsServiceShutdown() = 0; 209 virtual void NTPSnippetsServiceShutdown() = 0;
204 210
205 protected: 211 protected:
206 virtual ~NTPSnippetsServiceObserver() {} 212 virtual ~NTPSnippetsServiceObserver() {}
207 }; 213 };
208 214
209 } // namespace ntp_snippets 215 } // namespace ntp_snippets
210 216
211 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 217 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_scheduler.h ('k') | components/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698