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

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

Issue 1922083004: Allow fetching personalized snippets from ChromeReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes 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
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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/json/json_reader.h"
Marc Treib 2016/05/09 12:33:34 Not required? Also stringprintf below I think.
jkrcal 2016/05/09 15:30:13 Done.
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/stringprintf.h"
19 #include "base/task_runner_util.h" 21 #include "base/task_runner_util.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "base/values.h" 23 #include "base/values.h"
22 #include "components/image_fetcher/image_fetcher.h" 24 #include "components/image_fetcher/image_fetcher.h"
23 #include "components/ntp_snippets/pref_names.h" 25 #include "components/ntp_snippets/pref_names.h"
24 #include "components/ntp_snippets/switches.h" 26 #include "components/ntp_snippets/switches.h"
25 #include "components/prefs/pref_registry_simple.h" 27 #include "components/prefs/pref_registry_simple.h"
26 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
27 #include "components/suggestions/proto/suggestions.pb.h" 29 #include "components/suggestions/proto/suggestions.pb.h"
28 30
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 NTPSnippetsServiceShutdown()); 206 NTPSnippetsServiceShutdown());
205 enabled_ = false; 207 enabled_ = false;
206 } 208 }
207 209
208 void NTPSnippetsService::FetchSnippets() { 210 void NTPSnippetsService::FetchSnippets() {
209 FetchSnippetsFromHosts(GetSuggestionsHosts()); 211 FetchSnippetsFromHosts(GetSuggestionsHosts());
210 } 212 }
211 213
212 void NTPSnippetsService::FetchSnippetsFromHosts( 214 void NTPSnippetsService::FetchSnippetsFromHosts(
213 const std::set<std::string>& hosts) { 215 const std::set<std::string>& hosts) {
214 snippets_fetcher_->FetchSnippetsFromHosts(hosts, kMaxSnippetCount); 216 snippets_fetcher_->FetchSnippetsFromHosts(
217 hosts, application_language_code_, kMaxSnippetCount);
215 } 218 }
216 219
217 void NTPSnippetsService::RescheduleFetching() { 220 void NTPSnippetsService::RescheduleFetching() {
218 // The scheduler only exists on Android so far, it's null on other platforms. 221 // The scheduler only exists on Android so far, it's null on other platforms.
219 if (!scheduler_) 222 if (!scheduler_)
220 return; 223 return;
221 224
222 if (enabled_) { 225 if (enabled_) {
223 base::Time now = base::Time::Now(); 226 base::Time now = base::Time::Now();
224 scheduler_->Schedule( 227 scheduler_->Schedule(
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (snippet->expiry_date() < next_expiry) 487 if (snippet->expiry_date() < next_expiry)
485 next_expiry = snippet->expiry_date(); 488 next_expiry = snippet->expiry_date();
486 } 489 }
487 DCHECK_GT(next_expiry, expiry); 490 DCHECK_GT(next_expiry, expiry);
488 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 491 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
489 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 492 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
490 base::Unretained(this))); 493 base::Unretained(this)));
491 } 494 }
492 495
493 } // namespace ntp_snippets 496 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698