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

Unified Diff: content/child/websocket_bridge.cc

Issue 34753008: Notify WebSocket connection failure, chromium side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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 | « content/child/websocket_bridge.h ('k') | content/child/websocket_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/websocket_bridge.cc
diff --git a/content/child/websocket_bridge.cc b/content/child/websocket_bridge.cc
index e1810dd64789802b25d4be5803eec365a576aab6..a370dac3c998519d179d5db61c1c682a76920e16 100644
--- a/content/child/websocket_bridge.cc
+++ b/content/child/websocket_bridge.cc
@@ -31,10 +31,25 @@ using WebKit::WebVector;
namespace content {
+namespace {
+
+const unsigned short kAbnormalShutdownOpCode = 1006;
+
+} // namespace
+
WebSocketBridge::WebSocketBridge()
: channel_id_(kInvalidChannelId), client_(NULL) {}
WebSocketBridge::~WebSocketBridge() {
+ if (channel_id_ != kInvalidChannelId) {
+ // The connection is abruptly disconnected by the renderer without
+ // closing handshake.
+ ChildThread::current()->Send(
+ new WebSocketMsg_DropChannel(channel_id_,
+ false,
+ kAbnormalShutdownOpCode,
+ std::string()));
+ }
Disconnect();
}
@@ -42,6 +57,7 @@ bool WebSocketBridge::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebSocketBridge, msg)
IPC_MESSAGE_HANDLER(WebSocketMsg_AddChannelResponse, DidConnect)
+ IPC_MESSAGE_HANDLER(WebSocketMsg_NotifyFailure, DidFail)
IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, DidReceiveData)
IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, DidReceiveFlowControl)
IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, DidClose)
@@ -69,6 +85,16 @@ void WebSocketBridge::DidConnect(bool fail,
// |this| can be deleted here.
}
+void WebSocketBridge::DidFail(const std::string& message) {
+ DVLOG(1) << "WebSocketBridge::DidFail(" << message << ")";
+ if (!client_)
+ return;
+
+ WebString message_to_pass = WebString::fromUTF8(message);
+ client_->didFail(this, message_to_pass);
+ // |this| can be deleted here.
+}
+
void WebSocketBridge::DidReceiveData(bool fin,
WebSocketMessageType type,
const std::vector<char>& data) {
@@ -106,9 +132,11 @@ void WebSocketBridge::DidReceiveFlowControl(int64_t quota) {
// |this| can be deleted here.
}
-void WebSocketBridge::DidClose(unsigned short code,
+void WebSocketBridge::DidClose(bool was_clean,
+ unsigned short code,
const std::string& reason) {
DVLOG(1) << "WebSocketBridge::DidClose("
+ << was_clean << ", "
<< code << ", "
<< reason << ")";
WebSocketHandleClient* client = client_;
@@ -117,7 +145,7 @@ void WebSocketBridge::DidClose(unsigned short code,
return;
WebString reason_to_pass = WebString::fromUTF8(reason);
- client->didClose(this, code, reason_to_pass);
+ client->didClose(this, was_clean, code, reason_to_pass);
// |this| can be deleted here.
}
@@ -197,8 +225,9 @@ void WebSocketBridge::close(unsigned short code,
std::string reason_to_pass = reason.utf8();
DVLOG(1) << "Bridge #" << channel_id_ << " Close("
<< code << ", " << reason_to_pass << ")";
+ // This method is for closing handshake and hence |was_clean| shall be true.
tyoshino (SeeGerritForStatus) 2013/10/23 08:28:53 NewWebSocketChannelImpl::disconnect() also uses th
yhirano 2013/10/23 08:32:55 You are right, I will fix NewWebSocketChannelImpl
yhirano 2013/10/23 09:12:59 Done at the Blink-side change. https://codereview.
ChildThread::current()->Send(
- new WebSocketMsg_DropChannel(channel_id_, code, reason_to_pass));
+ new WebSocketMsg_DropChannel(channel_id_, true, code, reason_to_pass));
}
void WebSocketBridge::Disconnect() {
« no previous file with comments | « content/child/websocket_bridge.h ('k') | content/child/websocket_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698