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/remote/remote_suggestions_scheduler_impl.cc

Issue 2786023002: [Remote suggestions] Remove the unique_ptr wrapper around callbacks (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/remote/remote_suggestions_scheduler_impl.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_scheduler_impl.h"
6 6
7 #include <random> 7 #include <random>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 void RemoteSuggestionsSchedulerImpl::RefetchInTheBackground() { 435 void RemoteSuggestionsSchedulerImpl::RefetchInTheBackground() {
436 if (background_fetch_in_progress_) { 436 if (background_fetch_in_progress_) {
437 return; 437 return;
438 } 438 }
439 439
440 if (!AcquireQuota(/*interactive_request=*/false)) { 440 if (!AcquireQuota(/*interactive_request=*/false)) {
441 return; 441 return;
442 } 442 }
443 443
444 background_fetch_in_progress_ = true; 444 background_fetch_in_progress_ = true;
445 provider_->RefetchInTheBackground( 445 provider_->RefetchInTheBackground(base::Bind(
446 base::MakeUnique<RemoteSuggestionsProvider::FetchStatusCallback>( 446 &RemoteSuggestionsSchedulerImpl::RefetchInTheBackgroundFinished,
447 base::Bind( 447 base::Unretained(this)));
448 &RemoteSuggestionsSchedulerImpl::RefetchInTheBackgroundFinished,
449 base::Unretained(this))));
450 } 448 }
451 449
452 bool RemoteSuggestionsSchedulerImpl::ShouldRefetchInTheBackgroundNow( 450 bool RemoteSuggestionsSchedulerImpl::ShouldRefetchInTheBackgroundNow(
453 TriggerType trigger) { 451 TriggerType trigger) {
454 const base::Time last_fetch_attempt_time = base::Time::FromInternalValue( 452 const base::Time last_fetch_attempt_time = base::Time::FromInternalValue(
455 profile_prefs_->GetInt64(prefs::kSnippetLastFetchAttempt)); 453 profile_prefs_->GetInt64(prefs::kSnippetLastFetchAttempt));
456 base::Time first_allowed_fetch_time; 454 base::Time first_allowed_fetch_time;
457 switch (trigger) { 455 switch (trigger) {
458 case TriggerType::NTP_OPENED: 456 case TriggerType::NTP_OPENED:
459 first_allowed_fetch_time = 457 first_allowed_fetch_time =
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 return enabled_types; 573 return enabled_types;
576 } 574 }
577 575
578 std::set<RemoteSuggestionsSchedulerImpl::TriggerType> 576 std::set<RemoteSuggestionsSchedulerImpl::TriggerType>
579 RemoteSuggestionsSchedulerImpl::GetDefaultEnabledTriggerTypes() { 577 RemoteSuggestionsSchedulerImpl::GetDefaultEnabledTriggerTypes() {
580 return {TriggerType::PERSISTENT_SCHEDULER_WAKE_UP, TriggerType::NTP_OPENED, 578 return {TriggerType::PERSISTENT_SCHEDULER_WAKE_UP, TriggerType::NTP_OPENED,
581 TriggerType::BROWSER_FOREGROUNDED}; 579 TriggerType::BROWSER_FOREGROUNDED};
582 } 580 }
583 581
584 } // namespace ntp_snippets 582 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698