Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js

Issue 2562193002: Add filtering by priority in the Network filter area. (Closed)
Patch Set: Changes made according to reviewer comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Components.NetworkConditionsSelector = class { 7 Components.NetworkConditionsSelector = class {
8 /** 8 /**
9 * @param {function(!Array<!Components.NetworkConditionsGroup>):!Array<?SDK.Ne tworkManager.Conditions>} populateCallback 9 * @param {function(!Array<!Components.NetworkConditionsGroup>):!Array<?SDK.Ne tworkManager.Conditions>} populateCallback
10 * @param {function(number)} selectCallback 10 * @param {function(number)} selectCallback
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 return false; 482 return false;
483 } 483 }
484 }; 484 };
485 485
486 /** 486 /**
487 * @param {?Protocol.Network.ResourcePriority} priority 487 * @param {?Protocol.Network.ResourcePriority} priority
488 * @return {string} 488 * @return {string}
489 */ 489 */
490 Components.uiLabelForPriority = function(priority) { 490 Components.uiLabelForPriority = function(priority) {
491 var labelMap = Components.uiLabelForPriority._priorityToUILabel; 491 var labelMap = Components.uiLabelForPriority._priorityToUILabel;
492 if (!labelMap) { 492 if (!labelMap) {
allada 2016/12/17 01:20:20 Can we extract part of this function into "Compone
493 labelMap = new Map([ 493 labelMap = new Map([
494 [Protocol.Network.ResourcePriority.VeryLow, Common.UIString('Lowest')], 494 [Protocol.Network.ResourcePriority.VeryLow, Common.UIString('Lowest')],
495 [Protocol.Network.ResourcePriority.Low, Common.UIString('Low')], 495 [Protocol.Network.ResourcePriority.Low, Common.UIString('Low')],
496 [Protocol.Network.ResourcePriority.Medium, Common.UIString('Medium')], 496 [Protocol.Network.ResourcePriority.Medium, Common.UIString('Medium')],
497 [Protocol.Network.ResourcePriority.High, Common.UIString('High')], 497 [Protocol.Network.ResourcePriority.High, Common.UIString('High')],
498 [Protocol.Network.ResourcePriority.VeryHigh, Common.UIString('Highest')] 498 [Protocol.Network.ResourcePriority.VeryHigh, Common.UIString('Highest')]
499 ]); 499 ]);
500 Components.uiLabelForPriority._priorityToUILabel = labelMap; 500 Components.uiLabelForPriority._priorityToUILabel = labelMap;
501 } 501 }
502 return labelMap.get(priority) || Common.UIString('Unknown'); 502 return labelMap.get(priority) || Common.UIString('Unknown');
503 }; 503 };
504
505 /**
506 * @param {string} priorityLabel
507 * @return {string}
508 */
509 Components.priorityByUiLabel = function(priorityLabel) {
allada 2016/12/17 01:20:20 nit: lets rename to: "uiLabelToPriority"
510 var labelToPriorityMap = Components.priorityByUiLabel._uILabelToPriority;
allada 2016/12/17 01:20:20 Lets restructure this function to something like:
511 var labelMap;
512
513 if (!labelToPriorityMap) {
514 labelMap = Components.uiLabelForPriority._priorityToUILabel;
allada 2016/12/17 01:20:20 This may not be set yet.
515 labelToPriorityMap = Object.keys(Protocol.Network.ResourcePriority)
516 .reduce(((map, priority) => map.set(labelMap.get(pr iority), priority)), new Map());
Oleksii Kadurin 2016/12/13 19:43:37 * I know that such a huge indentation here looks u
517 Components.priorityByUiLabel._uILabelToPriority = labelToPriorityMap;
518 }
519
520 return labelToPriorityMap.get(priorityLabel);
521 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698