summaryrefslogtreecommitdiffstats
path: root/net/websockets
diff options
context:
space:
mode:
authoryhirano <yhirano@chromium.org>2014-10-30 04:23:44 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-30 11:24:11 +0000
commit27b2b57ce6d4e03728b3addf305f00d114b32e19 (patch)
tree12f5012321c144ee31777924e9c76133361c9b63 /net/websockets
parentb3a93a6794477a270de3eadccc7d12485649b861 (diff)
downloadchromium_src-27b2b57ce6d4e03728b3addf305f00d114b32e19.zip
chromium_src-27b2b57ce6d4e03728b3addf305f00d114b32e19.tar.gz
chromium_src-27b2b57ce6d4e03728b3addf305f00d114b32e19.tar.bz2
[WebSocket] Add NOINLINE function calls to see the stack trace.
We have a crash bug related to redirection, but I couln't understand the mechanism so far. This CL adds some functions to see the actual path from the crash dump. BUG=399535 Review URL: https://codereview.chromium.org/683923003 Cr-Commit-Position: refs/heads/master@{#302069}
Diffstat (limited to 'net/websockets')
-rw-r--r--net/websockets/websocket_basic_handshake_stream.cc58
-rw-r--r--net/websockets/websocket_basic_handshake_stream.h2
2 files changed, 56 insertions, 4 deletions
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc
index 2eee942..6255d8f 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -13,6 +13,7 @@
#include "base/base64.h"
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
@@ -46,6 +47,35 @@
namespace net {
+namespace {
+
+// TODO(yhirano): Remove these functions once http://crbug.com/399535 is fixed.
+NOINLINE void RunCallbackWithOk(const CompletionCallback& callback,
+ int result) {
+ DCHECK_EQ(result, OK);
+ callback.Run(OK);
+}
+
+NOINLINE void RunCallbackWithInvalidResponseCausedByRedirect(
+ const CompletionCallback& callback,
+ int result) {
+ DCHECK_EQ(result, ERR_INVALID_RESPONSE);
+ callback.Run(ERR_INVALID_RESPONSE);
+}
+
+NOINLINE void RunCallbackWithInvalidResponse(
+ const CompletionCallback& callback,
+ int result) {
+ DCHECK_EQ(result, ERR_INVALID_RESPONSE);
+ callback.Run(ERR_INVALID_RESPONSE);
+}
+
+NOINLINE void RunCallback(const CompletionCallback& callback, int result) {
+ callback.Run(result);
+}
+
+} // namespace
+
// TODO(ricea): If more extensions are added, replace this with a more general
// mechanism.
struct WebSocketExtensionParams {
@@ -430,7 +460,8 @@ int WebSocketBasicHandshakeStream::ReadResponseHeaders(
callback));
if (rv == ERR_IO_PENDING)
return rv;
- return ValidateResponse(rv);
+ bool is_redirect = false;
+ return ValidateResponse(rv, &is_redirect);
}
int WebSocketBasicHandshakeStream::ReadResponseBody(
@@ -535,7 +566,25 @@ void WebSocketBasicHandshakeStream::SetWebSocketKeyForTesting(
void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback(
const CompletionCallback& callback,
int result) {
- callback.Run(ValidateResponse(result));
+ bool is_redirect = false;
+ int rv = ValidateResponse(result, &is_redirect);
+
+ // TODO(yhirano): Simplify this statement once http://crbug.com/399535 is
+ // fixed.
+ switch (rv) {
+ case OK:
+ RunCallbackWithOk(callback, rv);
+ break;
+ case ERR_INVALID_RESPONSE:
+ if (is_redirect)
+ RunCallbackWithInvalidResponseCausedByRedirect(callback, rv);
+ else
+ RunCallbackWithInvalidResponse(callback, rv);
+ break;
+ default:
+ RunCallback(callback, rv);
+ break;
+ }
}
void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() {
@@ -546,14 +595,17 @@ void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() {
http_response_info_->response_time);
}
-int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
+int WebSocketBasicHandshakeStream::ValidateResponse(int rv,
+ bool* is_redirect) {
DCHECK(http_response_info_);
+ *is_redirect = false;
// 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) {
const HttpResponseHeaders* headers = http_response_info_->headers.get();
const int response_code = headers->response_code();
+ *is_redirect = HttpResponseHeaders::IsRedirectResponseCode(response_code);
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ResponseCode", response_code);
switch (response_code) {
case HTTP_SWITCHING_PROTOCOLS:
diff --git a/net/websockets/websocket_basic_handshake_stream.h b/net/websockets/websocket_basic_handshake_stream.h
index 98e80a2..9508ec7 100644
--- a/net/websockets/websocket_basic_handshake_stream.h
+++ b/net/websockets/websocket_basic_handshake_stream.h
@@ -84,7 +84,7 @@ class NET_EXPORT_PRIVATE WebSocketBasicHandshakeStream
void OnFinishOpeningHandshake();
// Validates the response and sends the finished handshake event.
- int ValidateResponse(int rv);
+ int ValidateResponse(int rv, bool* is_redirect);
// Check that the headers are well-formed for a 101 response, and returns
// OK if they are, otherwise returns ERR_INVALID_RESPONSE.