#include "content/public/test/network_connection_change_simulator.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/network_service_util.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/network_change_notifier.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "services/network/public/mojom/network_service_test.mojom.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "net/base/network_change_notifier_passive.h"
#endif
namespace content {
constexpr base::RunLoop::Type kRunLoopType = …;
NetworkConnectionChangeSimulator::NetworkConnectionChangeSimulator() = default;
NetworkConnectionChangeSimulator::~NetworkConnectionChangeSimulator() = default;
#if BUILDFLAG(IS_CHROMEOS)
void NetworkConnectionChangeSimulator::InitializeChromeosConnectionType() {
net::NetworkChangeNotifierPassive* network_change_notifier =
static_cast<net::NetworkChangeNotifierPassive*>(
content::GetNetworkChangeNotifier());
network_change_notifier->OnConnectionChanged(
net::NetworkChangeNotifier::CONNECTION_ETHERNET);
if (IsOutOfProcessNetworkService()) {
mojo::Remote<network::mojom::NetworkChangeManager> manager;
GetNetworkService()->GetNetworkChangeManager(
manager.BindNewPipeAndPassReceiver());
manager->OnNetworkChanged(
false, false,
true,
network::mojom::ConnectionType::CONNECTION_ETHERNET,
false,
network::mojom::ConnectionSubtype::SUBTYPE_UNKNOWN);
}
}
#endif
void NetworkConnectionChangeSimulator::SetConnectionType(
network::mojom::ConnectionType type) { … }
void NetworkConnectionChangeSimulator::SimulateNetworkChange(
network::mojom::ConnectionType type) { … }
void NetworkConnectionChangeSimulator::OnConnectionChanged(
network::mojom::ConnectionType connection_type) { … }
}