blob: 58eee69989856313d2e9e024d9641458a5fb797e [file] [log] [blame]
Andrew Top286dd782018-10-02 16:52:45 -07001// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/** @enum {number} */
Kaido Kertf585e262020-06-08 11:42:28 -07006export const CPUThrottlingRates = {
Andrew Top286dd782018-10-02 16:52:45 -07007 NoThrottling: 1,
8 MidTierMobile: 4,
9 LowEndMobile: 6,
10};
11
Kaido Kertf585e262020-06-08 11:42:28 -070012/** @type {!MobileThrottling.Conditions} */
13export const NoThrottlingConditions = {
14 title: SDK.NetworkManager.NoThrottlingConditions.title,
15 description: Common.UIString('No throttling'),
16 network: SDK.NetworkManager.NoThrottlingConditions,
17 cpuThrottlingRate: CPUThrottlingRates.NoThrottling,
18};
19
20/** @type {!MobileThrottling.Conditions} */
21export const OfflineConditions = {
22 title: SDK.NetworkManager.OfflineConditions.title,
23 description: Common.UIString('No internet connectivity'),
24 network: SDK.NetworkManager.OfflineConditions,
25 cpuThrottlingRate: CPUThrottlingRates.NoThrottling,
26};
27
28/** @type {!MobileThrottling.Conditions} */
29export const LowEndMobileConditions = {
30 title: Common.UIString('Low-end mobile'),
31 description: Common.UIString('Slow 3G & 6x CPU slowdown'),
32 network: SDK.NetworkManager.Slow3GConditions,
33 cpuThrottlingRate: CPUThrottlingRates.LowEndMobile,
34};
35
36/** @type {!MobileThrottling.Conditions} */
37export const MidTierMobileConditions = {
38 title: Common.UIString('Mid-tier mobile'),
39 description: Common.UIString('Fast 3G & 4x CPU slowdown'),
40 network: SDK.NetworkManager.Fast3GConditions,
41 cpuThrottlingRate: CPUThrottlingRates.MidTierMobile,
42};
43
44/** @type {!MobileThrottling.PlaceholderConditions} */
45export const CustomConditions = {
46 title: Common.UIString('Custom'),
47 description: Common.UIString('Check Network and Performance panels'),
48};
49
50/** @type {!Array.<!MobileThrottling.Conditions>} */
51export const mobilePresets = [MidTierMobileConditions, LowEndMobileConditions, CustomConditions];
52
53/** @type {!Array.<!MobileThrottling.Conditions>} */
54export const advancedMobilePresets = [
55 OfflineConditions,
56];
57
58/** @type {!Array<!SDK.NetworkManager.Conditions>} */
59export const networkPresets = [
60 SDK.NetworkManager.Fast3GConditions,
61 SDK.NetworkManager.Slow3GConditions,
62 SDK.NetworkManager.OfflineConditions,
63];
64
65/** @type {!Array<!CPUThrottlingRates>} */
66export const cpuThrottlingPresets = [
67 CPUThrottlingRates.NoThrottling,
68 CPUThrottlingRates.MidTierMobile,
69 CPUThrottlingRates.LowEndMobile,
70];
71
72/* Legacy exported object */
73self.MobileThrottling = self.MobileThrottling || {};
74
75/* Legacy exported object */
76MobileThrottling = MobileThrottling || {};
77
78/** @enum {number} */
79MobileThrottling.CPUThrottlingRates = CPUThrottlingRates;
80
81MobileThrottling.NoThrottlingConditions = NoThrottlingConditions;
82MobileThrottling.OfflineConditions = OfflineConditions;
83MobileThrottling.LowEndMobileConditions = LowEndMobileConditions;
84MobileThrottling.MidTierMobileConditions = MidTierMobileConditions;
85MobileThrottling.CustomConditions = CustomConditions;
86
87MobileThrottling.mobilePresets = mobilePresets;
88MobileThrottling.advancedMobilePresets = advancedMobilePresets;
89MobileThrottling.networkPresets = networkPresets;
90MobileThrottling.cpuThrottlingPresets = cpuThrottlingPresets;
91
Andrew Top286dd782018-10-02 16:52:45 -070092/**
93 * @typedef {{
94 * title: string,
95 * description: string,
96 * network: !SDK.NetworkManager.Conditions,
Kaido Kertf585e262020-06-08 11:42:28 -070097 * cpuThrottlingRate: !CPUThrottlingRates
Andrew Top286dd782018-10-02 16:52:45 -070098 * }}
99 **/
100MobileThrottling.Conditions;
101
Andrew Top286dd782018-10-02 16:52:45 -0700102/** @typedef {!{title: string, items: !Array<!SDK.NetworkManager.Conditions>}} */
103MobileThrottling.NetworkThrottlingConditionsGroup;
104
105/** @typedef {!{title: string, items: !Array<!MobileThrottling.Conditions|!MobileThrottling.PlaceholderConditions>}} */
106MobileThrottling.MobileThrottlingConditionsGroup;
107
108/** @typedef {!Array<?MobileThrottling.Conditions|!MobileThrottling.PlaceholderConditions>} */
109MobileThrottling.ConditionsList;
110
Kaido Kertf585e262020-06-08 11:42:28 -0700111/**
112 * @typedef {{
113 * title: string,
114 * description: string
115 * }}
116 **/
117MobileThrottling.PlaceholderConditions;