| 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(); |
| 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 Loading... |
| 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 |
| OLD | NEW |