Index: third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js b/third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js |
index fc19d6e08fe92bae648728321f050f37230e72b3..6f96f8fee3283a00aaf376868669617f5fe7bb01 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js |
+++ b/third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js |
@@ -501,3 +501,21 @@ Components.uiLabelForPriority = function(priority) { |
} |
return labelMap.get(priority) || Common.UIString('Unknown'); |
}; |
+ |
+/** |
+ * @param {string} priorityLabel |
+ * @return {string} |
+ */ |
+Components.priorityByUiLabel = function(priorityLabel) { |
allada
2016/12/17 01:20:20
nit: lets rename to: "uiLabelToPriority"
|
+ var labelToPriorityMap = Components.priorityByUiLabel._uILabelToPriority; |
allada
2016/12/17 01:20:20
Lets restructure this function to something like:
|
+ var labelMap; |
+ |
+ if (!labelToPriorityMap) { |
+ labelMap = Components.uiLabelForPriority._priorityToUILabel; |
allada
2016/12/17 01:20:20
This may not be set yet.
|
+ labelToPriorityMap = Object.keys(Protocol.Network.ResourcePriority) |
+ .reduce(((map, priority) => map.set(labelMap.get(priority), priority)), new Map()); |
Oleksii Kadurin
2016/12/13 19:43:37
* I know that such a huge indentation here looks u
|
+ Components.priorityByUiLabel._uILabelToPriority = labelToPriorityMap; |
+ } |
+ |
+ return labelToPriorityMap.get(priorityLabel); |
+}; |