Commit 2800c742 authored by manuk's avatar manuk Committed by Commit Bot

[omnibox] Backoff document provider on 400 or 499 response.

Previously, the document provider backed off upon receiving http 200 responses
with certain error codes (403 & 503). However, the backend sends http 400 and
499 responses to notify the client to backoff.

This CL modifies doc provider to backoff upon receiving any of the backoff
responses: http 200 w/ code 403, http 503 w/ code 503, http 400, and http 499
responses).

To avoid having to wait for this CL to rollout, the backend may be modified to
reply with the http 200 backoff responses. If that is the case, once this CL
rolls out to stable, the backend will return to sending http 403 and 499 backoff
responses. Afterwards, the document provider will be modified to no longer
listen for the http 200 backoff responses.

Alternatively, if the backend is never modified to send http 200 backoff
responses, backoff won't work until this CL rolls out. Regardless, the document
provider should be modified to only listen to one set of backoff responses going
forward.

Bug: 1022071
Change-Id: I60070be5a0f727bfda3cf165daed03a82efbb277
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900400
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713175}
parent c9ea6cb3
...@@ -102,6 +102,11 @@ AutocompleteMatch::DocumentType GetIconForMIMEType( ...@@ -102,6 +102,11 @@ AutocompleteMatch::DocumentType GetIconForMIMEType(
const char kErrorMessageAdminDisabled[] = const char kErrorMessageAdminDisabled[] =
"Not eligible to query due to admin disabled Chrome search settings."; "Not eligible to query due to admin disabled Chrome search settings.";
const char kErrorMessageRetryLater[] = "Not eligible to query, see retry info."; const char kErrorMessageRetryLater[] = "Not eligible to query, see retry info.";
// TODO(manukh): Remove ResponseContainsBackoffSignal once the check using http
// status code in |OnURLLoadComplete| rolls out and the backend returns to
// sending 4xx backoff responses as opposed to 2xx; or, if the backend is never
// adjusted to send 2xx responses, once that check rolls out.
bool ResponseContainsBackoffSignal(const base::DictionaryValue* root_dict) { bool ResponseContainsBackoffSignal(const base::DictionaryValue* root_dict) {
const base::DictionaryValue* error_info; const base::DictionaryValue* error_info;
if (!root_dict->GetDictionary("error", &error_info)) { if (!root_dict->GetDictionary("error", &error_info)) {
...@@ -609,10 +614,15 @@ void DocumentProvider::OnURLLoadComplete( ...@@ -609,10 +614,15 @@ void DocumentProvider::OnURLLoadComplete(
LogOmniboxDocumentRequest(DOCUMENT_REPLY_RECEIVED); LogOmniboxDocumentRequest(DOCUMENT_REPLY_RECEIVED);
int httpStatusCode = source->ResponseInfo() && source->ResponseInfo()->headers
? source->ResponseInfo()->headers->response_code()
: 0;
if (httpStatusCode == 400 || httpStatusCode == 499)
backoff_for_session_ = true;
const bool results_updated = const bool results_updated =
response_body && source->NetError() == net::OK && response_body && source->NetError() == net::OK && httpStatusCode == 200 &&
(source->ResponseInfo() && source->ResponseInfo()->headers &&
source->ResponseInfo()->headers->response_code() == 200) &&
UpdateResults(SearchSuggestionParser::ExtractJsonData( UpdateResults(SearchSuggestionParser::ExtractJsonData(
source, std::move(response_body))); source, std::move(response_body)));
loader_.reset(); loader_.reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment