Commit 29e01137 authored by Orin Jaworski's avatar Orin Jaworski Committed by Commit Bot

[omnibox] Configure OpenSearch requests with timeout and retry

This CL makes OpenSearch description document fetching more robust
by timing out old failed requests and retrying requests that would
otherwise silently fail due to network change.

Bug: 956689
Change-Id: I26e21194ea8911916b7766b3a6eb47d6d35643c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688437
Commit-Queue: Orin Jaworski <orinj@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676536}
parent 663bb259
...@@ -19,6 +19,18 @@ ...@@ -19,6 +19,18 @@
namespace { namespace {
// In some network environments, silent failure can be avoided by retrying
// request on network change. This helps OpenSearch get through in such cases.
// See https://crbug.com/956689 for context.
constexpr int kOpenSearchRetryCount = 3;
// Timeout for OpenSearch description document (OSDD) fetch request.
// Requests for a particular resource are limited to one.
// Requests may not receive a response, and in that case no
// further requests would be allowed. The timeout cleans up failed requests
// so that later attempts to fetch the OSDD can be made.
constexpr int kOpenSearchTimeoutSeconds = 30;
// Traffic annotation for RequestDelegate. // Traffic annotation for RequestDelegate.
const net::NetworkTrafficAnnotationTag kTrafficAnnotation = const net::NetworkTrafficAnnotationTag kTrafficAnnotation =
net::DefineNetworkTrafficAnnotation("open_search", R"( net::DefineNetworkTrafficAnnotation("open_search", R"(
...@@ -116,6 +128,10 @@ TemplateURLFetcher::RequestDelegate::RequestDelegate( ...@@ -116,6 +128,10 @@ TemplateURLFetcher::RequestDelegate::RequestDelegate(
simple_url_loader_ = network::SimpleURLLoader::Create( simple_url_loader_ = network::SimpleURLLoader::Create(
std::move(resource_request), kTrafficAnnotation); std::move(resource_request), kTrafficAnnotation);
simple_url_loader_->SetAllowHttpErrorResults(true); simple_url_loader_->SetAllowHttpErrorResults(true);
simple_url_loader_->SetTimeoutDuration(
base::TimeDelta::FromSeconds(kOpenSearchTimeoutSeconds));
simple_url_loader_->SetRetryOptions(
kOpenSearchRetryCount, network::SimpleURLLoader::RETRY_ON_NETWORK_CHANGE);
simple_url_loader_->DownloadToString( simple_url_loader_->DownloadToString(
url_loader_factory, url_loader_factory,
base::BindOnce( base::BindOnce(
......
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