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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 mainExtraCell.allowOverflow = true; | 95 mainExtraCell.allowOverflow = true; |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 // Format the table for fixed-width text. | 100 // Format the table for fixed-width text. |
101 return tablePrinter.toText(); | 101 return tablePrinter.toText(); |
102 } | 102 } |
103 | 103 |
104 function getTextForExtraParams(entry) { | 104 function getTextForExtraParams(entry) { |
| 105 // Format the extra parameters (use a custom formatter for certain types, |
| 106 // but default to displaying as JSON). |
| 107 switch (entry.type) { |
| 108 case LogEventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS: |
| 109 case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS: |
| 110 return getTextForRequestHeadersExtraParam(entry); |
| 111 |
| 112 default: |
| 113 var out = []; |
| 114 for (var k in entry.extra_parameters) { |
| 115 out.push(' --> ' + k + ' = ' + |
| 116 JSON.stringify(entry.extra_parameters[k])); |
| 117 } |
| 118 return out.join('\n'); |
| 119 } |
| 120 } |
| 121 |
| 122 function getTextForRequestHeadersExtraParam(entry) { |
| 123 var params = entry.extra_parameters; |
| 124 |
| 125 // We prepend spaces to each line to make it line up with the arrow. |
| 126 var firstLinePrefix = " --> " |
| 127 var prefix = " "; |
| 128 |
105 var out = []; | 129 var out = []; |
106 for (var k in entry.extra_parameters) { | 130 |
107 out.push(' --> ' + k + ' = ' + JSON.stringify(entry.extra_parameters[k])); | 131 // Strip the trailing CRLF that params.line contains. |
108 } | 132 var lineWithoutCRLF = params.line.replace(/\r\n$/g, ''); |
109 return out.join('\n'); | 133 out.push(firstLinePrefix + lineWithoutCRLF); |
| 134 |
| 135 // Concatenate all of the header lines. |
| 136 for (var i = 0; i < params.headers.length; ++i) |
| 137 out.push(prefix + params.headers[i]); |
| 138 |
| 139 return out.join("\n"); |
110 } | 140 } |
111 | 141 |
112 function getTextForEvent(entry) { | 142 function getTextForEvent(entry) { |
113 var text = ''; | 143 var text = ''; |
114 | 144 |
115 if (entry.isBegin()) { | 145 if (entry.isBegin()) { |
116 text = '+' + text; | 146 text = '+' + text; |
117 } else if (entry.isEnd()) { | 147 } else if (entry.isEnd()) { |
118 text = '-' + text; | 148 text = '-' + text; |
119 } else { | 149 } else { |
120 text = ' '; | 150 text = ' '; |
121 } | 151 } |
122 | 152 |
123 text += getKeyWithValue(LogEventType, entry.orig.type); | 153 text += getKeyWithValue(LogEventType, entry.orig.type); |
124 return text; | 154 return text; |
125 } | 155 } |
126 | 156 |
127 // End of anonymous namespace. | 157 // End of anonymous namespace. |
128 })(); | 158 })(); |
129 | 159 |
OLD | NEW |