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

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

Issue 10332138: WebSocket Pepper API: allow to close connection without code and reason (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uint16_t -> enum Created 8 years, 7 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
« ppapi/api/ppb_websocket.idl ('K') | « webkit/plugins/ppapi/ppb_websocket_impl.h ('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 c639fc6b40591107c166eea01caa279570b1dfa3..4230fc5aba152197563a3b6361f8fb276c1f3d97 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -204,35 +204,36 @@ int32_t PPB_WebSocket_Impl::Connect(PP_Var url,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_WebSocket_Impl::Close(uint16_t code,
+int32_t PPB_WebSocket_Impl::Close(PP_WebSocketStatusCode code,
PP_Var reason,
PP_CompletionCallback callback) {
// Check mandarory interfaces.
if (!websocket_.get())
return PP_ERROR_FAILED;
- // Validate |code|. Need to cast |CloseEventCodeNotSpecified| which is -1 to
- // uint16_t for the comparison to work.
- if (code != static_cast<uint16_t>(WebSocket::CloseEventCodeNotSpecified)) {
- if (!(code == WebSocket::CloseEventCodeNormalClosure ||
- (WebSocket::CloseEventCodeMinimumUserDefined <= code &&
- code <= WebSocket::CloseEventCodeMaximumUserDefined)))
+ // Validate |code| and |reason|. Need to cast |CloseEventCodeNotSpecified|
+ // which is -1 to uint16_t for the comparison to work. |reason| is valid only
+ // when |code| is not PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED.
+ scoped_refptr<StringVar> reason_string;
+ WebString web_reason;
+ if (code != PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) {
+ if (!(code == PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE ||
+ (PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN <= code &&
+ code <= PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX)))
// RFC 6455 limits applications to use reserved connection close code in
// section 7.4.2.. The WebSocket API (http://www.w3.org/TR/websockets/)
// defines this out of range error as InvalidAccessError in JavaScript.
return PP_ERROR_NOACCESS;
- }
- scoped_refptr<StringVar> reason_string;
- WebString web_reason;
- // |reason| must be ignored if it is PP_VARTYPE_UNDEFINED.
- if (reason.type != PP_VARTYPE_UNDEFINED) {
- // Validate |reason|.
- reason_string = StringVar::FromPPVar(reason);
- if (!reason_string ||
- reason_string->value().size() > kMaxReasonSizeInBytes)
- return PP_ERROR_BADARGUMENT;
- web_reason = WebString::fromUTF8(reason_string->value());
+ // |reason| must be ignored if it is PP_VARTYPE_UNDEFINED.
+ if (reason.type != PP_VARTYPE_UNDEFINED) {
+ // Validate |reason|.
+ reason_string = StringVar::FromPPVar(reason);
+ if (!reason_string ||
+ reason_string->value().size() > kMaxReasonSizeInBytes)
+ return PP_ERROR_BADARGUMENT;
+ web_reason = WebString::fromUTF8(reason_string->value());
+ }
}
// Check state.
« ppapi/api/ppb_websocket.idl ('K') | « webkit/plugins/ppapi/ppb_websocket_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698