Bug 1167132 - Part 1: [NetworkManager] Move network information into a separate interface (idl). r=echen
authorJessica Jong <jjong@mozilla.com>
Wed, 29 Jul 2015 02:00:00 -0400
changeset 286943 d30bd2a5787226a5ce22c201cb5fa6ac13c8c4c2
parent 286942 ee17e2b7ede8b9feaf161280a10a7618e043d4bc
child 286944 c722ee4b5cc32ca7f7b6a2b72711fde62f0fbed8
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1167132
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1167132 - Part 1: [NetworkManager] Move network information into a separate interface (idl). r=echen
dom/system/gonk/moz.build
dom/system/gonk/nsIDataCallManager.idl
dom/system/gonk/nsINetworkInterface.idl
dom/system/gonk/nsINetworkManager.idl
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -11,16 +11,17 @@
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 XPIDL_SOURCES += [
     'nsIAudioManager.idl',
+    'nsINetworkInterface.idl',
     'nsINetworkInterfaceListService.idl',
     'nsINetworkManager.idl',
     'nsINetworkService.idl',
     'nsINetworkWorker.idl',
     'nsISystemWorkerManager.idl',
     'nsITetheringService.idl',
     'nsIVolume.idl',
     'nsIVolumeMountLock.idl',
--- a/dom/system/gonk/nsIDataCallManager.idl
+++ b/dom/system/gonk/nsIDataCallManager.idl
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
-#include "nsINetworkManager.idl"
+#include "nsINetworkInterface.idl"
 
-[scriptable, uuid(b8ce8528-fce8-4b5e-9d0a-c3247296ccaf)]
-interface nsIRilNetworkInterface : nsINetworkInterface
+[scriptable, uuid(501b7041-0754-4ddb-9174-946e2c2ebd83)]
+interface nsIRilNetworkInfo : nsINetworkInfo
 {
   readonly attribute unsigned long serviceId;
   readonly attribute DOMString iccId;
 
   /* The following attributes are for MMS proxy settings. */
   readonly attribute DOMString mmsc;     // Empty string if not set.
   readonly attribute DOMString mmsProxy; // Empty string if not set.
   readonly attribute long      mmsPort;  // -1 if not set.
new file mode 100644
--- /dev/null
+++ b/dom/system/gonk/nsINetworkInterface.idl
@@ -0,0 +1,100 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(f439ab5d-64bd-4a6c-8863-30235fa784d2)]
+interface nsINetworkInfo : nsISupports
+{
+  const long NETWORK_STATE_UNKNOWN       = -1;
+  const long NETWORK_STATE_CONNECTING    = 0;
+  const long NETWORK_STATE_CONNECTED     = 1;
+  const long NETWORK_STATE_DISCONNECTING = 2;
+  const long NETWORK_STATE_DISCONNECTED  = 3;
+
+  /**
+   * Current network state, one of the NETWORK_STATE_* constants.
+   *
+   * When this changes, network interface implementations notify with
+   * updateNetworkInterface() API.
+   */
+  readonly attribute long state;
+
+  const long NETWORK_TYPE_UNKNOWN     = -1;
+  const long NETWORK_TYPE_WIFI        = 0;
+  const long NETWORK_TYPE_MOBILE      = 1;
+  const long NETWORK_TYPE_MOBILE_MMS  = 2;
+  const long NETWORK_TYPE_MOBILE_SUPL = 3;
+  const long NETWORK_TYPE_WIFI_P2P    = 4;
+  const long NETWORK_TYPE_MOBILE_IMS  = 5;
+  const long NETWORK_TYPE_MOBILE_DUN  = 6;
+  const long NETWORK_TYPE_MOBILE_FOTA = 7;
+
+  /**
+   * Network type. One of the NETWORK_TYPE_* constants.
+   */
+  readonly attribute long type;
+
+  /**
+   * Interface name of the network interface this network info belongs to.
+   */
+  readonly attribute DOMString name;
+
+  /**
+   * Get the list of ip addresses and prefix lengths, ip address could be IPv4
+   * or IPv6, typically 1 IPv4 or 1 IPv6 or one of each.
+   *
+   * @param ips
+   *        The list of ip addresses retrieved.
+   * @param prefixLengths
+   *        The list of prefix lengths retrieved.
+   *
+   * @returns the length of the lists.
+   */
+  void getAddresses([array, size_is(count)] out wstring ips,
+                    [array, size_is(count)] out unsigned long prefixLengths,
+                    [retval] out unsigned long count);
+
+  /**
+   * Get the list of gateways, could be IPv4 or IPv6, typically 1 IPv4 or 1
+   * IPv6 or one of each.
+   *
+   * @param count
+   *        The length of the list of gateways
+   *
+   * @returns the list of gateways.
+   */
+  void getGateways([optional] out unsigned long count,
+                   [array, size_is(count), retval] out wstring gateways);
+
+  /**
+   * Get the list of dnses, could be IPv4 or IPv6.
+   *
+   * @param count
+   *        The length of the list of dnses.
+   *
+   * @returns the list of dnses.
+   */
+  void getDnses([optional] out unsigned long count,
+                [array, size_is(count), retval] out wstring dnses);
+};
+
+[scriptable, uuid(9a025351-8684-4ab5-a0c1-f21a9f83d405)]
+interface nsINetworkInterface : nsISupports
+{
+  /**
+   * The network information about this network interface.
+   */
+  readonly attribute nsINetworkInfo info;
+
+  /**
+   * The host name of the http proxy server.
+   */
+  readonly attribute DOMString httpProxyHost;
+
+  /*
+   * The port number of the http proxy server.
+   */
+  readonly attribute long httpProxyPort;
+};
--- a/dom/system/gonk/nsINetworkManager.idl
+++ b/dom/system/gonk/nsINetworkManager.idl
@@ -1,107 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-/**
- * Information about networks that is exposed to network manager API consumers.
- */
-[scriptable, uuid(12da2bfd-0801-40d9-9c2e-768868526065)]
-interface nsINetworkInterface : nsISupports
-{
-  const long NETWORK_STATE_UNKNOWN = -1;
-  const long NETWORK_STATE_CONNECTING = 0;
-  const long NETWORK_STATE_CONNECTED = 1;
-  const long NETWORK_STATE_DISCONNECTING = 2;
-  const long NETWORK_STATE_DISCONNECTED = 3;
-
-  /**
-   * Current network state, one of the NETWORK_STATE_* constants.
-   *
-   * When this changes, network interface implementations notify with
-   * updateNetworkInterface() API.
-   */
-  readonly attribute long state;
-
-  const long NETWORK_TYPE_UNKNOWN     = -1;
-  const long NETWORK_TYPE_WIFI        = 0;
-  const long NETWORK_TYPE_MOBILE      = 1;
-  const long NETWORK_TYPE_MOBILE_MMS  = 2;
-  const long NETWORK_TYPE_MOBILE_SUPL = 3;
-  const long NETWORK_TYPE_WIFI_P2P    = 4;
-  const long NETWORK_TYPE_MOBILE_IMS  = 5;
-  const long NETWORK_TYPE_MOBILE_DUN  = 6;
-  const long NETWORK_TYPE_MOBILE_FOTA = 7;
-
-  /**
-   * Network type. One of the NETWORK_TYPE_* constants.
-   */
-  readonly attribute long type;
-
-  /**
-   * Name of the network interface. This identifier is unique.
-   */
-  readonly attribute DOMString name;
-
-  /**
-   * The host name of the http proxy server.
-   */
-  readonly attribute DOMString httpProxyHost;
-
-  /*
-   * The port number of the http proxy server.
-   */
-  readonly attribute long httpProxyPort;
-
-  /**
-   * Get the list of ip addresses and prefix lengths, ip address could be IPv4
-   * or IPv6, typically 1 IPv4 or 1 IPv6 or one of each.
-   *
-   * @param ips
-   *        The list of ip addresses retrieved.
-   * @param prefixLengths
-   *        The list of prefix lengths retrieved.
-   *
-   * @returns the length of the lists.
-   */
-  void getAddresses([array, size_is(count)] out wstring ips,
-                    [array, size_is(count)] out unsigned long prefixLengths,
-                    [retval] out unsigned long count);
-
-  /**
-   * Get the list of gateways, could be IPv4 or IPv6, typically 1 IPv4 or 1
-   * IPv6 or one of each.
-   *
-   * @param count
-   *        The length of the list of gateways
-   *
-   * @returns the list of gateways.
-   */
-  void getGateways([optional] out unsigned long count,
-                   [array, size_is(count), retval] out wstring gateways);
-
-  /**
-   * Get the list of dnses, could be IPv4 or IPv6.
-   *
-   * @param count
-   *        The length of the list of dnses.
-   *
-   * @returns the list of dnses.
-   */
-  void getDnses([optional] out unsigned long count,
-                [array, size_is(count), retval] out wstring dnses);
-};
+interface nsINetworkInfo;
+interface nsINetworkInterface;
 
 /**
  * Manage network interfaces.
  */
-[scriptable, uuid(b0ab71bf-4b38-4796-8a3c-4141255f4259)]
+[scriptable, uuid(e5ffe335-078e-4b25-87f1-02429bd2e458)]
 interface nsINetworkManager : nsISupports
 {
   /**
    * Register the given network interface with the network manager.
    *
    * Consumers will be notified with the 'network-interface-registered'
    * observer notification.
    *
@@ -136,40 +50,41 @@ interface nsINetworkManager : nsISupport
    * registered.
    *
    * @param network
    *        Network interface to unregister.
    */
   void unregisterNetworkInterface(in nsINetworkInterface network);
 
   /**
-   * Object containing all known network connections, keyed by their
+   * Object containing all known network information, keyed by their
    * network id. Network id is composed of a sub-id + '-' + network
    * type. For mobile network types, sub-id is 'ril' + service id; for
    * non-mobile network types, sub-id is always 'device'.
    */
-  readonly attribute jsval networkInterfaces;
+  readonly attribute jsval allNetworkInfo;
 
   /**
    * The preferred network type. One of the
    * nsINetworkInterface::NETWORK_TYPE_* constants.
    *
    * This attribute is used for setting default route to favor
    * interfaces with given type.  This can be overriden by calling
    * overrideDefaultRoute().
    */
   attribute long preferredNetworkType;
 
   /**
-   * The network interface handling all data traffic.
+   * The network information of the network interface handling all network
+   * traffic.
    *
    * When this changes, the 'network-active-changed' observer
    * notification is dispatched.
    */
-  readonly attribute nsINetworkInterface active;
+  readonly attribute nsINetworkInfo activeNetworkInfo;
 
   /**
    * Override the default behaviour for preferredNetworkType and route
    * all network traffic through the the specified interface.
    *
    * Consumers can observe changes to the active network by subscribing to
    * the 'network-active-changed' observer notification.
    *
@@ -178,34 +93,34 @@ interface nsINetworkManager : nsISupport
    *        a previous override is canceled.
    */
   long overrideActive(in nsINetworkInterface network);
 
   /**
    * Add host route to the specified network into routing table.
    *
    * @param network
-   *        The network interface where the host to be routed to.
+   *        The network information for the host to be routed to.
    * @param host
    *        The host to be added.
    *        The host will be resolved in advance if it's not an ip-address.
    *
    * @return a Promise
    *         resolved if added; rejected, otherwise.
    */
-  jsval addHostRoute(in nsINetworkInterface network,
+  jsval addHostRoute(in nsINetworkInfo network,
                      in DOMString host);
 
   /**
    * Remove host route to the specified network from routing table.
    *
    * @param network
-   *        The network interface where the routing to be removed from.
+   *        The network information for the routing to be removed from.
    * @param host
    *        The host routed to the network.
    *        The host will be resolved in advance if it's not an ip-address.
    *
    * @return a Promise
    *         resolved if removed; rejected, otherwise.
    */
-  jsval removeHostRoute(in nsINetworkInterface network,
+  jsval removeHostRoute(in nsINetworkInfo network,
                         in DOMString host);
 };