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

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

Issue 1897313002: Revert of [NTP Snippets] Refresh the displayed snippets less frequently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/ntp_snippets/ntp_snippets_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 void NTPSnippetsService::ClearDiscardedSnippets() { 234 void NTPSnippetsService::ClearDiscardedSnippets() {
235 discarded_snippets_.clear(); 235 discarded_snippets_.clear();
236 StoreDiscardedSnippetsToPrefs(); 236 StoreDiscardedSnippetsToPrefs();
237 FetchSnippets(); 237 FetchSnippets();
238 } 238 }
239 239
240 void NTPSnippetsService::AddObserver(NTPSnippetsServiceObserver* observer) { 240 void NTPSnippetsService::AddObserver(NTPSnippetsServiceObserver* observer) {
241 observers_.AddObserver(observer); 241 observers_.AddObserver(observer);
242 observer->NTPSnippetsServiceLoaded();
242 } 243 }
243 244
244 void NTPSnippetsService::RemoveObserver(NTPSnippetsServiceObserver* observer) { 245 void NTPSnippetsService::RemoveObserver(NTPSnippetsServiceObserver* observer) {
245 observers_.RemoveObserver(observer); 246 observers_.RemoveObserver(observer);
246 } 247 }
247 248
248 void NTPSnippetsService::OnSuggestionsChanged( 249 void NTPSnippetsService::OnSuggestionsChanged(
249 const SuggestionsProfile& suggestions) { 250 const SuggestionsProfile& suggestions) {
250 std::set<std::string> hosts = GetSuggestionsHostsImpl(suggestions); 251 std::set<std::string> hosts = GetSuggestionsHostsImpl(suggestions);
251 if (hosts == GetSnippetHostsFromPrefs()) 252 if (hosts == GetSnippetHostsFromPrefs())
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (snippet->expiry_date() < next_expiry) 424 if (snippet->expiry_date() < next_expiry)
424 next_expiry = snippet->expiry_date(); 425 next_expiry = snippet->expiry_date();
425 } 426 }
426 DCHECK_GT(next_expiry, expiry); 427 DCHECK_GT(next_expiry, expiry);
427 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 428 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
428 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets, 429 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets,
429 base::Unretained(this))); 430 base::Unretained(this)));
430 } 431 }
431 432
432 } // namespace ntp_snippets 433 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698