Commit e862177f authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

Reduce get token timeout to 50ms on Android.

Regression is still seen at 50% Stable:
http://uma/p/chrome/variations?sid=a3d201c28d29aab0568c58c18fca2e40.

Currently 85% of get token requests finish within 50ms.
http://uma/p/chrome/histograms?sid=1c472f87b67d1fe3197bdde7cb56db0e
Waiting for a full second for acquiring tokens is too long.
We should use an empty token if the token cannot be acquired in 50ms.
In this CL, reduce the get token timeout to 50ms to see if it mitigates
the issue. If the issue is still there, we will look into other
solutions such as fetching the token in the background.

Bug: 1070324
Change-Id: I744c775e88162b9c8814bf4a4efab98085c94da3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442010Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812902}
parent be9c75fc
......@@ -10,6 +10,7 @@
#include "base/optional.h"
#include "base/task/post_task.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/safe_browsing/core/common/thread_utils.h"
#include "components/signin/public/identity_manager/access_token_fetcher.h"
#include "components/signin/public/identity_manager/access_token_info.h"
......@@ -24,7 +25,11 @@ namespace {
const char kAPIScope[] = "https://www.googleapis.com/auth/chrome-safe-browsing";
const int kTimeoutDelaySeconds = 1;
#if defined(OS_ANDROID)
const int kTimeoutDelayFromMilliseconds = 50;
#else
const int kTimeoutDelayFromMilliseconds = 1000;
#endif
} // namespace
......@@ -60,7 +65,7 @@ void SafeBrowsingTokenFetcher::Start(signin::ConsentLevel consent_level,
FROM_HERE, CreateTaskTraits(ThreadID::UI),
base::BindOnce(&SafeBrowsingTokenFetcher::OnTokenTimeout,
weak_ptr_factory_.GetWeakPtr(), request_id),
base::TimeDelta::FromSeconds(kTimeoutDelaySeconds));
base::TimeDelta::FromMilliseconds(kTimeoutDelayFromMilliseconds));
}
void SafeBrowsingTokenFetcher::OnTokenFetched(
......
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