| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @param {!Protocol.Network.ResourcePriority} priority | 6 * @param {!Protocol.Network.ResourcePriority} priority |
| 7 * @return {string} | 7 * @return {string} |
| 8 */ | 8 */ |
| 9 NetworkConditions.uiLabelForPriority = function(priority) { | 9 NetworkPriorities.uiLabelForPriority = function(priority) { |
| 10 var map = NetworkConditions.priorityUiLabelMap(); | 10 var map = NetworkPriorities.priorityUiLabelMap(); |
| 11 return map.get(priority) || ''; | 11 return map.get(priority) || ''; |
| 12 }; | 12 }; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * @param {string} priorityLabel | 15 * @param {string} priorityLabel |
| 16 * @return {string} | 16 * @return {string} |
| 17 */ | 17 */ |
| 18 NetworkConditions.uiLabelToPriority = function(priorityLabel) { | 18 NetworkPriorities.uiLabelToPriority = function(priorityLabel) { |
| 19 /** @type {!Map<string, !Protocol.Network.ResourcePriority>} */ | 19 /** @type {!Map<string, !Protocol.Network.ResourcePriority>} */ |
| 20 var labelToPriorityMap = NetworkConditions.uiLabelToPriority._uiLabelToPriorit
yMap; | 20 var labelToPriorityMap = NetworkPriorities.uiLabelToPriority._uiLabelToPriorit
yMap; |
| 21 | 21 |
| 22 if (labelToPriorityMap) | 22 if (labelToPriorityMap) |
| 23 return labelToPriorityMap.get(priorityLabel); | 23 return labelToPriorityMap.get(priorityLabel); |
| 24 | 24 |
| 25 labelToPriorityMap = new Map(); | 25 labelToPriorityMap = new Map(); |
| 26 NetworkConditions.priorityUiLabelMap().forEach((value, key) => labelToPriority
Map.set(value, key)); | 26 NetworkPriorities.priorityUiLabelMap().forEach((value, key) => labelToPriority
Map.set(value, key)); |
| 27 NetworkConditions.uiLabelToPriority._uiLabelToPriorityMap = labelToPriorityMap
; | 27 NetworkPriorities.uiLabelToPriority._uiLabelToPriorityMap = labelToPriorityMap
; |
| 28 return labelToPriorityMap.get(priorityLabel) || ''; | 28 return labelToPriorityMap.get(priorityLabel) || ''; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @return {!Map<!Protocol.Network.ResourcePriority, string>} | 32 * @return {!Map<!Protocol.Network.ResourcePriority, string>} |
| 33 */ | 33 */ |
| 34 NetworkConditions.priorityUiLabelMap = function() { | 34 NetworkPriorities.priorityUiLabelMap = function() { |
| 35 /** @type {!Map<!Protocol.Network.ResourcePriority, string>} */ | 35 /** @type {!Map<!Protocol.Network.ResourcePriority, string>} */ |
| 36 var map = NetworkConditions.priorityUiLabelMap._priorityUiLabelMap; | 36 var map = NetworkPriorities.priorityUiLabelMap._priorityUiLabelMap; |
| 37 | 37 |
| 38 if (map) | 38 if (map) |
| 39 return map; | 39 return map; |
| 40 | 40 |
| 41 map = new Map(); | 41 map = new Map(); |
| 42 map.set(Protocol.Network.ResourcePriority.VeryLow, Common.UIString('Lowest')); | 42 map.set(Protocol.Network.ResourcePriority.VeryLow, Common.UIString('Lowest')); |
| 43 map.set(Protocol.Network.ResourcePriority.Low, Common.UIString('Low')); | 43 map.set(Protocol.Network.ResourcePriority.Low, Common.UIString('Low')); |
| 44 map.set(Protocol.Network.ResourcePriority.Medium, Common.UIString('Medium')); | 44 map.set(Protocol.Network.ResourcePriority.Medium, Common.UIString('Medium')); |
| 45 map.set(Protocol.Network.ResourcePriority.High, Common.UIString('High')); | 45 map.set(Protocol.Network.ResourcePriority.High, Common.UIString('High')); |
| 46 map.set(Protocol.Network.ResourcePriority.VeryHigh, Common.UIString('Highest')
); | 46 map.set(Protocol.Network.ResourcePriority.VeryHigh, Common.UIString('Highest')
); |
| 47 NetworkConditions.priorityUiLabelMap._priorityUiLabelMap = map; | 47 NetworkPriorities.priorityUiLabelMap._priorityUiLabelMap = map; |
| 48 | 48 |
| 49 return map; | 49 return map; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * @return {!Map<!Protocol.Network.ResourcePriority, number>} | 53 * @return {!Map<!Protocol.Network.ResourcePriority, number>} |
| 54 */ | 54 */ |
| 55 NetworkConditions.prioritySymbolToNumericMap = function() { | 55 NetworkPriorities.prioritySymbolToNumericMap = function() { |
| 56 /** @type {!Map<!Protocol.Network.ResourcePriority, number>} */ | 56 /** @type {!Map<!Protocol.Network.ResourcePriority, number>} */ |
| 57 var priorityMap = NetworkConditions.prioritySymbolToNumericMap._symbolicToNume
ricPriorityMap; | 57 var priorityMap = NetworkPriorities.prioritySymbolToNumericMap._symbolicToNume
ricPriorityMap; |
| 58 | 58 |
| 59 if (priorityMap) | 59 if (priorityMap) |
| 60 return priorityMap; | 60 return priorityMap; |
| 61 | 61 |
| 62 priorityMap = new Map(); | 62 priorityMap = new Map(); |
| 63 priorityMap.set(Protocol.Network.ResourcePriority.VeryLow, 1); | 63 priorityMap.set(Protocol.Network.ResourcePriority.VeryLow, 1); |
| 64 priorityMap.set(Protocol.Network.ResourcePriority.Low, 2); | 64 priorityMap.set(Protocol.Network.ResourcePriority.Low, 2); |
| 65 priorityMap.set(Protocol.Network.ResourcePriority.Medium, 3); | 65 priorityMap.set(Protocol.Network.ResourcePriority.Medium, 3); |
| 66 priorityMap.set(Protocol.Network.ResourcePriority.High, 4); | 66 priorityMap.set(Protocol.Network.ResourcePriority.High, 4); |
| 67 priorityMap.set(Protocol.Network.ResourcePriority.VeryHigh, 5); | 67 priorityMap.set(Protocol.Network.ResourcePriority.VeryHigh, 5); |
| 68 NetworkConditions.prioritySymbolToNumericMap._symbolicToNumericPriorityMap = p
riorityMap; | 68 NetworkPriorities.prioritySymbolToNumericMap._symbolicToNumericPriorityMap = p
riorityMap; |
| 69 | 69 |
| 70 return priorityMap; | 70 return priorityMap; |
| 71 }; | 71 }; |
| OLD | NEW |