Chromium Code Reviews| Index: components/ntp_snippets/remote/remote_suggestions_provider_impl.cc |
| diff --git a/components/ntp_snippets/remote/remote_suggestions_provider_impl.cc b/components/ntp_snippets/remote/remote_suggestions_provider_impl.cc |
| index eba4dda04ebb8442ea1d740120c4d246b4542079..1c44cc81f2aab950ce24d67c1fcce57ea0f5db9f 100644 |
| --- a/components/ntp_snippets/remote/remote_suggestions_provider_impl.cc |
| +++ b/components/ntp_snippets/remote/remote_suggestions_provider_impl.cc |
| @@ -324,6 +324,10 @@ void RemoteSuggestionsProviderImpl::SetRemoteSuggestionsScheduler( |
| } |
| void RemoteSuggestionsProviderImpl::ReloadSuggestions() { |
| + if (remote_suggestions_scheduler_ && |
| + !remote_suggestions_scheduler_->AcquireQuotaForInteractiveFetch()) { |
|
Marc Treib
2017/03/23 16:41:15
Hm. So if there's no scheduler, we don't bother wi
tschumann
2017/03/23 17:38:27
+1, let's return early if we don't have a schedule
jkrcal
2017/03/27 10:03:02
Done. I cannot make it part of ready() because the
|
| + return; |
| + } |
| FetchSuggestions(/*interactive_request=*/true, |
| /*callback=*/nullptr); |
| } |
| @@ -368,6 +372,12 @@ void RemoteSuggestionsProviderImpl::Fetch( |
| "RemoteSuggestionsProvider is not ready!")); |
| return; |
| } |
| + if (remote_suggestions_scheduler_ && |
| + !remote_suggestions_scheduler_->AcquireQuotaForInteractiveFetch()) { |
| + CallWithEmptyResults(callback, Status(StatusCode::TEMPORARY_ERROR, |
| + "Interactive quota exceeded!")); |
| + return; |
| + } |
| RequestParams params = BuildFetchParams(); |
| params.excluded_ids.insert(known_suggestion_ids.begin(), |
| known_suggestion_ids.end()); |
| @@ -643,6 +653,9 @@ void RemoteSuggestionsProviderImpl::OnFetchMoreFinished( |
| // status? |
| UpdateCategoryStatus(category, CategoryStatus::AVAILABLE); |
| // Notify callers and observers. |
| + if (remote_suggestions_scheduler_) { |
|
tschumann
2017/03/23 17:38:27
this should never be nullptr, right? remove the if
jkrcal
2017/03/27 10:03:02
Correct, removed the ifs here and below.
I am not
Marc Treib
2017/03/27 11:31:00
Not sure I understand the proposal... who would wr
jkrcal
2017/03/27 14:09:31
I am not sure either :D
The only solution I can i
Marc Treib
2017/03/27 14:27:20
Alright, then let's leave it as is for now, and le
tschumann
2017/03/27 15:40:45
OnFetchMoreFinished is already doing a lot of thin
jkrcal
2017/03/27 16:02:22
Tim, in the current state of the CL, the scheduler
jkrcal
2017/03/29 10:55:57
Okay, done.
|
| + remote_suggestions_scheduler_->OnInteractiveFetchFinished(status); |
| + } |
| fetching_callback.Run(Status::Success(), std::move(result)); |
| NotifyNewSuggestions(category, *existing_content); |
| } |
| @@ -727,6 +740,10 @@ void RemoteSuggestionsProviderImpl::OnFetchFinished( |
| content.dismissed.size()); |
| } |
| + if (interactive_request && remote_suggestions_scheduler_) { |
| + remote_suggestions_scheduler_->OnInteractiveFetchFinished(status); |
| + } |
| + |
| if (callback) { |
| callback->Run(status); |
| } |