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

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

Issue 10987030: Make about:net-internal's filters work a bit better. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update comments, cleanup Created 8 years, 2 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) 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 searchLogEntriesForText;
8 var proxySettingsToString; 9 var proxySettingsToString;
9 var stripCookiesAndLoginInfo; 10 var stripCookiesAndLoginInfo;
10 11
11 // Start of anonymous namespace. 12 // Start of anonymous namespace.
12 (function() { 13 (function() {
13 'use strict'; 14 'use strict';
14 15
15 function canCollapseBeginWithEnd(beginEntry) { 16 function canCollapseBeginWithEnd(beginEntry) {
16 return beginEntry && 17 return beginEntry &&
17 beginEntry.isBegin() && 18 beginEntry.isBegin() &&
18 beginEntry.end && 19 beginEntry.end &&
19 beginEntry.end.index == beginEntry.index + 1 && 20 beginEntry.end.index == beginEntry.index + 1 &&
20 (!beginEntry.orig.params || !beginEntry.end.orig.params); 21 (!beginEntry.orig.params || !beginEntry.end.orig.params);
21 } 22 }
22 23
23 /** 24 /**
24 * Adds a child pre element to the end of |parent|, and writes the 25 * Adds a child pre element to the end of |parent|, and writes the
25 * formatted contents of |logEntries| to it. 26 * formatted contents of |logEntries| to it.
26 */ 27 */
27 printLogEntriesAsText = function(logEntries, parent, privacyStripping, 28 printLogEntriesAsText = function(logEntries, parent, privacyStripping,
28 logCreationTime) { 29 logCreationTime) {
30 var tablePrinter = createTablePrinter(logEntries, privacyStripping,
31 logCreationTime);
32
33 // Format the table for fixed-width text.
34 tablePrinter.toText(0, parent);
35 }
36
37 /**
38 * Searches the table that would be output by printLogEntriesAsText for
39 * |searchString|. Seperate function since TablePrinter.toText modifies the
40 * DOM.
eroman 2012/09/25 19:59:21 Can you mention the return value?
mmenke 2012/09/25 20:12:24 Done (Also now mention that searchString much be l
41 */
42 searchLogEntriesForText = function(searchString, logEntries, privacyStripping) {
43 var tablePrinter =
44 createTablePrinter(logEntries, privacyStripping, undefined);
45
46 // Format the table for fixed-width text.
47 return tablePrinter.search(searchString);
48 }
49
50 /**
51 * Creates TablePrinters for use by the above two functions.
eroman 2012/09/25 19:59:21 nit: TablePrinters --> TablePrinter ?
mmenke 2012/09/25 20:12:24 Done.
52 */
53 function createTablePrinter(logEntries, privacyStripping, logCreationTime) {
29 var entries = LogGroupEntry.createArrayFrom(logEntries); 54 var entries = LogGroupEntry.createArrayFrom(logEntries);
30 var tablePrinter = new TablePrinter(); 55 var tablePrinter = new TablePrinter();
31 var parameterOutputter = new ParameterOutputter(tablePrinter); 56 var parameterOutputter = new ParameterOutputter(tablePrinter);
32 57
33 if (entries.length == 0) 58 if (entries.length == 0)
34 return; 59 return tablePrinter;
35 60
36 var startTime = timeutil.convertTimeTicksToTime(entries[0].orig.time); 61 var startTime = timeutil.convertTimeTicksToTime(entries[0].orig.time);
37 62
38 for (var i = 0; i < entries.length; ++i) { 63 for (var i = 0; i < entries.length; ++i) {
39 var entry = entries[i]; 64 var entry = entries[i];
40 65
41 // Avoid printing the END for a BEGIN that was immediately before, unless 66 // Avoid printing the END for a BEGIN that was immediately before, unless
42 // both have extra parameters. 67 // both have extra parameters.
43 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) { 68 if (!entry.isEnd() || !canCollapseBeginWithEnd(entry.begin)) {
44 var entryTime = timeutil.convertTimeTicksToTime(entry.orig.time); 69 var entryTime = timeutil.convertTimeTicksToTime(entry.orig.time);
(...skipping 29 matching lines...) Expand all
74 } 99 }
75 } 100 }
76 101
77 // If viewing a saved log file, add row with just the time the log was 102 // If viewing a saved log file, add row with just the time the log was
78 // created, if the event never completed. 103 // created, if the event never completed.
79 if (logCreationTime != undefined && 104 if (logCreationTime != undefined &&
80 entries[entries.length - 1].getDepth() > 0) { 105 entries[entries.length - 1].getDepth() > 0) {
81 addRowWithTime(tablePrinter, logCreationTime, startTime); 106 addRowWithTime(tablePrinter, logCreationTime, startTime);
82 } 107 }
83 108
84 // Format the table for fixed-width text. 109 return tablePrinter;
85 tablePrinter.toText(0, parent);
86 } 110 }
87 111
88 /** 112 /**
89 * Adds a new row to the given TablePrinter, and adds five cells containing 113 * Adds a new row to the given TablePrinter, and adds five cells containing
90 * information about the time an event occured. 114 * information about the time an event occured.
91 * Format is '[t=<UTC time in ms>] [st=<ms since the source started>]'. 115 * Format is '[t=<UTC time in ms>] [st=<ms since the source started>]'.
92 * @param {TablePrinter} tablePrinter The table printer to add the cells to. 116 * @param {TablePrinter} tablePrinter The table printer to add the cells to.
93 * @param {number} eventTime The time the event occured, as a UTC time in 117 * @param {number} eventTime The time the event occured, as a UTC time in
94 * milliseconds. 118 * milliseconds.
95 * @param {number} startTime The time the first event for the source occured, 119 * @param {number} startTime The time the first event for the source occured,
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 687
664 if (config.source != undefined && config.source != 'UNKNOWN') 688 if (config.source != undefined && config.source != 'UNKNOWN')
665 result.push('Source: ' + config.source); 689 result.push('Source: ' + config.source);
666 690
667 return result.join('\n'); 691 return result.join('\n');
668 }; 692 };
669 693
670 // End of anonymous namespace. 694 // End of anonymous namespace.
671 })(); 695 })();
672 696
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698