summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 11:39:07 +0000
committertoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 11:39:07 +0000
commit9c8b2fd3e1451243ef8e1b6fbe8f7325b7566a3c (patch)
treea2c843b405f0bb52b859f71dbaf2f88c8d5cf43a
parent6a6d0edd5ffcd8eb6b16be2376e2aba00cb961aa (diff)
downloadchromium_src-9c8b2fd3e1451243ef8e1b6fbe8f7325b7566a3c.zip
chromium_src-9c8b2fd3e1451243ef8e1b6fbe8f7325b7566a3c.tar.gz
chromium_src-9c8b2fd3e1451243ef8e1b6fbe8f7325b7566a3c.tar.bz2
WebSocket Pepper API: the second Close() should not return error code.
The WebSocket API defines that call to Close() on CLOSED state must do nothing and cause no error. Currently Pepper API returns PP_ERROR_INPROGRESS. This error code is confusing. We should return PP_OK here. BUG=124866 TEST=browser_tests --gtest_filter='*WebSocket*' Review URL: http://codereview.chromium.org/10169036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133894 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/api/ppb_websocket.idl4
-rw-r--r--ppapi/c/ppb_websocket.h6
-rw-r--r--ppapi/cpp/websocket.h2
-rw-r--r--ppapi/tests/test_websocket.cc25
-rw-r--r--webkit/plugins/ppapi/ppb_websocket_impl.cc5
5 files changed, 34 insertions, 8 deletions
diff --git a/ppapi/api/ppb_websocket.idl b/ppapi/api/ppb_websocket.idl
index 7ec3e1f..1e138bb 100644
--- a/ppapi/api/ppb_websocket.idl
+++ b/ppapi/api/ppb_websocket.idl
@@ -269,8 +269,8 @@ interface PPB_WebSocket {
* Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer
* equal to 1000 or in the range 3000 to 4999. <code>PP_ERROR_NOACCESS</code>
* corresponds to an InvalidAccessError in the WebSocket API specification.
- * Returns <code>PP_ERROR_INPROGRESS</code> if this is not the first call to
- * Close().
+ * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to Close() is
+ * not finished.
*/
int32_t Close([in] PP_Resource web_socket,
[in] uint16_t code,
diff --git a/ppapi/c/ppb_websocket.h b/ppapi/c/ppb_websocket.h
index fa8daa4..6463882 100644
--- a/ppapi/c/ppb_websocket.h
+++ b/ppapi/c/ppb_websocket.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From ppb_websocket.idl modified Mon Mar 26 09:51:15 2012. */
+/* From ppb_websocket.idl modified Wed Apr 25 11:48:30 2012. */
#ifndef PPAPI_C_PPB_WEBSOCKET_H_
#define PPAPI_C_PPB_WEBSOCKET_H_
@@ -271,8 +271,8 @@ struct PPB_WebSocket_1_0 {
* Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer
* equal to 1000 or in the range 3000 to 4999. <code>PP_ERROR_NOACCESS</code>
* corresponds to an InvalidAccessError in the WebSocket API specification.
- * Returns <code>PP_ERROR_INPROGRESS</code> if this is not the first call to
- * Close().
+ * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to Close() is
+ * not finished.
*/
int32_t (*Close)(PP_Resource web_socket,
uint16_t code,
diff --git a/ppapi/cpp/websocket.h b/ppapi/cpp/websocket.h
index 8a4d6f4..a34fdb7 100644
--- a/ppapi/cpp/websocket.h
+++ b/ppapi/cpp/websocket.h
@@ -94,7 +94,7 @@ class WebSocket : public Resource {
/// equal to 1000 or in the range 3000 to 4999.
/// <code>PP_ERROR_NOACCESS</code> corresponds to an InvalidAccessError in
/// the WebSocket API specification. Returns <code>PP_ERROR_INPROGRESS</code>
- /// if this is not the first call to Close().
+ /// if a previous call to Close() is not finished.
int32_t Close(uint16_t code, const Var& reason,
const CompletionCallback& callback);
diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc
index eff333a..11a4260 100644
--- a/ppapi/tests/test_websocket.cc
+++ b/ppapi/tests/test_websocket.cc
@@ -502,6 +502,31 @@ std::string TestWebSocket::TestInvalidClose() {
ReleaseVar(receive_message_var);
core_interface_->ReleaseResource(ws);
+ // Close twice.
+ ws = Connect(GetFullURL(kEchoServerURL), &result, "");
+ ASSERT_TRUE(ws);
+ ASSERT_EQ(PP_OK, result);
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
+ callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
+ // Call another Close() before previous one is in progress.
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
+ another_callback.GetCallback().pp_completion_callback());
+ ASSERT_EQ(PP_ERROR_INPROGRESS, result);
+ result = callback.WaitForResult();
+ ASSERT_EQ(PP_OK, result);
+ // Call another Close() after previous one is completed.
+ // This Close() must do nothing and reports no error.
+ result = websocket_interface_->Close(ws,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE, reason,
+ callback.GetCallback().pp_completion_callback());
+ if (result == PP_OK_COMPLETIONPENDING)
+ result = callback.WaitForResult();
+ ASSERT_EQ(PP_OK, result);
+ core_interface_->ReleaseResource(ws);
+
ReleaseVar(reason);
PASS();
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc
index 5851be3..154fe99 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -236,9 +236,10 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
}
// Check state.
- if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING ||
- state_ == PP_WEBSOCKETREADYSTATE_CLOSED)
+ if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING)
return PP_ERROR_INPROGRESS;
+ if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED)
+ return PP_OK;
// Validate |callback| (Doesn't support blocking callback)
if (!callback.func)