Skip to content

Commit

Permalink
arc: net: Listen on network configuration changes
Browse files Browse the repository at this point in the history
Chrome listens on network configuration changes. The changes
are now triggered by DNS proxy addresses change. This is needed
for ARC to always have the correct DNS proxy addresses. Chrome
will pass the addresses to ARC on changes.

BUG=b:232882301
TEST=Observe that OnNetworkConfigurationChanged is called;

Change-Id: I1e2391d20fdad393ec8bf22f4d8234649427895e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3760110
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Commit-Queue: Jason Jeremy Iman <jasongustaman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1028610}
  • Loading branch information
Jason Jeremy Iman authored and Chromium LUCI CQ committed Jul 27, 2022
1 parent 29d425b commit 3437b51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ash/components/arc/net/arc_net_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ void ArcNetHostImpl::OnConnectionReady() {
default_network->path(), base::BindOnce(&ArcVpnSuccessCallback),
base::BindOnce(&ArcVpnErrorCallback, "disconnecting stale ARC VPN"));
}

// Listen on network configuration changes.
ash::PatchPanelClient::Get()->AddObserver(this);
}

void ArcNetHostImpl::OnConnectionClosed() {
Expand All @@ -640,6 +643,12 @@ void ArcNetHostImpl::OnConnectionClosed() {
observing_network_state_ = false;
}

void ArcNetHostImpl::NetworkConfigurationChanged() {
// Get patchpanel devices and update active networks.
ash::PatchPanelClient::Get()->GetDevices(base::BindOnce(
&ArcNetHostImpl::UpdateActiveNetworks, weak_factory_.GetWeakPtr()));
}

void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type,
GetNetworksCallback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/net/arc_net_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/values.h"
#include "chromeos/ash/components/dbus/patchpanel/patchpanel_client.h"
#include "chromeos/ash/components/dbus/patchpanel/patchpanel_service.pb.h"
#include "chromeos/ash/components/network/network_connection_observer.h"
#include "chromeos/ash/components/network/network_profile_handler.h"
Expand All @@ -40,6 +41,7 @@ class ArcNetHostImpl : public KeyedService,
public ConnectionObserver<mojom::NetInstance>,
public chromeos::NetworkConnectionObserver,
public chromeos::NetworkStateHandlerObserver,
public ash::PatchPanelClient::Observer,
public mojom::NetHost {
public:
// Returns singleton instance for the given BrowserContext,
Expand Down Expand Up @@ -215,6 +217,9 @@ class ArcNetHostImpl : public KeyedService,
void ReceiveShillProperties(const std::string& service_path,
absl::optional<base::Value> shill_properties);

// PatchPanelClient::Observer implementation:
void NetworkConfigurationChanged() override;

ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.

// True if the chrome::NetworkStateHandler is currently being observed for
Expand Down

0 comments on commit 3437b51

Please sign in to comment.