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

Unified Diff: webkit/plugins/ppapi/ppb_websocket_impl.cc

Issue 8821008: WebSocket Pepper API: Add unit test to call Close() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« ppapi/tests/test_websocket.cc ('K') | « ppapi/tests/test_websocket.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_websocket_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc
index f8fb1900f8feca7b8e4882e6596addef99ca12cc..95b61df5aa5cd76b84a7af65d08190241b80f5bf 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -234,6 +234,7 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
// Install |callback|.
close_callback_ = callback;
+ // Abort ongoing connect.
if (state_ == PP_WEBSOCKETREADYSTATE_CONNECTING_DEV) {
state_ = PP_WEBSOCKETREADYSTATE_CLOSING_DEV;
PP_RunAndClearCompletionCallback(&connect_callback_, PP_ERROR_ABORTED);
@@ -242,6 +243,13 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
return PP_OK_COMPLETIONPENDING;
}
+ // Abort ongoing receive.
+ if (wait_for_receive_) {
+ wait_for_receive_ = false;
+ receive_callback_var_ = NULL;
+ PP_RunAndClearCompletionCallback(&receive_callback_, PP_ERROR_ABORTED);
+ }
+
// Close connection.
state_ = PP_WEBSOCKETREADYSTATE_CLOSING_DEV;
WebString web_reason = WebString::fromUTF8(reason_string->value());
@@ -414,6 +422,7 @@ void PPB_WebSocket_Impl::didReceiveMessageError() {
// But, if no messages are queued and ReceiveMessage() is now on going.
// We must invoke the callback with error code here.
wait_for_receive_ = false;
+ receive_callback_var_ = NULL;
PP_RunAndClearCompletionCallback(&receive_callback_, PP_ERROR_FAILED);
}
« ppapi/tests/test_websocket.cc ('K') | « ppapi/tests/test_websocket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698