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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS: | 112 case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS: |
113 return getTextForRequestHeadersExtraParam(entry); | 113 return getTextForRequestHeadersExtraParam(entry); |
114 | 114 |
115 case LogEventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS: | 115 case LogEventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS: |
116 case LogEventType.HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS: | 116 case LogEventType.HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS: |
117 return getTextForResponseHeadersExtraParam(entry); | 117 return getTextForResponseHeadersExtraParam(entry); |
118 | 118 |
119 default: | 119 default: |
120 var out = []; | 120 var out = []; |
121 for (var k in entry.params) { | 121 for (var k in entry.params) { |
122 out.push(' --> ' + k + ' = ' + | 122 var value = entry.params[k]; |
123 JSON.stringify(entry.params[k])); | 123 var paramStr = ' --> ' + k + ' = ' + JSON.stringify(value); |
| 124 |
| 125 // Append the symbolic name for certain constants. (This relies |
| 126 // on particular naming of event parameters to infer the type). |
| 127 if (typeof value == 'number') { |
| 128 if (k == 'net_error') { |
| 129 paramStr += ' (' + getNetErrorSymbolicString(value) + ')'; |
| 130 } else if (k == 'load_flags') { |
| 131 paramStr += ' (' + getLoadFlagSymbolicString(value) + ')'; |
| 132 } |
| 133 } |
| 134 |
| 135 out.push(paramStr); |
124 } | 136 } |
125 return out.join('\n'); | 137 return out.join('\n'); |
126 } | 138 } |
127 } | 139 } |
128 | 140 |
129 /** | 141 /** |
| 142 * Returns the name for netError. |
| 143 * |
| 144 * Example: getNetErrorSymbolicString(-105) would return |
| 145 * "NAME_NOT_RESOLVED". |
| 146 */ |
| 147 function getNetErrorSymbolicString(netError) { |
| 148 return getKeyWithValue(NetError, netError); |
| 149 } |
| 150 |
| 151 /** |
| 152 * Returns the set of LoadFlags that make up the integer |loadFlag|. |
| 153 * For example: getLoadFlagSymbolicString( |
| 154 */ |
| 155 function getLoadFlagSymbolicString(loadFlag) { |
| 156 // Load flag of 0 means "NORMAL". Special case this, since and-ing with |
| 157 // 0 is always going to be false. |
| 158 if (loadFlag == 0) |
| 159 return getKeyWithValue(LoadFlag, loadFlagNames); |
| 160 |
| 161 var matchingLoadFlagNames = []; |
| 162 |
| 163 for (var k in LoadFlag) { |
| 164 if (loadFlag & LoadFlag[k]) |
| 165 matchingLoadFlagNames.push(k); |
| 166 } |
| 167 |
| 168 return matchingLoadFlagNames.join(' | '); |
| 169 } |
| 170 |
| 171 /** |
130 * Indent |lines| by |start|. | 172 * Indent |lines| by |start|. |
131 * | 173 * |
132 * For example, if |start| = ' -> ' and |lines| = ['line1', 'line2', 'line3'] | 174 * For example, if |start| = ' -> ' and |lines| = ['line1', 'line2', 'line3'] |
133 * the output will be: | 175 * the output will be: |
134 * | 176 * |
135 * " -> line1\n" + | 177 * " -> line1\n" + |
136 * " line2\n" + | 178 * " line2\n" + |
137 * " line3" | 179 * " line3" |
138 */ | 180 */ |
139 function indentLines(start, lines) { | 181 function indentLines(start, lines) { |
(...skipping 28 matching lines...) Expand all Loading... |
168 text = ' '; | 210 text = ' '; |
169 } | 211 } |
170 | 212 |
171 text += getKeyWithValue(LogEventType, entry.orig.type); | 213 text += getKeyWithValue(LogEventType, entry.orig.type); |
172 return text; | 214 return text; |
173 } | 215 } |
174 | 216 |
175 // End of anonymous namespace. | 217 // End of anonymous namespace. |
176 })(); | 218 })(); |
177 | 219 |
OLD | NEW |