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

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

Issue 1984103004: DevTools: Add initiator field to timeline network events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update the test Created 4 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 var title = WebInspector.TimelineUIUtils.eventStyle(event).title; 249 var title = WebInspector.TimelineUIUtils.eventStyle(event).title;
250 if (event.hasCategory(WebInspector.TimelineModel.Category.Console)) 250 if (event.hasCategory(WebInspector.TimelineModel.Category.Console))
251 return title; 251 return title;
252 if (event.name === WebInspector.TimelineModel.RecordType.TimeStamp) 252 if (event.name === WebInspector.TimelineModel.RecordType.TimeStamp)
253 return WebInspector.UIString("%s: %s", title, event.args["data"]["messag e"]); 253 return WebInspector.UIString("%s: %s", title, event.args["data"]["messag e"]);
254 if (event.name === WebInspector.TimelineModel.RecordType.Animation && event. args["data"] && event.args["data"]["name"]) 254 if (event.name === WebInspector.TimelineModel.RecordType.Animation && event. args["data"] && event.args["data"]["name"])
255 return WebInspector.UIString("%s: %s", title, event.args["data"]["name"] ); 255 return WebInspector.UIString("%s: %s", title, event.args["data"]["name"] );
256 return title; 256 return title;
257 } 257 }
258 258
259 /**
260 * @param {!WebInspector.TracingModel.Event} event
261 * @return {?string}
262 */
263 WebInspector.TimelineUIUtils.eventURL = function(event)
264 {
265 if (event.url)
266 return event.url;
267 var data = event.args["data"] || event.args["beginData"];
268 return data && data.url || null;
269 }
259 270
260 /** 271 /**
261 * !Map<!WebInspector.TimelineIRModel.Phases, !{color: string, label: string}> 272 * !Map<!WebInspector.TimelineIRModel.Phases, !{color: string, label: string}>
262 */ 273 */
263 WebInspector.TimelineUIUtils._interactionPhaseStyles = function() 274 WebInspector.TimelineUIUtils._interactionPhaseStyles = function()
264 { 275 {
265 var map = WebInspector.TimelineUIUtils._interactionPhaseStylesMap; 276 var map = WebInspector.TimelineUIUtils._interactionPhaseStylesMap;
266 if (!map) { 277 if (!map) {
267 map = new Map([ 278 map = new Map([
268 [WebInspector.TimelineIRModel.Phases.Idle, {color: "white", label: " Idle"}], 279 [WebInspector.TimelineIRModel.Phases.Idle, {color: "white", label: " Idle"}],
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 childrenTime += Math.min(endTime, child.endTime()) - Math.max(startTime, child.startTime()); 979 childrenTime += Math.min(endTime, child.endTime()) - Math.max(startTime, child.startTime());
969 WebInspector.TimelineUIUtils._collectAggregatedStatsForRecord(child, sta rtTime, endTime, aggregatedStats); 980 WebInspector.TimelineUIUtils._collectAggregatedStatsForRecord(child, sta rtTime, endTime, aggregatedStats);
970 } 981 }
971 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(record).na me; 982 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(record).na me;
972 var ownTime = Math.min(endTime, record.endTime()) - Math.max(startTime, reco rd.startTime()) - childrenTime; 983 var ownTime = Math.min(endTime, record.endTime()) - Math.max(startTime, reco rd.startTime()) - childrenTime;
973 aggregatedStats[categoryName] = (aggregatedStats[categoryName] || 0) + ownTi me; 984 aggregatedStats[categoryName] = (aggregatedStats[categoryName] || 0) + ownTi me;
974 } 985 }
975 986
976 /** 987 /**
977 * @param {!WebInspector.TimelineModel.NetworkRequest} request 988 * @param {!WebInspector.TimelineModel.NetworkRequest} request
978 * @return {!Array<!{title: string, value: (string|!Element)}>}
979 */
980 WebInspector.TimelineUIUtils.buildNetworkRequestInfo = function(request)
981 {
982 var duration = request.endTime - (request.startTime || -Infinity);
983 var items = [];
984 if (request.url)
985 items.push({ title: WebInspector.UIString("URL"), value: WebInspector.li nkifyURLAsNode(request.url) });
986 if (isFinite(duration))
987 items.push({ title: WebInspector.UIString("Duration"), value: Number.mil lisToString(duration, true) });
988 if (request.requestMethod)
989 items.push({ title: WebInspector.UIString("Request Method"), value: requ est.requestMethod });
990 if (typeof request.priority === "string") {
991 var priority = WebInspector.uiLabelForPriority(/** @type {!NetworkAgent. ResourcePriority} */ (request.priority));
992 items.push({ title: WebInspector.UIString("Priority"), value: priority } );
993 }
994 if (request.mimeType)
995 items.push({ title: WebInspector.UIString("Mime Type"), value: request.m imeType });
996 return items;
997 }
998
999 /**
1000 * @param {!WebInspector.TimelineModel.NetworkRequest} request
1001 * @param {!WebInspector.TimelineModel} model 989 * @param {!WebInspector.TimelineModel} model
1002 * @param {!WebInspector.Linkifier} linkifier 990 * @param {!WebInspector.Linkifier} linkifier
1003 * @return {!Promise<!DocumentFragment>} 991 * @return {!Promise<!DocumentFragment>}
1004 */ 992 */
1005 WebInspector.TimelineUIUtils.buildNetworkRequestDetails = function(request, mode l, linkifier) 993 WebInspector.TimelineUIUtils.buildNetworkRequestDetails = function(request, mode l, linkifier)
1006 { 994 {
1007 var target = model.target(); 995 var target = model.target();
1008 var contentHelper = new WebInspector.TimelineDetailsContentHelper(target, li nkifier); 996 var contentHelper = new WebInspector.TimelineDetailsContentHelper(target, li nkifier);
1009 997
1010 var info = WebInspector.TimelineUIUtils.buildNetworkRequestInfo(request); 998 var duration = request.endTime - (request.startTime || -Infinity);
1011 for (var item of info) { 999 var items = [];
1012 if (typeof item.value === "string") 1000 if (request.url)
1013 contentHelper.appendTextRow(item.title, item.value); 1001 contentHelper.appendElementRow(WebInspector.UIString("URL"), WebInspecto r.linkifyURLAsNode(request.url));
1014 else 1002 if (isFinite(duration))
1015 contentHelper.appendElementRow(item.title, item.value); 1003 contentHelper.appendTextRow(WebInspector.UIString("Duration"), Number.mi llisToString(duration, true));
1004 if (request.requestMethod)
1005 contentHelper.appendTextRow(WebInspector.UIString("Request Method"), req uest.requestMethod);
1006 if (typeof request.priority === "string") {
1007 var priority = WebInspector.uiLabelForPriority(/** @type {!NetworkAgent. ResourcePriority} */ (request.priority));
1008 contentHelper.appendTextRow(WebInspector.UIString("Priority"), priority) ;
1009 }
1010 if (request.mimeType)
1011 contentHelper.appendTextRow(WebInspector.UIString("Mime Type"), request. mimeType);
1012
1013 var title = WebInspector.UIString("Initiator");
1014 var sendRequest = request.children[0];
1015 var topFrame = WebInspector.TimelineUIUtils.topStackFrame(sendRequest);
1016 if (topFrame) {
1017 contentHelper.appendElementRow(title, linkifier.linkifyConsoleCallFrame( target, topFrame));
1018 } else if (sendRequest.initiator) {
1019 var initiatorURL = WebInspector.TimelineUIUtils.eventURL(sendRequest.ini tiator);
1020 if (initiatorURL)
1021 contentHelper.appendElementRow(title, linkifier.linkifyScriptLocatio n(target, null, initiatorURL, 0));
1016 } 1022 }
1017 1023
1018 /** 1024 /**
1019 * @param {function(?Element)} fulfill 1025 * @param {function(?Element)} fulfill
1020 */ 1026 */
1021 function action(fulfill) 1027 function action(fulfill)
1022 { 1028 {
1023 WebInspector.DOMPresentationUtils.buildImagePreviewContents(/** @type {! WebInspector.Target} */(target), request.url, false, saveImage); 1029 WebInspector.DOMPresentationUtils.buildImagePreviewContents(/** @type {! WebInspector.Target} */(target), request.url, false, saveImage);
1024 /** 1030 /**
1025 * @param {!Element=} element 1031 * @param {!Element=} element
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 case warnings.V8Deopt: 2163 case warnings.V8Deopt:
2158 span.appendChild(WebInspector.linkifyURLAsNode("https://github.com/Googl eChrome/devtools-docs/issues/53", 2164 span.appendChild(WebInspector.linkifyURLAsNode("https://github.com/Googl eChrome/devtools-docs/issues/53",
2159 WebInspector.UIString("Not optimized"), undefined, true)); 2165 WebInspector.UIString("Not optimized"), undefined, true));
2160 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"])); 2166 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"]));
2161 break; 2167 break;
2162 default: 2168 default:
2163 console.assert(false, "Unhandled TimelineModel.WarningType"); 2169 console.assert(false, "Unhandled TimelineModel.WarningType");
2164 } 2170 }
2165 return span; 2171 return span;
2166 } 2172 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698