summaryrefslogtreecommitdiffstats
path: root/net/websockets
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 12:05:43 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 12:05:43 +0000
commitf7e98cae026f036fd9c94708abb5b21c3617ba56 (patch)
treed275e61c52b438e61df7fbb343879e7c91f10820 /net/websockets
parent3bb74103738112f26d73e665c590c3eb27f2538c (diff)
downloadchromium_src-f7e98cae026f036fd9c94708abb5b21c3617ba56.zip
chromium_src-f7e98cae026f036fd9c94708abb5b21c3617ba56.tar.gz
chromium_src-f7e98cae026f036fd9c94708abb5b21c3617ba56.tar.bz2
Add Net.WebSocket.ResponseCode and ErrorCodes UMA
Add histograms to record the response codes seen by all WebSocket requests, and also the error codes. This will provide more insight into the reasons for WebSocket connection failures. BUG=384273 TEST=manually tested with chrome://histograms Review URL: https://codereview.chromium.org/336753002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets')
-rw-r--r--net/websockets/websocket_basic_handshake_stream.cc10
-rw-r--r--net/websockets/websocket_stream.cc11
2 files changed, 16 insertions, 5 deletions
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc
index a4a634e..a51fee2 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -15,6 +15,7 @@
#include "base/bind.h"
#include "base/containers/hash_tables.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -552,9 +553,14 @@ void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() {
int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
DCHECK(http_response_info_);
- const HttpResponseHeaders* headers = http_response_info_->headers.get();
+ // Most net errors happen during connection, so they are not seen by this
+ // method. The histogram for error codes is created in
+ // Delegate::OnResponseStarted in websocket_stream.cc instead.
if (rv >= 0) {
- switch (headers->response_code()) {
+ const HttpResponseHeaders* headers = http_response_info_->headers.get();
+ const int response_code = headers->response_code();
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ResponseCode", response_code);
+ switch (response_code) {
case HTTP_SWITCHING_PROTOCOLS:
OnFinishOpeningHandshake();
return ValidateUpgradeResponse(headers);
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc
index 9880ea8..304edc75 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
@@ -178,14 +179,18 @@ class SSLErrorCallbacks : public WebSocketEventInterface::SSLErrorCallbacks {
};
void Delegate::OnResponseStarted(URLRequest* request) {
+ // All error codes, including OK and ABORTED, as with
+ // Net.ErrorCodesForMainFrame3
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes",
+ -request->status().error());
if (!request->status().is_success()) {
DVLOG(3) << "OnResponseStarted (request failed)";
owner_->ReportFailure();
return;
}
- DVLOG(3) << "OnResponseStarted (response code " << request->GetResponseCode()
- << ")";
- switch (request->GetResponseCode()) {
+ const int response_code = request->GetResponseCode();
+ DVLOG(3) << "OnResponseStarted (response code " << response_code << ")";
+ switch (response_code) {
case HTTP_SWITCHING_PROTOCOLS:
result_ = CONNECTED;
owner_->PerformUpgrade();