summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 10:00:53 +0000
committeryhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 10:00:53 +0000
commite778f32d900b8e13581055d13617402673dad187 (patch)
tree7819e4e68992b5974d4f208fb806edd3d7e68e62 /net
parentf9811c8c1a21feef3728c70a0607b612ce966ae7 (diff)
downloadchromium_src-e778f32d900b8e13581055d13617402673dad187.zip
chromium_src-e778f32d900b8e13581055d13617402673dad187.tar.gz
chromium_src-e778f32d900b8e13581055d13617402673dad187.tar.bz2
[WebSocket] Send a close frame when the renderer process is gone.
Renderer processes may die without clearing its |WebSocketBridge|s. It is helpful to send a close frame with code = 1001 in such a case. BUG=392534 R=ricea@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=285557 Review URL: https://codereview.chromium.org/390773002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/data/websocket/README15
-rw-r--r--net/data/websocket/connect_check.html13
-rw-r--r--net/data/websocket/count-connection_wsh.py26
-rw-r--r--net/data/websocket/count_connection.html22
-rw-r--r--net/data/websocket/counted_connection.html19
-rw-r--r--net/data/websocket/split_packet_check.html12
-rw-r--r--net/data/websocket/websocket_shared_worker.html11
-rw-r--r--net/websockets/websocket_channel.cc2
8 files changed, 90 insertions, 30 deletions
diff --git a/net/data/websocket/README b/net/data/websocket/README
index 9dab697..9282a38 100644
--- a/net/data/websocket/README
+++ b/net/data/websocket/README
@@ -19,6 +19,16 @@ Multiple tests may share one resource, or URI handler.
content::TitleWatcher.
Used by WorkerTest.WebSocketSharedWorker.
+- counted_connection.html : A page that creates a WebSocket connection
+ to count-connection_wsh.
+ This file does NOT close the established connection.
+ Used by SendCloseFrameWhenTabIsClosed.
+
+- count_connection.html : A page that creates a WebSocket connection
+ to count-connection_wsh and checks the number of open and closed
+ websocket connections to the handler.
+ Used by SendCloseFrameWhenTabIsClosed.
+
- websocket_worker_simple.js : A JavaScript runs on Workers created from the
websocket_shared_worker.html.
Used by WorkerTest.WebSocketSharedWorker.
@@ -44,6 +54,11 @@ Multiple tests may share one resource, or URI handler.
Used by WebSocketBrowserTest.WebSocketSplitSegments and
WebSocketBrowserTest.SecureWebSocketSplitRecords.
+- count-connection_wsh.py : counts the number of open and closed websocket
+ connections to this handler.
+ It sends the numbers after each connection establishment.
+ Used by SendCloseFrameWhenTabIsClosed.
+
- protocol-test_wsh.py : A WebSocket URL handler for testing outgoing opening
handshake protocol.
Used by kinds of PPAPI tests for WebSocket.
diff --git a/net/data/websocket/connect_check.html b/net/data/websocket/connect_check.html
index 4a1ca8c..8d8e815 100644
--- a/net/data/websocket/connect_check.html
+++ b/net/data/websocket/connect_check.html
@@ -3,17 +3,8 @@
<head>
<title>test ws connection</title>
<script type="text/javascript">
-
-var href = window.location.href;
-var hostBegin = href.indexOf('/') + 2;
-var hostEnd = href.lastIndexOf(':');
-var host = href.slice(hostBegin, hostEnd);
-var portBegin = hostEnd + 1;
-var portEnd = href.lastIndexOf('/');
-var port = href.slice(portBegin, portEnd);
-var scheme = href.indexOf('https') >= 0 ? 'wss' : 'ws';
-var url = scheme + '://' + host + ':' + port + '/echo-with-no-extension';
-
+var protocol = location.protocol.replace('http', 'ws');
+var url = protocol + '//' + location.host + '/echo-with-no-extension';
// Do connection test.
var ws = new WebSocket(url);
diff --git a/net/data/websocket/count-connection_wsh.py b/net/data/websocket/count-connection_wsh.py
new file mode 100644
index 0000000..aa1659c
--- /dev/null
+++ b/net/data/websocket/count-connection_wsh.py
@@ -0,0 +1,26 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+numOpenConnections = 0
+numClosedConnections = 0
+
+
+def web_socket_do_extra_handshake(request):
+ global numOpenConnections
+ numOpenConnections += 1
+
+
+def web_socket_transfer_data(request):
+ request.ws_stream.send_message('open: %d, closed: %d' %
+ (numOpenConnections, numClosedConnections), binary=False)
+ # Just waiting...
+ request.ws_stream.receive_message()
+
+
+def web_socket_passive_closing_handshake(request):
+ global numOpenConnections
+ global numClosedConnections
+ numOpenConnections -= 1
+ numClosedConnections += 1
+ return (1000, '')
diff --git a/net/data/websocket/count_connection.html b/net/data/websocket/count_connection.html
new file mode 100644
index 0000000..b523a47
--- /dev/null
+++ b/net/data/websocket/count_connection.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+<head>
+<title>Connect to a WebSocket server</title>
+<script type="text/javascript">
+var protocol = location.protocol.replace('http', 'ws');
+var url = protocol + '//' + location.host + '/count-connection';
+
+// Do connection test.
+var ws = new WebSocket(url);
+
+ws.onmessage = function(e) {
+ document.title = (e.data === 'open: 1, closed: 1' ? 'PASS' : 'FAIL');
+}
+
+ws.onclose = function() {
+ document.title = 'FAIL';
+};
+
+</script>
+</head>
+</html>
diff --git a/net/data/websocket/counted_connection.html b/net/data/websocket/counted_connection.html
new file mode 100644
index 0000000..bb53ec1
--- /dev/null
+++ b/net/data/websocket/counted_connection.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+<head>
+<title>Connect to a WebSocket server</title>
+<script type="text/javascript">
+var protocol = location.protocol.replace('http', 'ws');
+var url = protocol + '//' + location.host + '/count-connection';
+var ws = new WebSocket(url);
+
+ws.onopen = function() {
+ document.title = 'CONNECTED';
+};
+
+ws.onclose = function() {
+ document.title = 'CLOSED';
+};
+</script>
+</head>
+</html>
diff --git a/net/data/websocket/split_packet_check.html b/net/data/websocket/split_packet_check.html
index a7f4c36..6b7e980a 100644
--- a/net/data/websocket/split_packet_check.html
+++ b/net/data/websocket/split_packet_check.html
@@ -3,16 +3,8 @@
<head>
<title>test ws split packet</title>
<script type="text/javascript">
-
-var href = window.location.href;
-var hostBegin = href.indexOf('/') + 2;
-var hostEnd = href.lastIndexOf(':');
-var host = href.slice(hostBegin, hostEnd);
-var portBegin = hostEnd + 1;
-var portEnd = href.lastIndexOf('/');
-var port = href.slice(portBegin, portEnd);
-var scheme = href.indexOf('https') >= 0 ? 'wss' : 'ws';
-var url = scheme + '://' + host + ':' + port + '/close-with-split-packet';
+var protocol = location.protocol.replace('http', 'ws');
+var url = protocol + '//' + location.host + '/close-with-split-packet';
// Do connection test.
var ws = new WebSocket(url);
diff --git a/net/data/websocket/websocket_shared_worker.html b/net/data/websocket/websocket_shared_worker.html
index 7acb4ab..2156465 100644
--- a/net/data/websocket/websocket_shared_worker.html
+++ b/net/data/websocket/websocket_shared_worker.html
@@ -7,14 +7,8 @@ function log(message)
document.getElementById("result").innerHTML += message + "<br>";
}
var worker = new SharedWorker("websocket_worker_simple.js");
-var href = window.location.href;
-var hostBegin = href.indexOf("/") + 2;
-var hostEnd = href.lastIndexOf(":");
-var host = href.slice(hostBegin, hostEnd);
-var portBegin = hostEnd + 1;
-var portEnd = href.lastIndexOf("/");
-var port = href.slice(portBegin, portEnd);
-var url = "ws://" + host + ":" + port + "/echo-with-no-extension";
+var protocol = location.protocol.replace('http', 'ws');
+var url = protocol + '//' + location.host + '/echo-with-no-extension';
worker.port.onmessage = function (evt) {
log(evt.data);
if (evt.data == "DONE") {
@@ -28,4 +22,3 @@ worker.port.postMessage(url);
</script>
</body>
</html>
-
diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc
index 12f152f..767d632 100644
--- a/net/websockets/websocket_channel.cc
+++ b/net/websockets/websocket_channel.cc
@@ -465,6 +465,8 @@ void WebSocketChannel::SendFlowControl(int64 quota) {
void WebSocketChannel::StartClosingHandshake(uint16 code,
const std::string& reason) {
if (InClosingState()) {
+ // When the associated renderer process is killed while the channel is in
+ // CLOSING state we reach here.
DVLOG(1) << "StartClosingHandshake called in state " << state_
<< ". This may be a bug, or a harmless race.";
return;