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

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

Issue 10825116: net-internals: Display time log dump was created at end of printed logs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix comments, order Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/source_entry.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(eroman): put these methods into a namespace. 5 // TODO(eroman): put these methods into a namespace.
6 6
7 var printLogEntriesAsText; 7 var printLogEntriesAsText;
8 var proxySettingsToString; 8 var proxySettingsToString;
9 var stripCookiesAndLoginInfo; 9 var stripCookiesAndLoginInfo;
10 10
11 // Start of anonymous namespace. 11 // Start of anonymous namespace.
12 (function() { 12 (function() {
13 'use strict'; 13 'use strict';
14 14
15 function canCollapseBeginWithEnd(beginEntry) { 15 function canCollapseBeginWithEnd(beginEntry) {
16 return beginEntry && 16 return beginEntry &&
17 beginEntry.isBegin() && 17 beginEntry.isBegin() &&
18 beginEntry.end && 18 beginEntry.end &&
19 beginEntry.end.index == beginEntry.index + 1 && 19 beginEntry.end.index == beginEntry.index + 1 &&
20 (!beginEntry.orig.params || !beginEntry.end.orig.params); 20 (!beginEntry.orig.params || !beginEntry.end.orig.params);
21 } 21 }
22 22
23 /** 23 /**
24 * Adds a child pre element to the end of |parent|, and writes the 24 * Adds a child pre element to the end of |parent|, and writes the
25 * formatted contents of |logEntries| to it. 25 * formatted contents of |logEntries| to it.
26 */ 26 */
27 printLogEntriesAsText = function(logEntries, parent, enableSecurityStripping) { 27 printLogEntriesAsText = function(logEntries, parent, enableSecurityStripping,
28 logCreationTime) {
28 var entries = LogGroupEntry.createArrayFrom(logEntries); 29 var entries = LogGroupEntry.createArrayFrom(logEntries);
29 var tablePrinter = new TablePrinter(); 30 var tablePrinter = new TablePrinter();
30 var parameterOutputter = new ParameterOutputter(tablePrinter); 31 var parameterOutputter = new ParameterOutputter(tablePrinter);
31 32
32 if (entries.length == 0) 33 if (entries.length == 0)
33 return; 34 return;
34 35
35 var startDate = timeutil.convertTimeTicksToDate(entries[0].orig.time); 36 var startDate = timeutil.convertTimeTicksToDate(entries[0].orig.time);
36 var startTime = startDate.getTime(); 37 var startTime = startDate.getTime();
37 38
38 for (var i = 0; i < entries.length; ++i) { 39 for (var i = 0; i < entries.length; ++i) {
39 var entry = entries[i]; 40 var entry = entries[i];
40 41
41 // Avoid printing the END for a BEGIN that was immediately before, unless 42 // Avoid printing the END for a BEGIN that was immediately before, unless
42 // both have extra parameters. 43 // both have extra parameters.
43 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) { 44 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) {
44 tablePrinter.addRow(); 45 addRowWithTime(tablePrinter,
45 46 timeutil.convertTimeTicksToDate(entry.orig.time).getTime(),
46 tablePrinter.addCell('t='); 47 startTime);
47 var date = timeutil.convertTimeTicksToDate(entry.orig.time);
48 var tCell = tablePrinter.addCell(date.getTime());
49 tCell.alignRight = true;
50 tablePrinter.addCell(' [st=');
51 var stCell = tablePrinter.addCell(date.getTime() - startTime);
52 stCell.alignRight = true;
53 tablePrinter.addCell('] ');
54 48
55 for (var j = entry.getDepth(); j > 0; --j) 49 for (var j = entry.getDepth(); j > 0; --j)
56 tablePrinter.addCell(' '); 50 tablePrinter.addCell(' ');
57 51
58 var eventText = getTextForEvent(entry); 52 var eventText = getTextForEvent(entry);
59 // Get the elapsed time, and append it to the event text. 53 // Get the elapsed time, and append it to the event text.
60 if (entry.isBegin()) { 54 if (entry.isBegin()) {
61 var dt = '?'; 55 var dt = '?';
62 // Definite time. 56 // Definite time.
63 if (entry.end) { 57 if (entry.end) {
64 dt = entry.end.orig.time - entry.orig.time; 58 dt = entry.end.orig.time - entry.orig.time;
65 } 59 }
66 eventText += ' [dt=' + dt + ']'; 60 eventText += ' [dt=' + dt + ']';
67 } 61 }
68 62
69 var mainCell = tablePrinter.addCell(eventText); 63 var mainCell = tablePrinter.addCell(eventText);
70 mainCell.allowOverflow = true; 64 mainCell.allowOverflow = true;
71 } 65 }
72 66
73 // Output the extra parameters. 67 // Output the extra parameters.
74 if (typeof entry.orig.params == 'object') { 68 if (typeof entry.orig.params == 'object') {
75 // Those 5 skipped cells are: two for "t=", and three for "st=". 69 // Those 5 skipped cells are: two for "t=", and three for "st=".
76 tablePrinter.setNewRowCellIndent(5 + entry.getDepth()); 70 tablePrinter.setNewRowCellIndent(5 + entry.getDepth());
77 writeParameters(entry.orig, enableSecurityStripping, parameterOutputter); 71 writeParameters(entry.orig, enableSecurityStripping, parameterOutputter);
78 72
79 tablePrinter.setNewRowCellIndent(0); 73 tablePrinter.setNewRowCellIndent(0);
80 } 74 }
81 } 75 }
82 76
77 // If viewing a saved log file, add row with just the time the log was
78 // created, if the event never completed.
79 if (logCreationTime != null && entries[entries.length - 1].getDepth() > 0)
80 addRowWithTime(tablePrinter, logCreationTime, startTime);
81
83 // Format the table for fixed-width text. 82 // Format the table for fixed-width text.
84 tablePrinter.toText(0, parent); 83 tablePrinter.toText(0, parent);
85 } 84 }
86 85
87 /** 86 /**
87 * Adds a new row to the given TablePrinter, and adds five cells containing
88 * information about the time an event occured.
89 * Format is '[t=<UTC time in ms>] [st=<ms since the source started>]'.
90 * @param {TablePrinter} tablePrinter The table printer to add the cells to.
91 * @param {number} eventTime The time the event occured, as a UTC time in
92 * milliseconds.
93 * @param {number} startTime The time the first event for the source occured,
94 * as a UTC time in milliseconds.
95 */
96 function addRowWithTime(tablePrinter, eventTime, startTime) {
mmenke 2012/07/31 20:45:42 Could move this over to ParameterOutputter (writeL
97 tablePrinter.addRow();
98 tablePrinter.addCell('t=');
99 var tCell = tablePrinter.addCell(eventTime);
100 tCell.alignRight = true;
101 tablePrinter.addCell(' [st=');
102 var stCell = tablePrinter.addCell(eventTime - startTime);
103 stCell.alignRight = true;
104 tablePrinter.addCell('] ');
105 }
106
107 /**
88 * |hexString| must be a string of hexadecimal characters with no whitespace, 108 * |hexString| must be a string of hexadecimal characters with no whitespace,
89 * whose length is a multiple of two. Writes multiple lines to |out| with 109 * whose length is a multiple of two. Writes multiple lines to |out| with
90 * the hexadecimal characters from |hexString| on the left, in groups of 110 * the hexadecimal characters from |hexString| on the left, in groups of
91 * two, and their corresponding ASCII characters on the right. 111 * two, and their corresponding ASCII characters on the right.
92 * 112 *
93 * |asciiCharsPerLine| specifies how many ASCII characters will be put on each 113 * |asciiCharsPerLine| specifies how many ASCII characters will be put on each
94 * line of the output string. 114 * line of the output string.
95 */ 115 */
96 function writeHexString(hexString, asciiCharsPerLine, out) { 116 function writeHexString(hexString, asciiCharsPerLine, out) {
97 // Number of transferred bytes in a line of output. Length of a 117 // Number of transferred bytes in a line of output. Length of a
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 626
607 if (config.source != undefined && config.source != 'UNKNOWN') 627 if (config.source != undefined && config.source != 'UNKNOWN')
608 result.push('Source: ' + config.source); 628 result.push('Source: ' + config.source);
609 629
610 return result.join('\n'); 630 return result.join('\n');
611 }; 631 };
612 632
613 // End of anonymous namespace. 633 // End of anonymous namespace.
614 })(); 634 })();
615 635
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/net_internals/source_entry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698