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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js

Issue 2886393003: DevTools: Use badges to render products in timeline details. (Closed)
Patch Set: Created 3 years, 7 months 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 break; 902 break;
903 903
904 default: 904 default:
905 var detailsNode = 905 var detailsNode =
906 Timeline.TimelineUIUtils.buildDetailsNodeForTraceEvent(event, model. targetByEvent(event), linkifier); 906 Timeline.TimelineUIUtils.buildDetailsNodeForTraceEvent(event, model. targetByEvent(event), linkifier);
907 if (detailsNode) 907 if (detailsNode)
908 contentHelper.appendElementRow(Common.UIString('Details'), detailsNode ); 908 contentHelper.appendElementRow(Common.UIString('Details'), detailsNode );
909 break; 909 break;
910 } 910 }
911 911
912 await Timeline.TimelineUIUtils._maybeAppendProductToDetails(contentHelper, u rl || eventData && eventData['url']); 912 Timeline.TimelineUIUtils._maybeAppendProductToDetails(contentHelper, url || eventData && eventData['url']);
913 913
914 if (timelineData.timeWaitingForMainThread) { 914 if (timelineData.timeWaitingForMainThread) {
915 contentHelper.appendTextRow( 915 contentHelper.appendTextRow(
916 Common.UIString('Time Waiting for Main Thread'), 916 Common.UIString('Time Waiting for Main Thread'),
917 Number.millisToString(timelineData.timeWaitingForMainThread, true)); 917 Number.millisToString(timelineData.timeWaitingForMainThread, true));
918 } 918 }
919 919
920 var relatedNode = relatedNodesMap && relatedNodesMap.get(timelineData.backen dNodeId); 920 var relatedNode = relatedNodesMap && relatedNodesMap.get(timelineData.backen dNodeId);
921 if (relatedNode) { 921 if (relatedNode) {
922 contentHelper.appendElementRow( 922 contentHelper.appendElementRow(
(...skipping 18 matching lines...) Expand all
941 stats, Timeline.TimelineUIUtils.eventStyle(event).category, event.self Time); 941 stats, Timeline.TimelineUIUtils.eventStyle(event).category, event.self Time);
942 contentHelper.appendElementRow('', pieChart); 942 contentHelper.appendElementRow('', pieChart);
943 } 943 }
944 944
945 return contentHelper.fragment; 945 return contentHelper.fragment;
946 } 946 }
947 947
948 /** 948 /**
949 * @param {!Timeline.TimelineDetailsContentHelper} contentHelper 949 * @param {!Timeline.TimelineDetailsContentHelper} contentHelper
950 * @param {?string} url 950 * @param {?string} url
951 * @return {!Promise}
952 */ 951 */
953 static async _maybeAppendProductToDetails(contentHelper, url) { 952 static _maybeAppendProductToDetails(contentHelper, url) {
954 var parsedURL = url && url.asParsedURL(); 953 var parsedURL = url ? url.asParsedURL() : null;
955 if (!parsedURL) 954 if (!parsedURL)
956 return; 955 return;
957 var registry = await ProductRegistry.instance(); 956 var badgePool = new ProductRegistry.BadgePool();
pfeldman 2017/05/18 20:18:34 Pool is a pool for a reason, you need to reset it
alph 2017/05/18 22:56:02 Done.
958 var name = registry.nameForUrl(parsedURL); 957 contentHelper.appendElementRow('', badgePool.badgeForURL(parsedURL, true));
959 if (name)
960 contentHelper.appendTextRow(Common.UIString('Product'), name);
961 } 958 }
962 959
963 /** 960 /**
964 * @param {!TimelineModel.TimelineModel} model 961 * @param {!TimelineModel.TimelineModel} model
965 * @param {number} startTime 962 * @param {number} startTime
966 * @param {number} endTime 963 * @param {number} endTime
967 * @return {!DocumentFragment} 964 * @return {!DocumentFragment}
968 */ 965 */
969 static buildRangeStats(model, startTime, endTime) { 966 static buildRangeStats(model, startTime, endTime) {
970 var aggregatedStats = Timeline.TimelineUIUtils.statsForTimeRange(model, star tTime, endTime); 967 var aggregatedStats = Timeline.TimelineUIUtils.statsForTimeRange(model, star tTime, endTime);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 static async buildNetworkRequestDetails(request, model, linkifier) { 1099 static async buildNetworkRequestDetails(request, model, linkifier) {
1103 const target = model.targetByEvent(request.children[0]); 1100 const target = model.targetByEvent(request.children[0]);
1104 const contentHelper = new Timeline.TimelineDetailsContentHelper(target, link ifier); 1101 const contentHelper = new Timeline.TimelineDetailsContentHelper(target, link ifier);
1105 const category = Timeline.TimelineUIUtils.networkRequestCategory(request); 1102 const category = Timeline.TimelineUIUtils.networkRequestCategory(request);
1106 const color = Timeline.TimelineUIUtils.networkCategoryColor(category); 1103 const color = Timeline.TimelineUIUtils.networkCategoryColor(category);
1107 contentHelper.addSection(Common.UIString('Network request'), color); 1104 contentHelper.addSection(Common.UIString('Network request'), color);
1108 1105
1109 const duration = request.endTime - (request.startTime || -Infinity); 1106 const duration = request.endTime - (request.startTime || -Infinity);
1110 if (request.url) 1107 if (request.url)
1111 contentHelper.appendElementRow(Common.UIString('URL'), Components.Linkifie r.linkifyURL(request.url)); 1108 contentHelper.appendElementRow(Common.UIString('URL'), Components.Linkifie r.linkifyURL(request.url));
1112 await Timeline.TimelineUIUtils._maybeAppendProductToDetails(contentHelper, r equest.url); 1109 Timeline.TimelineUIUtils._maybeAppendProductToDetails(contentHelper, request .url);
1113 if (isFinite(duration)) 1110 if (isFinite(duration))
1114 contentHelper.appendTextRow(Common.UIString('Duration'), Number.millisToSt ring(duration, true)); 1111 contentHelper.appendTextRow(Common.UIString('Duration'), Number.millisToSt ring(duration, true));
1115 if (request.requestMethod) 1112 if (request.requestMethod)
1116 contentHelper.appendTextRow(Common.UIString('Request Method'), request.req uestMethod); 1113 contentHelper.appendTextRow(Common.UIString('Request Method'), request.req uestMethod);
1117 if (typeof request.priority === 'string') { 1114 if (typeof request.priority === 'string') {
1118 const priority = 1115 const priority =
1119 NetworkConditions.uiLabelForPriority(/** @type {!Protocol.Network.Reso urcePriority} */ (request.priority)); 1116 NetworkConditions.uiLabelForPriority(/** @type {!Protocol.Network.Reso urcePriority} */ (request.priority));
1120 contentHelper.appendTextRow(Common.UIString('Priority'), priority); 1117 contentHelper.appendTextRow(Common.UIString('Priority'), priority);
1121 } 1118 }
1122 if (request.mimeType) 1119 if (request.mimeType)
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 * @param {string=} warningType 2282 * @param {string=} warningType
2286 */ 2283 */
2287 appendWarningRow(event, warningType) { 2284 appendWarningRow(event, warningType) {
2288 var warning = Timeline.TimelineUIUtils.eventWarning(event, warningType); 2285 var warning = Timeline.TimelineUIUtils.eventWarning(event, warningType);
2289 if (warning) 2286 if (warning)
2290 this.appendElementRow(Common.UIString('Warning'), warning, true); 2287 this.appendElementRow(Common.UIString('Warning'), warning, true);
2291 } 2288 }
2292 }; 2289 };
2293 2290
2294 Timeline.TimelineUIUtils._categoryBreakdownCacheSymbol = Symbol('categoryBreakdo wnCache'); 2291 Timeline.TimelineUIUtils._categoryBreakdownCacheSymbol = Symbol('categoryBreakdo wnCache');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698