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

// https://wicg.github.io/netinfo/#the-networkinformation-interface

enum ConnectionType {
    "cellular",
    "bluetooth",
    "ethernet",
    "wifi",
    "wimax",
    "other",
    "none",
    "unknown"
};

enum EffectiveConnectionType {
    "slow-2g",
    "2g",
    "3g",
    "4g"
};

typedef unrestricted double Megabit;
typedef unsigned long long Milliseconds;

[
    ActiveScriptWrappable,
    Exposed=(Window,Worker)
] interface NetworkInformation : EventTarget {
    [RuntimeEnabled=NetInfoDownlinkMax, MeasureAs=NetInfoType] readonly attribute ConnectionType type;
    [RuntimeEnabled=NetInfoDownlinkMax, MeasureAs=NetInfoDownlinkMax] readonly attribute Megabit downlinkMax;
    [RuntimeEnabled=NetInfoEffectiveType, MeasureAs=NetInfoOnChange] attribute EventHandler onchange;
    [RuntimeEnabled=NetInfoDownlinkMax, MeasureAs=NetInfoOnTypeChange] attribute EventHandler ontypechange;
    [RuntimeEnabled=NetInfoEffectiveType, MeasureAs=NetInfoEffectiveType] readonly attribute EffectiveConnectionType effectiveType;
    [RuntimeEnabled=NetInfoRtt, MeasureAs=NetInfoRtt] readonly attribute Milliseconds rtt;
    [RuntimeEnabled=NetInfoDownlink, MeasureAs=NetInfoDownlink] readonly attribute Megabit downlink;
    [RuntimeEnabled=NetInfoSaveData, MeasureAs=NetInfoSaveData] readonly attribute boolean saveData;
};
