chromium/services/network/public/mojom/network_change_manager.mojom

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module network.mojom;

import "services/network/public/mojom/network_interface_change_listener.mojom";

// This needs to match the definition of net::ConnectionType.
enum ConnectionType {
  CONNECTION_UNKNOWN = 0,  // A connection exists, but its type is unknown.
                           // Also used as a default value.
  CONNECTION_ETHERNET = 1,
  CONNECTION_WIFI = 2,
  CONNECTION_2G = 3,
  CONNECTION_3G = 4,
  CONNECTION_4G = 5,
  CONNECTION_NONE = 6,     // No connection.
  CONNECTION_BLUETOOTH = 7,
  CONNECTION_5G = 8,
  CONNECTION_LAST = CONNECTION_5G
};

// This needs to match the definition of net::ConnectionSubtype.
enum ConnectionSubtype {
  SUBTYPE_UNKNOWN = 0,
  SUBTYPE_NONE,
  SUBTYPE_OTHER,
  SUBTYPE_GSM,
  SUBTYPE_IDEN,
  SUBTYPE_CDMA,
  SUBTYPE_1XRTT,
  SUBTYPE_GPRS,
  SUBTYPE_EDGE,
  SUBTYPE_UMTS,
  SUBTYPE_EVDO_REV_0,
  SUBTYPE_EVDO_REV_A,
  SUBTYPE_HSPA,
  SUBTYPE_EVDO_REV_B,
  SUBTYPE_HSDPA,
  SUBTYPE_HSUPA,
  SUBTYPE_EHRPD,
  SUBTYPE_HSPAP,
  SUBTYPE_LTE,
  SUBTYPE_LTE_ADVANCED,
  SUBTYPE_BLUETOOTH_1_2,
  SUBTYPE_BLUETOOTH_2_1,
  SUBTYPE_BLUETOOTH_3_0,
  SUBTYPE_BLUETOOTH_4_0,
  SUBTYPE_ETHERNET,
  SUBTYPE_FAST_ETHERNET,
  SUBTYPE_GIGABIT_ETHERNET,
  SUBTYPE_10_GIGABIT_ETHERNET,
  SUBTYPE_WIFI_B,
  SUBTYPE_WIFI_G,
  SUBTYPE_WIFI_N,
  SUBTYPE_WIFI_AC,
  SUBTYPE_WIFI_AD,
  SUBTYPE_LAST = SUBTYPE_WIFI_AD
};

// A client interface that subscribes to network change events from
// NetworkChangeManager.
interface NetworkChangeManagerClient {
  // Invoked when the initial connection type is ready.
  OnInitialConnectionType(ConnectionType type);

  // OnNetworkChanged will be called when a change occurs to the host
  // computer's hardware or software that affects the route network packets
  // take to any network server. Some examples:
  //   1. A network connection becoming available or going away. For example
  //      plugging or unplugging an Ethernet cable, WiFi or cellular modem
  //      connecting or disconnecting from a network, or a VPN tunnel being
  //      established or taken down.
  //   2. An active network connection's IP address changes.
  //   3. A change to the local IP routing tables.
  // The signal is produced when the change is complete. For example if a new
  // network connection has become available, the signal is issued after OS has
  // finished establishing the connection (i.e. DHCP is done) to the point where
  // the new connection is usable. |type| indicates the type of the active
  // primary network connection after the change.  OnNetworkChanged will always
  // be called with CONNECTION_NONE immediately prior to being called with an
  // online state.
  OnNetworkChanged(ConnectionType type);
};

// An interface for facilitating notifications of network change events.
interface NetworkChangeManager {
  // Requests to receive notification when there is a network change.
  RequestNotifications(
      pending_remote<NetworkChangeManagerClient> client_remote);

  // Notifies the network service that the network configuration has changed.
  // This is needed for ChromeOS because only one process can listen for network
  // changes from Shill, and currently that has to be the browser process. This
  // allows the browser process to forward the network changes to the network
  // service. Similarly for Android and Lacros: only the browser process can
  // listen for network changes due to platform-specific issues. And on Linux,
  // listening for network changes can't run sandboxed.
  [EnableIf=network_change_notifier_in_browser]
  OnNetworkChanged(
      bool dns_changed,
      bool ip_address_changed,
      bool connection_type_changed,
      ConnectionType new_connection_type,
      bool connection_subtype_changed,
      ConnectionSubtype new_connection_subtype);

  // Informs the network service to bind a NetworkInterfaceChangeListener, which
  // will be informed of changes to the set of network interfaces.
  [EnableIf=use_network_interface_change_listener]
  BindNetworkInterfaceChangeListener(
      pending_associated_receiver<NetworkInterfaceChangeListener> notifier);
};