summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/net_internals/dataview.js17
-rw-r--r--chrome/browser/resources/net_internals/index.html10
-rw-r--r--chrome/browser/resources/net_internals/logviewpainter.js48
-rw-r--r--chrome/browser/resources/net_internals/main.js11
4 files changed, 82 insertions, 4 deletions
diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js
index 2138a83..38dc5a3 100644
--- a/chrome/browser/resources/net_internals/dataview.js
+++ b/chrome/browser/resources/net_internals/dataview.js
@@ -16,6 +16,7 @@ function DataView(mainBoxId,
outputTextBoxId,
exportTextButtonId,
securityStrippingCheckboxId,
+ byteLoggingCheckboxId,
passivelyCapturedCountId,
activelyCapturedCountId,
deleteAllId) {
@@ -25,6 +26,10 @@ function DataView(mainBoxId,
this.securityStrippingCheckbox_ =
document.getElementById(securityStrippingCheckboxId);
+ var byteLoggingCheckbox = document.getElementById(byteLoggingCheckboxId);
+ byteLoggingCheckbox.onclick =
+ this.onSetByteLogging_.bind(this, byteLoggingCheckbox);
+
var exportTextButton = document.getElementById(exportTextButtonId);
exportTextButton.onclick = this.onExportToText_.bind(this);
@@ -76,6 +81,18 @@ DataView.prototype.updateEventCounts_ = function() {
};
/**
+ * Depending on the value of the checkbox, enables or disables logging of
+ * actual bytes transferred.
+ */
+DataView.prototype.onSetByteLogging_ = function(byteLoggingCheckbox) {
+ if (byteLoggingCheckbox.checked) {
+ g_browser.setLogLevel(LogLevelType.LOG_ALL);
+ } else {
+ g_browser.setLogLevel(LogLevelType.LOG_ALL_BUT_BYTES);
+ }
+};
+
+/**
* If not already waiting for results from all updates, triggers all
* updates and starts waiting for them to complete.
*/
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index 483d932..d146242 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -191,9 +191,8 @@ found in the LICENSE file.
<td valign=top>
<h2>Dump data</h2>
<div style="margin: 8px">
- <p>
- <input id=securityStrippingCheckbox type=checkbox checked=yes>
- Strip private information (cookies and credentials).
+ <p><input id=securityStrippingCheckbox type=checkbox checked=yes>
+ Strip private information (cookies and credentials).
</p>
<p>
<a href="javascript:displayHelpForBugDump()">
@@ -217,7 +216,10 @@ found in the LICENSE file.
<td align=right id=activelyCapturedCount></td>
</tr>
</table>
- <input type=button value="Delete all" id=dataViewDeleteAll />
+ <p><input type=button value="Delete all" id=dataViewDeleteAll /></p>
+ <p><input id=byteLoggingCheckbox type=checkbox>
+ Log actual bytes sent/received.
+ </p>
</div>
</td>
diff --git a/chrome/browser/resources/net_internals/logviewpainter.js b/chrome/browser/resources/net_internals/logviewpainter.js
index d82a027..3d6d7e1 100644
--- a/chrome/browser/resources/net_internals/logviewpainter.js
+++ b/chrome/browser/resources/net_internals/logviewpainter.js
@@ -136,6 +136,47 @@ PrintSourceEntriesAsText = function(sourceEntries, doSecurityStripping) {
return tablePrinter.toText(0);
}
+/**
+ * |hexString| must be a string of hexadecimal characters with no whitespace,
+ * whose length is a multiple of two. Returns a string spanning multiple lines,
+ * with the hexadecimal characters from |hexString| on the left, in groups of
+ * two, and their corresponding ASCII characters on the right.
+ *
+ * |asciiCharsPerLine| specifies how many ASCII characters will be put on each
+ * line of the output string.
+ */
+function formatHexString(hexString, asciiCharsPerLine) {
+ // Number of transferred bytes in a line of output. Length of a
+ // line is roughly 4 times larger.
+ var hexCharsPerLine = 2 * asciiCharsPerLine;
+ var out = [];
+ for (var i = 0; i < hexString.length; i += hexCharsPerLine) {
+ var hexLine = '';
+ var asciiLine = '';
+ for (var j = i; j < i + hexCharsPerLine && j < hexString.length; j += 2) {
+ var hex = hexString.substr(j, 2);
+ hexLine += hex + ' ';
+ var charCode = parseInt(hex, 16);
+ // For ASCII codes 32 though 126, display the corresponding
+ // characters. Use a space for nulls, and a period for
+ // everything else.
+ if (charCode >= 0x20 && charCode <= 0x7E) {
+ asciiLine += String.fromCharCode(charCode);
+ } else if (charCode == 0x00) {
+ asciiLine += ' ';
+ } else {
+ asciiLine += '.';
+ }
+ }
+
+ // Max sure the ASCII text on last line of output lines up with previous
+ // lines.
+ hexLine += makeRepeatedString(' ', 3 * asciiCharsPerLine - hexLine.length);
+ out.push(' ' + hexLine + ' ' + asciiLine);
+ }
+ return out.join('\n');
+}
+
function getTextForExtraParams(entry, doSecurityStripping) {
// Format the extra parameters (use a custom formatter for certain types,
// but default to displaying as JSON).
@@ -160,6 +201,13 @@ function getTextForExtraParams(entry, doSecurityStripping) {
continue;
}
var value = entry.params[k];
+ // For transferred bytes, display the bytes in hex and ASCII.
+ if (k == 'hex_encoded_bytes') {
+ out.push(' --> ' + k + ' =');
+ out.push(formatHexString(value, 20));
+ continue;
+ }
+
var paramStr = ' --> ' + k + ' = ' + JSON.stringify(value);
// Append the symbolic name for certain constants. (This relies
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index 1702085..e71fade 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -9,6 +9,7 @@ var LogEventType = null;
var LogEventPhase = null;
var ClientInfo = null;
var LogSourceType = null;
+var LogLevelType = null;
var NetError = null;
var LoadFlag = null;
var AddressFamily = null;
@@ -73,6 +74,7 @@ function onLoaded() {
// captured data.
var dataView = new DataView("dataTabContent", "exportedDataText",
"exportToText", "securityStrippingCheckbox",
+ "byteLoggingCheckbox",
"passivelyCapturedCount",
"activelyCapturedCount",
"dataViewDeleteAll");
@@ -296,6 +298,10 @@ BrowserBridge.prototype.enableIPv6 = function() {
chrome.send('enableIPv6');
};
+BrowserBridge.prototype.setLogLevel = function(logLevel) {
+ chrome.send('setLogLevel', ['' + logLevel]);
+}
+
//------------------------------------------------------------------------------
// Messages received from the browser
//------------------------------------------------------------------------------
@@ -333,6 +339,11 @@ function(constantsMap) {
LogSourceType = constantsMap;
};
+BrowserBridge.prototype.receivedLogLevelConstants =
+function(constantsMap) {
+ LogLevelType = constantsMap;
+};
+
BrowserBridge.prototype.receivedLoadFlagConstants = function(constantsMap) {
LoadFlag = constantsMap;
};