summaryrefslogtreecommitdiffstats
path: root/net/socket_stream
diff options
context:
space:
mode:
authorli.yin@intel.com <li.yin@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 14:31:18 +0000
committerli.yin@intel.com <li.yin@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 14:31:18 +0000
commit35a16a2ccaf419ec4cfd52ac46ac75874fc16acc (patch)
tree6981c70c22a8420ed8f66fefee967e27cfea97c8 /net/socket_stream
parent92e9182a996c85607d77f28bcf619d337b961c27 (diff)
downloadchromium_src-35a16a2ccaf419ec4cfd52ac46ac75874fc16acc.zip
chromium_src-35a16a2ccaf419ec4cfd52ac46ac75874fc16acc.tar.gz
chromium_src-35a16a2ccaf419ec4cfd52ac46ac75874fc16acc.tar.bz2
Websocket should fire 'error' event if no server available
Implement OnError virtual function, when network is down, OnError can be invoked. Send error code to render process from browser process through IPC. This patch depends on Blink side patch which can be found from https://codereview.chromium.org/14071008/ BUG=128057 TEST= Review URL: https://chromiumcodereview.appspot.com/10668018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket_stream')
-rw-r--r--net/socket_stream/socket_stream.cc3
-rw-r--r--net/socket_stream/socket_stream_unittest.cc12
2 files changed, 6 insertions, 9 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc
index 84b58bc..a9df840 100644
--- a/net/socket_stream/socket_stream.cc
+++ b/net/socket_stream/socket_stream.cc
@@ -359,7 +359,8 @@ void SocketStream::Finish(int result) {
Delegate* delegate = delegate_;
delegate_ = NULL;
if (delegate) {
- delegate->OnError(this, result);
+ if (result != ERR_CONNECTION_CLOSED)
+ delegate->OnError(this, result);
if (result != ERR_PROTOCOL_SWITCHED)
delegate->OnClose(this);
}
diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc
index e98e0df..b0734fc 100644
--- a/net/socket_stream/socket_stream_unittest.cc
+++ b/net/socket_stream/socket_stream_unittest.cc
@@ -356,7 +356,7 @@ TEST_F(SocketStreamTest, CloseFlushPendingWrite) {
test_callback.WaitForResult();
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
- ASSERT_EQ(8U, events.size());
+ ASSERT_EQ(7U, events.size());
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
@@ -365,9 +365,7 @@ TEST_F(SocketStreamTest, CloseFlushPendingWrite) {
EXPECT_EQ(SocketStreamEvent::EVENT_RECEIVED_DATA, events[3].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
- EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
- EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
- EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
+ EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[6].event_type);
}
TEST_F(SocketStreamTest, ExceedMaxPendingSendAllowed) {
@@ -645,7 +643,7 @@ TEST_F(SocketStreamTest, IOPending) {
EXPECT_EQ(OK, test_callback.WaitForResult());
const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
- ASSERT_EQ(8U, events.size());
+ ASSERT_EQ(7U, events.size());
EXPECT_EQ(SocketStreamEvent::EVENT_START_OPEN_CONNECTION,
events[0].event_type);
@@ -654,9 +652,7 @@ TEST_F(SocketStreamTest, IOPending) {
EXPECT_EQ(SocketStreamEvent::EVENT_RECEIVED_DATA, events[3].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[4].event_type);
EXPECT_EQ(SocketStreamEvent::EVENT_SENT_DATA, events[5].event_type);
- EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[6].event_type);
- EXPECT_EQ(ERR_CONNECTION_CLOSED, events[6].error_code);
- EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[7].event_type);
+ EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[6].event_type);
}
TEST_F(SocketStreamTest, SwitchToSpdy) {