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

Unified Diff: webkit/tools/test_shell/simple_socket_stream_bridge.cc

Issue 10668018: Websocket should fire 'error' event if no server available (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: For reland (tyoshino) Created 7 years, 8 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 | « webkit/glue/websocketstreamhandle_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 */
« no previous file with comments | « webkit/glue/websocketstreamhandle_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698