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 <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 258 |
259 void NTPSnippetsService::FetchSnippetsFromHosts( | 259 void NTPSnippetsService::FetchSnippetsFromHosts( |
260 const std::set<std::string>& hosts, | 260 const std::set<std::string>& hosts, |
261 bool interactive_request) { | 261 bool interactive_request) { |
262 if (!ready()) | 262 if (!ready()) |
263 return; | 263 return; |
264 | 264 |
265 if (snippets_.empty()) | 265 if (snippets_.empty()) |
266 UpdateCategoryStatus(CategoryStatus::AVAILABLE_LOADING); | 266 UpdateCategoryStatus(CategoryStatus::AVAILABLE_LOADING); |
267 | 267 |
268 snippets_fetcher_->FetchSnippetsFromHosts( | 268 std::set<std::string> excluded_ids; |
269 hosts, application_language_code_, kMaxSnippetCount, interactive_request); | 269 for (const auto& snippet : dismissed_snippets_) { |
270 excluded_ids.insert(snippet->id()); | |
tschumann
2016/08/24 16:56:19
i'm wondering if we should limit those, to say no
sfiera
2016/08/24 17:08:28
We have timestamps of creation and expiration, but
tschumann
2016/08/24 18:24:07
Good point! This of course assumes that we don't s
Marc Treib
2016/08/25 09:01:41
+1 for some hard limit, just to be safe. I'd put t
sfiera
2016/08/25 10:39:56
Done (there, 100).
| |
271 } | |
272 snippets_fetcher_->FetchSnippetsFromHosts(hosts, application_language_code_, | |
273 excluded_ids, kMaxSnippetCount, | |
274 interactive_request); | |
270 } | 275 } |
271 | 276 |
272 void NTPSnippetsService::RescheduleFetching() { | 277 void NTPSnippetsService::RescheduleFetching() { |
273 // The scheduler only exists on Android so far, it's null on other platforms. | 278 // The scheduler only exists on Android so far, it's null on other platforms. |
274 if (!scheduler_) | 279 if (!scheduler_) |
275 return; | 280 return; |
276 | 281 |
277 if (ready()) { | 282 if (ready()) { |
278 base::Time now = base::Time::Now(); | 283 base::Time now = base::Time::Now(); |
279 scheduler_->Schedule( | 284 scheduler_->Schedule( |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { | 893 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { |
889 if (status == category_status_) | 894 if (status == category_status_) |
890 return; | 895 return; |
891 | 896 |
892 category_status_ = status; | 897 category_status_ = status; |
893 observer()->OnCategoryStatusChanged(this, provided_category_, | 898 observer()->OnCategoryStatusChanged(this, provided_category_, |
894 category_status_); | 899 category_status_); |
895 } | 900 } |
896 | 901 |
897 } // namespace ntp_snippets | 902 } // namespace ntp_snippets |
OLD | NEW |