blob: 518cc9083cdb13ee392202c97b4f87c025c32fa9 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// found in the LICENSE file.
#include "base/optional.h"
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
namespace net {
NET_EXPORT extern const char kEffectiveConnectionTypeUnknown[];
NET_EXPORT extern const char kEffectiveConnectionTypeOffline[];
NET_EXPORT extern const char kEffectiveConnectionTypeSlow2G[];
NET_EXPORT extern const char kEffectiveConnectionType2G[];
NET_EXPORT extern const char kEffectiveConnectionType3G[];
NET_EXPORT extern const char kEffectiveConnectionType4G[];
// EffectiveConnectionType is the connection type whose typical performance is
// most similar to the measured performance of the network in use. In many
// cases, the "effective" connection type and the actual type of connection in
// use are the same, but often a network connection performs significantly
// differently, usually worse, from its expected capabilities.
// EffectiveConnectionType of a network is independent of if the current
// connection is metered or not. For example, an unmetered slow connection may
// have EFFECTIVE_CONNECTION_TYPE_SLOW_2G as its effective connection type. The
// effective connection type enums are be in increasing order of quality.
enum EffectiveConnectionType {
// Effective connection type reported when the network quality is unknown.
// Effective connection type reported when the Internet is unreachable
// because the device does not have a connection (as reported by underlying
// platform APIs). Note that due to rare but potential bugs in the platform
// APIs, it is possible that effective connection type is reported as
// EFFECTIVE_CONNECTION_TYPE_OFFLINE. Callers must use caution when using
// acting on this.
// Effective connection type reported when the network has the quality of a
// poor 2G connection.
// faster 2G connection.
// Effective connection type reported when the network has the quality of a 3G
// connection.
// Effective connection type reported when the network has the quality of a 4G
// connection.
// Last value of the effective connection type. This value is unused.
// Returns the string equivalent of |type|.
NET_EXPORT const char* GetNameForEffectiveConnectionType(
EffectiveConnectionType type);
// Returns the EffectiveConnectionType that corresponds to
// |connection_type_name|. If the effective connection type is unavailable or if
// |connection_type_name| does not match to a known effective connection type,
// an unset value is returned.
NET_EXPORT base::Optional<EffectiveConnectionType>
GetEffectiveConnectionTypeForName(base::StringPiece connection_type_name);
// Returns the string equivalent of |type|. Deprecated, and replaced by
// GetNameForEffectiveConnectionType.
NET_EXPORT_PRIVATE const char* DeprecatedGetNameForEffectiveConnectionType(
EffectiveConnectionType type);
} // namespace net