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

Unified Diff: chrome/browser/resources/net_internals/logviewpainter.js

Issue 2115007: Annotate load flags and net errors with their symbolic name.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address willchan's comment Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/logviewpainter.js
===================================================================
--- chrome/browser/resources/net_internals/logviewpainter.js (revision 47545)
+++ chrome/browser/resources/net_internals/logviewpainter.js (working copy)
@@ -119,14 +119,56 @@
default:
var out = [];
for (var k in entry.params) {
- out.push(' --> ' + k + ' = ' +
- JSON.stringify(entry.params[k]));
+ var value = entry.params[k];
+ var paramStr = ' --> ' + k + ' = ' + JSON.stringify(value);
+
+ // Append the symbolic name for certain constants. (This relies
+ // on particular naming of event parameters to infer the type).
+ if (typeof value == 'number') {
+ if (k == 'net_error') {
+ paramStr += ' (' + getNetErrorSymbolicString(value) + ')';
+ } else if (k == 'load_flags') {
+ paramStr += ' (' + getLoadFlagSymbolicString(value) + ')';
+ }
+ }
+
+ out.push(paramStr);
}
return out.join('\n');
}
}
/**
+ * Returns the name for netError.
+ *
+ * Example: getNetErrorSymbolicString(-105) would return
+ * "NAME_NOT_RESOLVED".
+ */
+function getNetErrorSymbolicString(netError) {
+ return getKeyWithValue(NetError, netError);
+}
+
+/**
+ * Returns the set of LoadFlags that make up the integer |loadFlag|.
+ * For example: getLoadFlagSymbolicString(
+ */
+function getLoadFlagSymbolicString(loadFlag) {
+ // Load flag of 0 means "NORMAL". Special case this, since and-ing with
+ // 0 is always going to be false.
+ if (loadFlag == 0)
+ return getKeyWithValue(LoadFlag, loadFlagNames);
+
+ var matchingLoadFlagNames = [];
+
+ for (var k in LoadFlag) {
+ if (loadFlag & LoadFlag[k])
+ matchingLoadFlagNames.push(k);
+ }
+
+ return matchingLoadFlagNames.join(' | ');
+}
+
+/**
* Indent |lines| by |start|.
*
* For example, if |start| = ' -> ' and |lines| = ['line1', 'line2', 'line3']
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698