Index: webkit/tools/test_shell/simple_socket_stream_bridge.cc |
diff --git a/webkit/tools/test_shell/simple_socket_stream_bridge.cc b/webkit/tools/test_shell/simple_socket_stream_bridge.cc |
index b28e1e16b5cac01dc4348d1055e73dc1c4686290..f43c87b8d74b157320d564f825e7caf17d4c4077 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 */ |