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

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

Issue 1980033002: [NTP Snippets] Clear the snippets when the user signs out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix double we Created 4 years, 7 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 | « components/ntp_snippets/ntp_snippets_service.h ('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 <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 snippets_.erase( 324 snippets_.erase(
325 std::remove_if(snippets_.begin(), snippets_.end(), 325 std::remove_if(snippets_.begin(), snippets_.end(),
326 [&hosts](const std::unique_ptr<NTPSnippet>& snippet) { 326 [&hosts](const std::unique_ptr<NTPSnippet>& snippet) {
327 return !hosts.count(snippet->best_source().url.host()); 327 return !hosts.count(snippet->best_source().url.host());
328 }), 328 }),
329 snippets_.end()); 329 snippets_.end());
330 330
331 StoreSnippetsToPrefs(); 331 StoreSnippetsToPrefs();
332 StoreSnippetHostsToPrefs(hosts); 332 StoreSnippetHostsToPrefs(hosts);
333 333
334 if (hosts.empty()) {
Marc Treib 2016/05/17 14:57:17 Post-commit drive-by comment: After https://codere
335 FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_,
336 NTPSnippetsServiceCleared());
337 }
338
334 FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_, 339 FOR_EACH_OBSERVER(NTPSnippetsServiceObserver, observers_,
335 NTPSnippetsServiceLoaded()); 340 NTPSnippetsServiceLoaded());
336 341
337 FetchSnippetsFromHosts(hosts); 342 FetchSnippetsFromHosts(hosts);
338 } 343 }
339 344
340 void NTPSnippetsService::OnFetchFinished( 345 void NTPSnippetsService::OnFetchFinished(
341 NTPSnippetsFetcher::OptionalSnippets snippets) { 346 NTPSnippetsFetcher::OptionalSnippets snippets) {
342 if (snippets) { 347 if (snippets) {
343 // Sparse histogram used because the number of snippets is small (bound by 348 // Sparse histogram used because the number of snippets is small (bound by
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (snippet->expiry_date() < next_expiry) 498 if (snippet->expiry_date() < next_expiry)
494 next_expiry = snippet->expiry_date(); 499 next_expiry = snippet->expiry_date();
495 } 500 }
496 DCHECK_GT(next_expiry, expiry); 501 DCHECK_GT(next_expiry, expiry);
497 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 502 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
498 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 503 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
499 base::Unretained(this))); 504 base::Unretained(this)));
500 } 505 }
501 506
502 } // namespace ntp_snippets 507 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « 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