| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 NTPSnippetsServiceShutdown()); | 202 NTPSnippetsServiceShutdown()); |
| 203 enabled_ = false; | 203 enabled_ = false; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void NTPSnippetsService::FetchSnippets() { | 206 void NTPSnippetsService::FetchSnippets() { |
| 207 FetchSnippetsFromHosts(GetSuggestionsHosts()); | 207 FetchSnippetsFromHosts(GetSuggestionsHosts()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void NTPSnippetsService::FetchSnippetsFromHosts( | 210 void NTPSnippetsService::FetchSnippetsFromHosts( |
| 211 const std::set<std::string>& hosts) { | 211 const std::set<std::string>& hosts) { |
| 212 snippets_fetcher_->FetchSnippetsFromHosts(hosts, kMaxSnippetCount); | 212 snippets_fetcher_->FetchSnippetsFromHosts(hosts, application_language_code_, |
| 213 kMaxSnippetCount); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void NTPSnippetsService::RescheduleFetching() { | 216 void NTPSnippetsService::RescheduleFetching() { |
| 216 // The scheduler only exists on Android so far, it's null on other platforms. | 217 // The scheduler only exists on Android so far, it's null on other platforms. |
| 217 if (!scheduler_) | 218 if (!scheduler_) |
| 218 return; | 219 return; |
| 219 | 220 |
| 220 if (enabled_) { | 221 if (enabled_) { |
| 221 base::Time now = base::Time::Now(); | 222 base::Time now = base::Time::Now(); |
| 222 scheduler_->Schedule( | 223 scheduler_->Schedule( |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (snippet->expiry_date() < next_expiry) | 480 if (snippet->expiry_date() < next_expiry) |
| 480 next_expiry = snippet->expiry_date(); | 481 next_expiry = snippet->expiry_date(); |
| 481 } | 482 } |
| 482 DCHECK_GT(next_expiry, expiry); | 483 DCHECK_GT(next_expiry, expiry); |
| 483 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, | 484 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, |
| 484 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, | 485 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, |
| 485 base::Unretained(this))); | 486 base::Unretained(this))); |
| 486 } | 487 } |
| 487 | 488 |
| 488 } // namespace ntp_snippets | 489 } // namespace ntp_snippets |
| OLD | NEW |