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

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

Issue 1978513002: Getting the personalization info in chrome://snippets-internals correct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #2 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
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 registry->RegisterListPref(prefs::kSnippetHosts); 211 registry->RegisterListPref(prefs::kSnippetHosts);
212 } 212 }
213 213
214 void NTPSnippetsService::Init(bool enabled) { 214 void NTPSnippetsService::Init(bool enabled) {
215 DCHECK(state_ == State::NOT_INITED); 215 DCHECK(state_ == State::NOT_INITED);
216 state_ = State::INITED; 216 state_ = State::INITED;
217 217
218 enabled_ = enabled; 218 enabled_ = enabled;
219 if (enabled_) { 219 if (enabled_) {
220 // |suggestions_service_| can be null in tests. 220 // |suggestions_service_| can be null in tests.
221 if (snippets_fetcher_->UseHostRestriction() && suggestions_service_) { 221 if (snippets_fetcher_->UsesHostRestrictions() && suggestions_service_) {
222 suggestions_service_subscription_ = suggestions_service_->AddCallback( 222 suggestions_service_subscription_ = suggestions_service_->AddCallback(
223 base::Bind(&NTPSnippetsService::OnSuggestionsChanged, 223 base::Bind(&NTPSnippetsService::OnSuggestionsChanged,
224 base::Unretained(this))); 224 base::Unretained(this)));
225 } 225 }
226 226
227 // Get any existing snippets immediately from prefs. 227 // Get any existing snippets immediately from prefs.
228 LoadDiscardedSnippetsFromPrefs(); 228 LoadDiscardedSnippetsFromPrefs();
229 LoadSnippetsFromPrefs(); 229 LoadSnippetsFromPrefs();
230 230
231 // If we don't have any snippets yet, start a fetch. 231 // If we don't have any snippets yet, start a fetch.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 if (snippet->expiry_date() < next_expiry) 542 if (snippet->expiry_date() < next_expiry)
543 next_expiry = snippet->expiry_date(); 543 next_expiry = snippet->expiry_date();
544 } 544 }
545 DCHECK_GT(next_expiry, expiry); 545 DCHECK_GT(next_expiry, expiry);
546 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 546 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
547 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 547 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
548 base::Unretained(this))); 548 base::Unretained(this)));
549 } 549 }
550 550
551 } // namespace ntp_snippets 551 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.h ('k') | components/ntp_snippets/ntp_snippets_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698