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

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

Issue 4067002: First pass at adding http/backend cache to NetLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Minor cleanup Created 10 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 | 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 &&
53 beginEntry.end && 52 beginEntry.end &&
54 beginEntry.end.index == beginEntry.index + 1 && 53 beginEntry.end.index == beginEntry.index + 1 &&
55 !beginEntry.end.orig.params && 54 (!beginEntry.orig.params || !beginEntry.end.orig.params) &&
eroman 2011/01/05 02:39:06 Can you explain this change? Won't this make it am
mmenke 2011/01/05 16:32:25 Not really (To being ambiguous, not to being able
56 beginEntry.orig.wasPassivelyCaptured == 55 beginEntry.orig.wasPassivelyCaptured ==
57 beginEntry.end.orig.wasPassivelyCaptured; 56 beginEntry.end.orig.wasPassivelyCaptured;
58 } 57 }
59 58
60 PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) { 59 PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) {
61 var entries = LogGroupEntry.createArrayFrom(sourceEntries); 60 var entries = LogGroupEntry.createArrayFrom(sourceEntries);
62 if (entries.length == 0) 61 if (entries.length == 0)
63 return ''; 62 return '';
64 63
65 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time); 64 var startDate = g_browser.convertTimeTicksToDate(entries[0].orig.time);
66 var startTime = startDate.getTime(); 65 var startTime = startDate.getTime();
67 66
68 var tablePrinter = new TablePrinter(); 67 var tablePrinter = new TablePrinter();
69 68
70 for (var i = 0; i < entries.length; ++i) { 69 for (var i = 0; i < entries.length; ++i) {
71 var entry = entries[i]; 70 var entry = entries[i];
72 71
73 // Avoid printing the END for a BEGIN that was immediately before. 72 // Avoid printing the END for a BEGIN that was immediately before, unless
74 if (entry.isEnd() && canCollapseBeginWithEnd(entry.begin)) 73 // both have extra parameters.
75 continue; 74 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) {
75 tablePrinter.addRow();
76 76
77 tablePrinter.addRow(); 77 // Annotate this entry with "(P)" if it was passively captured.
78 tablePrinter.addCell(entry.orig.wasPassivelyCaptured ? '(P) ' : '');
78 79
79 // Annotate this entry with "(P)" if it was passively captured. 80 tablePrinter.addCell('t=');
80 tablePrinter.addCell(entry.orig.wasPassivelyCaptured ? '(P) ' : ''); 81 var date = g_browser.convertTimeTicksToDate(entry.orig.time) ;
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;
eroman 2011/01/05 02:39:06 Did any of this, or is it all just indentation dif
mmenke 2011/01/05 16:32:25 Wish diff handled spaces better. No, there's abso
87 tablePrinter.addCell('] ');
81 88
82 tablePrinter.addCell('t='); 89 var indentationStr = makeRepeatedString(' ', entry.getDepth() * 3);
83 var date = g_browser.convertTimeTicksToDate(entry.orig.time) ; 90 var mainCell =
84 var tCell = tablePrinter.addCell(date.getTime()); 91 tablePrinter.addCell(indentationStr + getTextForEvent(entry));
85 tCell.alignRight = true; 92 tablePrinter.addCell(' ');
86 tablePrinter.addCell(' [st=');
87 var stCell = tablePrinter.addCell(date.getTime() - startTime);
88 stCell.alignRight = true;
89 tablePrinter.addCell('] ');
90 93
91 var indentationStr = makeRepeatedString(' ', entry.getDepth() * 3); 94 // Get the elapsed time.
92 var mainCell = 95 if (entry.isBegin()) {
93 tablePrinter.addCell(indentationStr + getTextForEvent(entry)); 96 tablePrinter.addCell('[dt=');
94 tablePrinter.addCell(' '); 97 var dt = '?';
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;
95 104
96 // Get the elapsed time. 105 tablePrinter.addCell(']');
97 if (entry.isBegin()) { 106 } else {
98 tablePrinter.addCell('[dt='); 107 mainCell.allowOverflow = true;
99 var dt = '?';
100 // Definite time.
101 if (entry.end) {
102 dt = entry.end.orig.time - entry.orig.time;
103 } 108 }
104 var dtCell = tablePrinter.addCell(dt);
105 dtCell.alignRight = true;
106
107 tablePrinter.addCell(']');
108 } else {
109 mainCell.allowOverflow = true;
110 } 109 }
111 110
112 // Output the extra parameters. 111 // Output the extra parameters.
113 if (entry.orig.params != undefined) { 112 if (entry.orig.params != undefined) {
114 // Add a continuation row for each line of text from the extra parameters. 113 // Add a continuation row for each line of text from the extra parameters.
115 var extraParamsText = getTextForExtraParams(entry.orig, 114 var extraParamsText = getTextForExtraParams(entry.orig,
116 doSecurityStripping); 115 doSecurityStripping);
117 var extraParamsTextLines = extraParamsText.split('\n'); 116 var extraParamsTextLines = extraParamsText.split('\n');
118 117
119 for (var j = 0; j < extraParamsTextLines.length; ++j) { 118 for (var j = 0; j < extraParamsTextLines.length; ++j) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 var result = []; 422 var result = [];
424 for (var i = 0; i < modes.length; ++i) 423 for (var i = 0; i < modes.length; ++i)
425 result.push(indentLines('(' + (i + 1) + ') ', modes[i])); 424 result.push(indentLines('(' + (i + 1) + ') ', modes[i]));
426 425
427 return result.join('\n'); 426 return result.join('\n');
428 }; 427 };
429 428
430 // End of anonymous namespace. 429 // End of anonymous namespace.
431 })(); 430 })();
432 431
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698