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

Side by Side Diff: chrome/browser/resources/net_internals/logviewpainter.js

Issue 1994006: Add the requests dumps to the text summary on chrome://net2#data (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 * TODO(eroman): This needs better presentation, and cleaner code. This 6 * TODO(eroman): This needs better presentation, and cleaner code. This
7 * implementation is more of a transitionary step as 7 * implementation is more of a transitionary step as
8 * the old net-internals is replaced. 8 * the old net-internals is replaced.
9 */ 9 */
10 10
11 var PaintLogView; 11 var PaintLogView;
12 var PrintSourceEntriesAsText;
12 13
13 // Start of anonymous namespace. 14 // Start of anonymous namespace.
14 (function() { 15 (function() {
15 16
16 PaintLogView = function(sourceEntries, node) { 17 PaintLogView = function(sourceEntries, node) {
17 for (var i = 0; i < sourceEntries.length; ++i) { 18 for (var i = 0; i < sourceEntries.length; ++i) {
18 if (i != 0) 19 if (i != 0)
19 addNode(node, 'hr'); 20 addNode(node, 'hr');
20 addSourceEntry_(node, sourceEntries[i]); 21 addSourceEntry_(node, sourceEntries[i]);
21 } 22 }
22 } 23 }
23 24
24 const INDENTATION_PX = 20; 25 const INDENTATION_PX = 20;
25 26
26 function addSourceEntry_(node, sourceEntry) { 27 function addSourceEntry_(node, sourceEntry) {
27 var div = addNode(node, 'div'); 28 var div = addNode(node, 'div');
28 div.className = 'logSourceEntry'; 29 div.className = 'logSourceEntry';
29 30
30 var p = addNode(div, 'p'); 31 var p = addNode(div, 'p');
31 var nobr = addNode(p, 'nobr'); 32 var nobr = addNode(p, 'nobr');
32 33
33 addTextNode(nobr, sourceEntry.getDescription()); 34 addTextNode(nobr, sourceEntry.getDescription());
34 35
35 var groupedEntries = LogGroupEntry.createArrayFrom( 36 var pre = addNode(div, 'pre');
36 sourceEntry.getLogEntries()); 37 addTextNode(pre, PrintSourceEntriesAsText(sourceEntry.getLogEntries()));
37
38 makeLoadLogTable_(div, groupedEntries);
39 } 38 }
40 39
41 function makeLoadLogTable_(node, entries) { 40 PrintSourceEntriesAsText = function(sourceEntries) {
42 var table = addNode(node, 'table'); 41 var entries = LogGroupEntry.createArrayFrom(sourceEntries);
43 var tbody = addNode(node, 'tbody'); 42
43 var tablePrinter = new TablePrinter();
44 44
45 for (var i = 0; i < entries.length; ++i) { 45 for (var i = 0; i < entries.length; ++i) {
46 var entry = entries[i]; 46 var entry = entries[i];
47 47
48 // Avoid printing the END for a BEGIN that was immediately before. 48 // Avoid printing the END for a BEGIN that was immediately before.
49 if (entry.isEnd() && entry.begin && entry.begin.index == i - 1) { 49 if (entry.isEnd() && entry.begin && entry.begin.index == i - 1) {
50 continue; 50 continue;
51 } 51 }
52 52
53 var tr = addNode(node, 'tr'); 53 tablePrinter.addRow();
54 54
55 var timeLabelCell = addNode(tr, 'td'); 55 tablePrinter.addCell('t=');
56 addTextNode(timeLabelCell, 't='); 56 var tCell = tablePrinter.addCell(entry.orig.time);
57 tCell.alignRight = true;
58 tablePrinter.addCell(' ');
57 59
58 var timeCell = addNode(tr, 'td'); 60 var indentationStr = makeRepeatedString(' ', entry.getDepth() * 3);
59 timeCell.style.textAlign = 'right'; 61 var mainCell =
60 timeCell.style.paddingRight = '5px'; 62 tablePrinter.addCell(indentationStr + getTextForEvent(entry));
61 addTextNode(timeCell, entry.orig.time); 63 tablePrinter.addCell(' ');
62
63 var mainCell = addNode(tr, 'td');
64 mainCell.style.paddingRight = '5px';
65 var dtLabelCell = addNode(tr, 'td');
66 var dtCell = addNode(tr, 'td');
67 dtCell.style.textAlign = 'right';
68
69 mainCell.style.paddingLeft = (INDENTATION_PX * entry.getDepth()) + "px";
70
71 addTextNode(mainCell, getTextForEvent(entry));
72 64
73 // Get the elapsed time. 65 // Get the elapsed time.
74 if (entry.isBegin()) { 66 if (entry.isBegin()) {
75 addTextNode(dtLabelCell, '[dt='); 67 tablePrinter.addCell('[dt=');
76 68 var dt = '?';
77 // Definite time. 69 // Definite time.
78 if (entry.end) { 70 if (entry.end) {
79 var dt = entry.end.orig.time - entry.orig.time; 71 dt = entry.end.orig.time - entry.orig.time;
80 addTextNode(dtCell, dt + ']');
81 } else {
82 addTextNode(dtCell, '?]');
83 } 72 }
73 var dtCell = tablePrinter.addCell(dt);
74 dtCell.alignRight = true;
75
76 tablePrinter.addCell(']');
84 } else { 77 } else {
85 mainCell.colSpan = '3'; 78 mainCell.allowOverflow = true;
86 } 79 }
87 80
88 // Output the extra parameters. 81 // Output the extra parameters.
89 // TODO(eroman): Do type-specific formatting.
90 if (entry.orig.extra_parameters != undefined) { 82 if (entry.orig.extra_parameters != undefined) {
91 addNode(mainCell, 'br'); 83 // Add a continuation row for each line of text from the extra parameters.
92 addTextNode(mainCell, JSON.stringify(entry.orig.extra_parameters)); 84 var extraParamsText = getTextForExtraParams(entry.orig);
85 var extraParamsTextLines = extraParamsText.split('\n');
86
87 for (var j = 0; j < extraParamsTextLines.length; ++j) {
88 tablePrinter.addRow();
89 tablePrinter.addCell(''); // No t=.
90 tablePrinter.addCell('');
91 tablePrinter.addCell(' ');
92
93 var mainExtraCell =
94 tablePrinter.addCell(indentationStr + extraParamsTextLines[j]);
95 mainExtraCell.allowOverflow = true;
96 }
93 } 97 }
94 } 98 }
99
100 // Format the table for fixed-width text.
101 return tablePrinter.toText();
102 }
103
104 function getTextForExtraParams(entry) {
105 var out = [];
106 for (var k in entry.extra_parameters) {
107 out.push(' --> ' + k + ' = ' + JSON.stringify(entry.extra_parameters[k]));
108 }
109 return out.join('\n');
95 } 110 }
96 111
97 function getTextForEvent(entry) { 112 function getTextForEvent(entry) {
98 var text = ''; 113 var text = '';
99 114
100 if (entry.isBegin()) { 115 if (entry.isBegin()) {
101 text = '+' + text; 116 text = '+' + text;
102 } else if (entry.isEnd()) { 117 } else if (entry.isEnd()) {
103 text = '-' + text; 118 text = '-' + text;
104 } else { 119 } else {
105 text = '.'; 120 text = ' ';
106 } 121 }
107 122
108 text += getKeyWithValue(LogEventType, entry.orig.type); 123 text += getKeyWithValue(LogEventType, entry.orig.type);
109 return text; 124 return text;
110 } 125 }
111 126
112 // End of anonymous namespace. 127 // End of anonymous namespace.
113 })(); 128 })();
114 129
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/index.html ('k') | chrome/browser/resources/net_internals/main.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698