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

Unified Diff: Source/modules/websockets/MainThreadWebSocketChannel.cpp

Issue 14071008: WebSocket object should fire error event when WebSocket server can't be connected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Add new layouttests into TestExceptions because it depends on chromium side patch Created 7 years, 8 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 | « Source/modules/websockets/MainThreadWebSocketChannel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/MainThreadWebSocketChannel.cpp
diff --git a/Source/modules/websockets/MainThreadWebSocketChannel.cpp b/Source/modules/websockets/MainThreadWebSocketChannel.cpp
index 27f7e51ab58b95dbf9134c052d08d0f3d8803a15..33fc1a29b5dc268a8f84a0421b18297720360835 100644
--- a/Source/modules/websockets/MainThreadWebSocketChannel.cpp
+++ b/Source/modules/websockets/MainThreadWebSocketChannel.cpp
@@ -76,6 +76,7 @@ MainThreadWebSocketChannel::MainThreadWebSocketChannel(Document* document, WebSo
, m_resumeTimer(this, &MainThreadWebSocketChannel::resumeTimerFired)
, m_suspended(false)
, m_closing(false)
+ , m_didFailOfClientAlreadyRun(false)
, m_receivedClosingHandshake(false)
, m_closingTimer(this, &MainThreadWebSocketChannel::closingTimerFired)
, m_closed(false)
@@ -207,10 +208,13 @@ void MainThreadWebSocketChannel::fail(const String& reason)
m_deflateFramer.didFail();
m_hasContinuousFrame = false;
m_continuousFrameData.clear();
- m_client->didReceiveMessageError();
-
+ if (!m_didFailOfClientAlreadyRun) {
+ m_didFailOfClientAlreadyRun = true;
+ if (m_client)
+ m_client->didReceiveMessageError();
+ }
if (m_handle && !m_closed)
- m_handle->disconnect(); // Will call didClose().
+ m_handle->disconnect(); // Will call didCloseSocketStream().
}
void MainThreadWebSocketChannel::disconnect()
@@ -321,20 +325,27 @@ void MainThreadWebSocketChannel::didUpdateBufferedAmount(SocketStreamHandle*, si
void MainThreadWebSocketChannel::didFailSocketStream(SocketStreamHandle* handle, const SocketStreamError& error)
{
LOG(Network, "MainThreadWebSocketChannel %p didFailSocketStream()", this);
- ASSERT(handle == m_handle || !m_handle);
- if (m_document) {
- String message;
- if (error.isNull())
- message = "WebSocket network error";
- else if (error.localizedDescription().isNull())
- message = "WebSocket network error: error code " + String::number(error.errorCode());
- else
- message = "WebSocket network error: " + error.localizedDescription();
- InspectorInstrumentation::didReceiveWebSocketFrameError(m_document, m_identifier, message);
- m_document->addConsoleMessage(NetworkMessageSource, ErrorMessageLevel, message);
- }
+ ASSERT_UNUSED(handle, handle == m_handle || !m_handle);
m_shouldDiscardReceivedData = true;
- handle->disconnect();
+ String message;
+ if (error.isNull())
+ message = "WebSocket network error";
+ else if (error.localizedDescription().isNull())
+ message = "WebSocket network error: error code " + String::number(error.errorCode());
+ else
+ message = "WebSocket network error: error code " + String::number(error.errorCode()) + ", " + error.localizedDescription();
+ String failingURL = error.failingURL();
+ ASSERT(failingURL.isNull() || m_handshake->url().string() == failingURL);
+ if (failingURL.isNull())
+ failingURL = m_handshake->url().string();
+ LOG(Network, "Error Message: '%s', FailURL: '%s'", message.utf8().data(), failingURL.utf8().data());
+ RefPtr<WebSocketChannel> protect(this);
+ if (m_client && !m_didFailOfClientAlreadyRun) {
+ m_didFailOfClientAlreadyRun = true;
+ m_client->didReceiveMessageError();
+ }
+ if (m_handle && !m_closed)
+ m_handle->disconnect();
}
void MainThreadWebSocketChannel::didStartLoading()
« no previous file with comments | « Source/modules/websockets/MainThreadWebSocketChannel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698