OLD | NEW |
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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 var startDate = g_browser.convertTimeTicksToDate(logEntries[0].time); | 42 var startDate = g_browser.convertTimeTicksToDate(logEntries[0].time); |
43 addTextNode(nobr2, 'Start Time: ' + startDate.toLocaleString()); | 43 addTextNode(nobr2, 'Start Time: ' + startDate.toLocaleString()); |
44 | 44 |
45 var pre = addNode(div, 'pre'); | 45 var pre = addNode(div, 'pre'); |
46 addTextNode(pre, PrintSourceEntriesAsText(logEntries, false)); | 46 addTextNode(pre, PrintSourceEntriesAsText(logEntries, false)); |
47 } | 47 } |
48 | 48 |
49 function canCollapseBeginWithEnd(beginEntry) { | 49 function canCollapseBeginWithEnd(beginEntry) { |
50 return beginEntry && | 50 return beginEntry && |
51 beginEntry.isBegin() && | 51 beginEntry.isBegin() && |
| 52 !beginEntry.orig.params && |
52 beginEntry.end && | 53 beginEntry.end && |
53 beginEntry.end.index == beginEntry.index + 1 && | 54 beginEntry.end.index == beginEntry.index + 1 && |
54 (!beginEntry.orig.params || !beginEntry.end.orig.params) && | 55 !beginEntry.end.orig.params && |
55 beginEntry.orig.wasPassivelyCaptured == | 56 beginEntry.orig.wasPassivelyCaptured == |
56 beginEntry.end.orig.wasPassivelyCaptured; | 57 beginEntry.end.orig.wasPassivelyCaptured; |
57 } | 58 } |
58 | 59 |
59 PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) { | 60 PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) { |
60 var entries = LogGroupEntry.createArrayFrom(sourceEntries); | 61 var entries = LogGroupEntry.createArrayFrom(sourceEntries); |
61 if (entries.length == 0) | 62 if (entries.length == 0) |
62 return ''; | 63 return ''; |
63 | 64 |
64 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time); | 65 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time); |
65 var startTime = startDate.getTime(); | 66 var startTime = startDate.getTime(); |
66 | 67 |
67 var tablePrinter = new TablePrinter(); | 68 var tablePrinter = new TablePrinter(); |
68 | 69 |
69 for (var i = 0; i < entries.length; ++i) { | 70 for (var i = 0; i < entries.length; ++i) { |
70 var entry = entries[i]; | 71 var entry = entries[i]; |
71 | 72 |
72 // Avoid printing the END for a BEGIN that was immediately before, unless | 73 // Avoid printing the END for a BEGIN that was immediately before. |
73 // both have extra parameters. | 74 if (entry.isEnd() && canCollapseBeginWithEnd(entry.begin)) |
74 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) { | 75 continue; |
75 tablePrinter.addRow(); | |
76 | 76 |
77 // Annotate this entry with "(P)" if it was passively captured. | 77 tablePrinter.addRow(); |
78 tablePrinter.addCell(entry.orig.wasPassivelyCaptured ? '(P) ' : ''); | |
79 | 78 |
80 tablePrinter.addCell('t='); | 79 // Annotate this entry with "(P)" if it was passively captured. |
81 var date = g_browser.convertTimeTicksToDate(entry.orig.time) ; | 80 tablePrinter.addCell(entry.orig.wasPassivelyCaptured ? '(P) ' : ''); |
82 var tCell = tablePrinter.addCell(date.getTime()); | |
83 tCell.alignRight = true; | |
84 tablePrinter.addCell(' [st='); | |
85 var stCell = tablePrinter.addCell(date.getTime() - startTime); | |
86 stCell.alignRight = true; | |
87 tablePrinter.addCell('] '); | |
88 | 81 |
89 var indentationStr = makeRepeatedString(' ', entry.getDepth() * 3); | 82 tablePrinter.addCell('t='); |
90 var mainCell = | 83 var date = g_browser.convertTimeTicksToDate(entry.orig.time) ; |
91 tablePrinter.addCell(indentationStr + getTextForEvent(entry)); | 84 var tCell = tablePrinter.addCell(date.getTime()); |
92 tablePrinter.addCell(' '); | 85 tCell.alignRight = true; |
| 86 tablePrinter.addCell(' [st='); |
| 87 var stCell = tablePrinter.addCell(date.getTime() - startTime); |
| 88 stCell.alignRight = true; |
| 89 tablePrinter.addCell('] '); |
93 | 90 |
94 // Get the elapsed time. | 91 var indentationStr = makeRepeatedString(' ', entry.getDepth() * 3); |
95 if (entry.isBegin()) { | 92 var mainCell = |
96 tablePrinter.addCell('[dt='); | 93 tablePrinter.addCell(indentationStr + getTextForEvent(entry)); |
97 var dt = '?'; | 94 tablePrinter.addCell(' '); |
98 // Definite time. | |
99 if (entry.end) { | |
100 dt = entry.end.orig.time - entry.orig.time; | |
101 } | |
102 var dtCell = tablePrinter.addCell(dt); | |
103 dtCell.alignRight = true; | |
104 | 95 |
105 tablePrinter.addCell(']'); | 96 // Get the elapsed time. |
106 } else { | 97 if (entry.isBegin()) { |
107 mainCell.allowOverflow = true; | 98 tablePrinter.addCell('[dt='); |
| 99 var dt = '?'; |
| 100 // Definite time. |
| 101 if (entry.end) { |
| 102 dt = entry.end.orig.time - entry.orig.time; |
108 } | 103 } |
| 104 var dtCell = tablePrinter.addCell(dt); |
| 105 dtCell.alignRight = true; |
| 106 |
| 107 tablePrinter.addCell(']'); |
| 108 } else { |
| 109 mainCell.allowOverflow = true; |
109 } | 110 } |
110 | 111 |
111 // Output the extra parameters. | 112 // Output the extra parameters. |
112 if (entry.orig.params != undefined) { | 113 if (entry.orig.params != undefined) { |
113 // Add a continuation row for each line of text from the extra parameters. | 114 // Add a continuation row for each line of text from the extra parameters. |
114 var extraParamsText = getTextForExtraParams(entry.orig, | 115 var extraParamsText = getTextForExtraParams(entry.orig, |
115 doSecurityStripping); | 116 doSecurityStripping); |
116 var extraParamsTextLines = extraParamsText.split('\n'); | 117 var extraParamsTextLines = extraParamsText.split('\n'); |
117 | 118 |
118 for (var j = 0; j < extraParamsTextLines.length; ++j) { | 119 for (var j = 0; j < extraParamsTextLines.length; ++j) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 var result = []; | 423 var result = []; |
423 for (var i = 0; i < modes.length; ++i) | 424 for (var i = 0; i < modes.length; ++i) |
424 result.push(indentLines('(' + (i + 1) + ') ', modes[i])); | 425 result.push(indentLines('(' + (i + 1) + ') ', modes[i])); |
425 | 426 |
426 return result.join('\n'); | 427 return result.join('\n'); |
427 }; | 428 }; |
428 | 429 |
429 // End of anonymous namespace. | 430 // End of anonymous namespace. |
430 })(); | 431 })(); |
431 | 432 |
OLD | NEW |