Commit d6846d18 authored by rch@chromium.org's avatar rch@chromium.org

Pretty-print QUIC CONNECTION_CLOSE and RST_STREAM error codes.

Review URL: https://chromiumcodereview.appspot.com/17333003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207773 0039d316-1c4b-4281-b951-d872f2087c98
parent c422f073
...@@ -329,6 +329,18 @@ function defaultWriteParameter(key, value, out) { ...@@ -329,6 +329,18 @@ function defaultWriteParameter(key, value, out) {
return; return;
} }
if (key == 'quic_error' && typeof value == 'number') {
var valueStr = value + ' (' + quicErrorToString(value) + ')';
out.writeArrowKeyValue(key, valueStr);
return;
}
if (key == 'quic_rst_stream_error' && typeof value == 'number') {
var valueStr = value + ' (' + quicRstStreamErrorToString(value) + ')';
out.writeArrowKeyValue(key, valueStr);
return;
}
if (key == 'load_flags' && typeof value == 'number') { if (key == 'load_flags' && typeof value == 'number') {
var valueStr = value + ' (' + getLoadFlagSymbolicString(value) + ')'; var valueStr = value + ' (' + getLoadFlagSymbolicString(value) + ')';
out.writeArrowKeyValue(key, valueStr); out.writeArrowKeyValue(key, valueStr);
......
...@@ -15,6 +15,8 @@ var EventSourceTypeNames = null; ...@@ -15,6 +15,8 @@ var EventSourceTypeNames = null;
var LogLevelType = null; var LogLevelType = null;
var ClientInfo = null; var ClientInfo = null;
var NetError = null; var NetError = null;
var QuicError = null;
var QuicRstStreamError = null;
var LoadFlag = null; var LoadFlag = null;
var LoadState = null; var LoadState = null;
var AddressFamily = null; var AddressFamily = null;
...@@ -303,6 +305,8 @@ ConstantsObserver.prototype.onReceivedConstants = function(receivedConstants) { ...@@ -303,6 +305,8 @@ ConstantsObserver.prototype.onReceivedConstants = function(receivedConstants) {
ClientInfo = Constants.clientInfo; ClientInfo = Constants.clientInfo;
LoadFlag = Constants.loadFlag; LoadFlag = Constants.loadFlag;
NetError = Constants.netError; NetError = Constants.netError;
QuicError = Constants.quicError;
QuicRstStreamError = Constants.quicRstStreamError;
AddressFamily = Constants.addressFamily; AddressFamily = Constants.addressFamily;
LoadState = Constants.loadState; LoadState = Constants.loadState;
...@@ -331,7 +335,7 @@ function areValidConstants(receivedConstants) { ...@@ -331,7 +335,7 @@ function areValidConstants(receivedConstants) {
/** /**
* Returns the name for netError. * Returns the name for netError.
* *
* Example: netErrorToString(-105) would return * Example: netErrorToString(-105) should return
* "ERR_NAME_NOT_RESOLVED". * "ERR_NAME_NOT_RESOLVED".
* @param {number} netError The net error code. * @param {number} netError The net error code.
* @return {string} The name of the given error. * @return {string} The name of the given error.
...@@ -343,6 +347,30 @@ function netErrorToString(netError) { ...@@ -343,6 +347,30 @@ function netErrorToString(netError) {
return 'ERR_' + str; return 'ERR_' + str;
} }
/**
* Returns the name for quicError.
*
* Example: quicErrorToString(25) should return
* "TIMED_OUT".
* @param {number} quicError The QUIC error code.
* @return {string} The name of the given error.
*/
function quicErrorToString(quicError) {
return getKeyWithValue(QuicError, quicError);
}
/**
* Returns the name for quicRstStreamError.
*
* Example: quicRstStreamErrorToString(3) should return
* "BAD_APPLICATION_PAYLOAD".
* @param {number} quicRstStreamError The QUIC RST_STREAM error code.
* @return {string} The name of the given error.
*/
function quicRstStreamErrorToString(quicRstStreamError) {
return getKeyWithValue(QuicRstStreamError, quicRstStreamError);
}
/** /**
* Returns a string representation of |family|. * Returns a string representation of |family|.
* @param {number} family An AddressFamily * @param {number} family An AddressFamily
......
...@@ -1929,6 +1929,36 @@ Value* NetInternalsUI::GetConstants() { ...@@ -1929,6 +1929,36 @@ Value* NetInternalsUI::GetConstants() {
constants_dict->Set("netError", dict); constants_dict->Set("netError", dict);
} }
// Add information on the relationship between QUIC error codes and their
// symbolic names.
{
DictionaryValue* dict = new DictionaryValue();
for (net::QuicErrorCode error = net::QUIC_NO_ERROR;
error < net::QUIC_LAST_ERROR;
error = static_cast<net::QuicErrorCode>(error + 1)) {
dict->SetInteger(net::QuicUtils::ErrorToString(error),
static_cast<int>(error));
}
constants_dict->Set("quicError", dict);
}
// Add information on the relationship between QUIC RST_STREAM error codes
// and their symbolic names.
{
DictionaryValue* dict = new DictionaryValue();
for (net::QuicRstStreamErrorCode error = net::QUIC_STREAM_NO_ERROR;
error < net::QUIC_STREAM_LAST_ERROR;
error = static_cast<net::QuicRstStreamErrorCode>(error + 1)) {
dict->SetInteger(net::QuicUtils::StreamErrorToString(error),
static_cast<int>(error));
}
constants_dict->Set("quicRstStreamError", dict);
}
// Information about the relationship between event phase enums and their // Information about the relationship between event phase enums and their
// symbolic names. // symbolic names.
{ {
......
...@@ -150,6 +150,7 @@ TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() { ...@@ -150,6 +150,7 @@ TEST_F('NetInternalsTest', 'netInternalsLogViewPainterPrintAsText', function() {
runTestCase(painterTestURLRequestIncompleteFromLoadedLog()); runTestCase(painterTestURLRequestIncompleteFromLoadedLog());
runTestCase(painterTestURLRequestIncompleteFromLoadedLogSingleEvent()); runTestCase(painterTestURLRequestIncompleteFromLoadedLogSingleEvent());
runTestCase(painterTestNetError()); runTestCase(painterTestNetError());
runTestCase(painterTestQuicError());
runTestCase(painterTestHexEncodedBytes()); runTestCase(painterTestHexEncodedBytes());
runTestCase(painterTestCertVerifierJob()); runTestCase(painterTestCertVerifierJob());
runTestCase(painterTestProxyConfigOneProxyAllSchemes()); runTestCase(painterTestProxyConfigOneProxyAllSchemes());
...@@ -1081,6 +1082,87 @@ function painterTestNetError() { ...@@ -1081,6 +1082,87 @@ function painterTestNetError() {
return testCase; return testCase;
} }
/**
* Tests the custom formatting of QUIC errors across several different event
* types.
*/
function painterTestQuicError() {
var testCase = {};
testCase.tickOffset = '1337911098446';
testCase.logEntries = [
{
'params': {
"host": "www.example.com"
},
'phase': EventPhase.PHASE_BEGIN,
'source': {
'id': 318,
'type': EventSourceType.URL_REQUEST
},
'time': '953675448',
'type': EventType.QUIC_SESSION
},
{
'params': {
'details': "invalid headers",
'quic_rst_stream_error':
QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD,
'stream_id': 1
},
'phase': EventPhase.PHASE_NONE,
'source': {
'id': 318,
'type': EventSourceType.URL_REQUEST
},
'time': '953675460',
'type': EventType.QUIC_SESSION_RST_STREAM_FRAME_RECEIVED
},
{
'params': {
'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT,
},
'phase': EventPhase.PHASE_NONE,
'source': {
'id': 318,
'type': EventSourceType.URL_REQUEST
},
'time': '953675705',
'type': EventType.QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED
},
{
'params': {
'quic_error': QuicError.QUIC_CONNECTION_TIMED_OUT
},
'phase': EventPhase.PHASE_END,
'source': {
'id': 318,
'type': EventSourceType.URL_REQUEST
},
'time': '953675923',
'type': EventType.QUIC_SESSION
}
];
testCase.expectedText =
't=1338864773894 [st= 0] +QUIC_SESSION [dt=475]\n' +
' --> host = "www.example.com"\n' +
't=1338864773906 [st= 12] QUIC_SESSION_RST_STREAM_FRAME_RECEIVED\n' +
' --> details = "invalid headers"\n' +
' --> quic_rst_stream_error = ' +
QuicRstStreamError.QUIC_BAD_APPLICATION_PAYLOAD + ' (' +
'QUIC_BAD_APPLICATION_PAYLOAD)\n' +
' --> stream_id = 1\n' +
't=1338864774151 [st=257] QUIC_SESSION_CONNECTION_CLOSE_FRAME_RECEIVED\n' +
' --> quic_error = ' +
QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)\n' +
't=1338864774369 [st=475] -QUIC_SESSION\n' +
' --> quic_error = ' +
QuicError.QUIC_CONNECTION_TIMED_OUT + ' (QUIC_CONNECTION_TIMED_OUT)';
return testCase;
}
/** /**
* Tests the formatting of bytes sent/received as hex + ASCII. Note that the * Tests the formatting of bytes sent/received as hex + ASCII. Note that the
* test data was truncated which is why the byte_count doesn't quite match the * test data was truncated which is why the byte_count doesn't quite match the
......
...@@ -114,7 +114,7 @@ base::Value* NetLogQuicRstStreamFrameCallback( ...@@ -114,7 +114,7 @@ base::Value* NetLogQuicRstStreamFrameCallback(
NetLog::LogLevel /* log_level */) { NetLog::LogLevel /* log_level */) {
base::DictionaryValue* dict = new base::DictionaryValue(); base::DictionaryValue* dict = new base::DictionaryValue();
dict->SetInteger("stream_id", frame->stream_id); dict->SetInteger("stream_id", frame->stream_id);
dict->SetInteger("error_code", frame->error_code); dict->SetInteger("quic_rst_stream_error", frame->error_code);
dict->SetString("details", frame->error_details); dict->SetString("details", frame->error_details);
return dict; return dict;
} }
...@@ -123,7 +123,7 @@ base::Value* NetLogQuicConnectionCloseFrameCallback( ...@@ -123,7 +123,7 @@ base::Value* NetLogQuicConnectionCloseFrameCallback(
const QuicConnectionCloseFrame* frame, const QuicConnectionCloseFrame* frame,
NetLog::LogLevel /* log_level */) { NetLog::LogLevel /* log_level */) {
base::DictionaryValue* dict = new base::DictionaryValue(); base::DictionaryValue* dict = new base::DictionaryValue();
dict->SetInteger("error_code", frame->error_code); dict->SetInteger("quic_error", frame->error_code);
dict->SetString("details", frame->error_details); dict->SetString("details", frame->error_details);
return dict; return dict;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment