diff options
author | li.yin@intel.com <li.yin@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-26 14:31:18 +0000 |
---|---|---|
committer | li.yin@intel.com <li.yin@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-26 14:31:18 +0000 |
commit | 35a16a2ccaf419ec4cfd52ac46ac75874fc16acc (patch) | |
tree | 6981c70c22a8420ed8f66fefee967e27cfea97c8 /webkit/tools/test_shell/simple_socket_stream_bridge.cc | |
parent | 92e9182a996c85607d77f28bcf619d337b961c27 (diff) | |
download | chromium_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 'webkit/tools/test_shell/simple_socket_stream_bridge.cc')
-rw-r--r-- | webkit/tools/test_shell/simple_socket_stream_bridge.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/simple_socket_stream_bridge.cc b/webkit/tools/test_shell/simple_socket_stream_bridge.cc index b28e1e1..f43c87b 100644 --- a/webkit/tools/test_shell/simple_socket_stream_bridge.cc +++ b/webkit/tools/test_shell/simple_socket_stream_bridge.cc @@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/message_loop.h" +#include "base/utf_string_conversions.h" #include "googleurl/src/gurl.h" #include "net/socket_stream/socket_stream_job.h" #include "net/websockets/websocket_job.h" @@ -48,6 +49,7 @@ class WebSocketStreamHandleBridgeImpl virtual void OnReceivedData(net::SocketStream* req, const char* data, int len) OVERRIDE; virtual void OnClose(net::SocketStream* req) OVERRIDE; + virtual void OnError(const net::SocketStream* req, int error_code) OVERRIDE; private: virtual ~WebSocketStreamHandleBridgeImpl(); @@ -62,6 +64,7 @@ class WebSocketStreamHandleBridgeImpl void DoOnSentData(int amount_sent); void DoOnReceivedData(std::vector<char>* data); void DoOnClose(); + void DoOnError(int error_code, const char* error_msg); int socket_id_; MessageLoop* message_loop_; @@ -154,6 +157,15 @@ void WebSocketStreamHandleBridgeImpl::OnClose(net::SocketStream* socket) { base::Bind(&WebSocketStreamHandleBridgeImpl::DoOnClose, this)); } +void WebSocketStreamHandleBridgeImpl::OnError( + const net::SocketStream* socket, int error_code) { + base::subtle::NoBarrier_AtomicIncrement(&num_pending_tasks_, 1); + message_loop_->PostTask( + FROM_HERE, + base::Bind(&WebSocketStreamHandleBridgeImpl::DoOnError, this, + error_code, net::ErrorToString(error_code))); +} + void WebSocketStreamHandleBridgeImpl::DoConnect(const GURL& url) { DCHECK(MessageLoop::current() == g_io_thread); socket_ = net::SocketStreamJob::CreateSocketStreamJob( @@ -217,6 +229,14 @@ void WebSocketStreamHandleBridgeImpl::DoOnClose() { Release(); } +void WebSocketStreamHandleBridgeImpl::DoOnError( + int error_code, const char* error_msg) { + DCHECK(MessageLoop::current() == message_loop_); + base::subtle::NoBarrier_AtomicIncrement(&num_pending_tasks_, -1); + if (delegate_) + delegate_->DidFail(handle_, error_code, ASCIIToUTF16(error_msg)); +} + } // namespace /* static */ |