Commit 38698310 authored by Junbo Ke's avatar Junbo Ke Committed by Commit Bot

[Chromecast] Avoid checking connectivity when connection type cannot be

retrieved synchronously.

Bug: b/150888532
Test: CQ
Change-Id: I82f63be44fcb832a5a4ed5c0eccd36211eb15313
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097539Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Junbo Ke <juke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749261}
parent f2d9411d
...@@ -158,14 +158,18 @@ void ConnectivityCheckerImpl::CheckInternal() { ...@@ -158,14 +158,18 @@ void ConnectivityCheckerImpl::CheckInternal() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(url_loader_factory_); DCHECK(url_loader_factory_);
// Don't check connectivity if network is offline, because Internet could be
// accessible via netifs ignored.
auto connection_type = network::mojom::ConnectionType::CONNECTION_UNKNOWN; auto connection_type = network::mojom::ConnectionType::CONNECTION_UNKNOWN;
network_connection_tracker_->GetConnectionType( bool is_sync = network_connection_tracker_->GetConnectionType(
&connection_type, &connection_type,
base::BindOnce(&ConnectivityCheckerImpl::OnConnectionChanged, base::BindOnce(&ConnectivityCheckerImpl::OnConnectionChanged,
weak_this_)); weak_this_));
if (connection_type == network::mojom::ConnectionType::CONNECTION_NONE) {
// Don't check connectivity if network is offline.
// Also don't check connectivity if the connection_type cannot be
// synchronously retrieved, since OnConnectionChanged will be triggered later
// which will cause duplicate checks.
if (!is_sync ||
connection_type == network::mojom::ConnectionType::CONNECTION_NONE) {
return; return;
} }
......
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