| OLD | NEW |
| 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 Loading... |
| 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(); | |
| 243 } | 242 } |
| 244 | 243 |
| 245 void NTPSnippetsService::RemoveObserver(NTPSnippetsServiceObserver* observer) { | 244 void NTPSnippetsService::RemoveObserver(NTPSnippetsServiceObserver* observer) { |
| 246 observers_.RemoveObserver(observer); | 245 observers_.RemoveObserver(observer); |
| 247 } | 246 } |
| 248 | 247 |
| 249 void NTPSnippetsService::OnSuggestionsChanged( | 248 void NTPSnippetsService::OnSuggestionsChanged( |
| 250 const SuggestionsProfile& suggestions) { | 249 const SuggestionsProfile& suggestions) { |
| 251 std::set<std::string> hosts = GetSuggestionsHostsImpl(suggestions); | 250 std::set<std::string> hosts = GetSuggestionsHostsImpl(suggestions); |
| 252 if (hosts == GetSnippetHostsFromPrefs()) | 251 if (hosts == GetSnippetHostsFromPrefs()) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 if (snippet->expiry_date() < next_expiry) | 423 if (snippet->expiry_date() < next_expiry) |
| 425 next_expiry = snippet->expiry_date(); | 424 next_expiry = snippet->expiry_date(); |
| 426 } | 425 } |
| 427 DCHECK_GT(next_expiry, expiry); | 426 DCHECK_GT(next_expiry, expiry); |
| 428 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, | 427 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, |
| 429 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets, | 428 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets, |
| 430 base::Unretained(this))); | 429 base::Unretained(this))); |
| 431 } | 430 } |
| 432 | 431 |
| 433 } // namespace ntp_snippets | 432 } // namespace ntp_snippets |
| OLD | NEW |