Andrew Top | 286dd78 | 2018-10-02 16:52:45 -0700 | [diff] [blame] | 1 | // 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 Kert | f585e26 | 2020-06-08 11:42:28 -0700 | [diff] [blame] | 6 | export const CPUThrottlingRates = { |
Andrew Top | 286dd78 | 2018-10-02 16:52:45 -0700 | [diff] [blame] | 7 | NoThrottling: 1, |
| 8 | MidTierMobile: 4, |
| 9 | LowEndMobile: 6, |
| 10 | }; |
| 11 | |
Kaido Kert | f585e26 | 2020-06-08 11:42:28 -0700 | [diff] [blame] | 12 | /** @type {!MobileThrottling.Conditions} */ |
| 13 | export 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} */ |
| 21 | export 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} */ |
| 29 | export 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} */ |
| 37 | export 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} */ |
| 45 | export const CustomConditions = { |
| 46 | title: Common.UIString('Custom'), |
| 47 | description: Common.UIString('Check Network and Performance panels'), |
| 48 | }; |
| 49 | |
| 50 | /** @type {!Array.<!MobileThrottling.Conditions>} */ |
| 51 | export const mobilePresets = [MidTierMobileConditions, LowEndMobileConditions, CustomConditions]; |
| 52 | |
| 53 | /** @type {!Array.<!MobileThrottling.Conditions>} */ |
| 54 | export const advancedMobilePresets = [ |
| 55 | OfflineConditions, |
| 56 | ]; |
| 57 | |
| 58 | /** @type {!Array<!SDK.NetworkManager.Conditions>} */ |
| 59 | export const networkPresets = [ |
| 60 | SDK.NetworkManager.Fast3GConditions, |
| 61 | SDK.NetworkManager.Slow3GConditions, |
| 62 | SDK.NetworkManager.OfflineConditions, |
| 63 | ]; |
| 64 | |
| 65 | /** @type {!Array<!CPUThrottlingRates>} */ |
| 66 | export const cpuThrottlingPresets = [ |
| 67 | CPUThrottlingRates.NoThrottling, |
| 68 | CPUThrottlingRates.MidTierMobile, |
| 69 | CPUThrottlingRates.LowEndMobile, |
| 70 | ]; |
| 71 | |
| 72 | /* Legacy exported object */ |
| 73 | self.MobileThrottling = self.MobileThrottling || {}; |
| 74 | |
| 75 | /* Legacy exported object */ |
| 76 | MobileThrottling = MobileThrottling || {}; |
| 77 | |
| 78 | /** @enum {number} */ |
| 79 | MobileThrottling.CPUThrottlingRates = CPUThrottlingRates; |
| 80 | |
| 81 | MobileThrottling.NoThrottlingConditions = NoThrottlingConditions; |
| 82 | MobileThrottling.OfflineConditions = OfflineConditions; |
| 83 | MobileThrottling.LowEndMobileConditions = LowEndMobileConditions; |
| 84 | MobileThrottling.MidTierMobileConditions = MidTierMobileConditions; |
| 85 | MobileThrottling.CustomConditions = CustomConditions; |
| 86 | |
| 87 | MobileThrottling.mobilePresets = mobilePresets; |
| 88 | MobileThrottling.advancedMobilePresets = advancedMobilePresets; |
| 89 | MobileThrottling.networkPresets = networkPresets; |
| 90 | MobileThrottling.cpuThrottlingPresets = cpuThrottlingPresets; |
| 91 | |
Andrew Top | 286dd78 | 2018-10-02 16:52:45 -0700 | [diff] [blame] | 92 | /** |
| 93 | * @typedef {{ |
| 94 | * title: string, |
| 95 | * description: string, |
| 96 | * network: !SDK.NetworkManager.Conditions, |
Kaido Kert | f585e26 | 2020-06-08 11:42:28 -0700 | [diff] [blame] | 97 | * cpuThrottlingRate: !CPUThrottlingRates |
Andrew Top | 286dd78 | 2018-10-02 16:52:45 -0700 | [diff] [blame] | 98 | * }} |
| 99 | **/ |
| 100 | MobileThrottling.Conditions; |
| 101 | |
Andrew Top | 286dd78 | 2018-10-02 16:52:45 -0700 | [diff] [blame] | 102 | /** @typedef {!{title: string, items: !Array<!SDK.NetworkManager.Conditions>}} */ |
| 103 | MobileThrottling.NetworkThrottlingConditionsGroup; |
| 104 | |
| 105 | /** @typedef {!{title: string, items: !Array<!MobileThrottling.Conditions|!MobileThrottling.PlaceholderConditions>}} */ |
| 106 | MobileThrottling.MobileThrottlingConditionsGroup; |
| 107 | |
| 108 | /** @typedef {!Array<?MobileThrottling.Conditions|!MobileThrottling.PlaceholderConditions>} */ |
| 109 | MobileThrottling.ConditionsList; |
| 110 | |
Kaido Kert | f585e26 | 2020-06-08 11:42:28 -0700 | [diff] [blame] | 111 | /** |
| 112 | * @typedef {{ |
| 113 | * title: string, |
| 114 | * description: string |
| 115 | * }} |
| 116 | **/ |
| 117 | MobileThrottling.PlaceholderConditions; |