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

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

Issue 10167028: WebSocket Pepper API: PPB_WebSocket::close must accept undefined reason (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove a TODO Created 8 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 | « 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 9157b67c92f896a90d622c407f718452cbc658de..5851be38556286aee9554db8aa60fc7b9fb14bc7 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -223,12 +223,17 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
return PP_ERROR_NOACCESS;
}
- // Validate |reason|.
- // TODO(toyoshim): Returns PP_ERROR_BADARGUMENT if |reason| contains any
- // surrogates.
- scoped_refptr<StringVar> reason_string = StringVar::FromPPVar(reason);
- if (!reason_string || reason_string->value().size() > kMaxReasonSizeInBytes)
- return PP_ERROR_BADARGUMENT;
+ 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());
+ }
// Check state.
if (state_ == PP_WEBSOCKETREADYSTATE_CLOSING ||
@@ -265,7 +270,6 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
// Close connection.
state_ = PP_WEBSOCKETREADYSTATE_CLOSING;
- WebString web_reason = WebString::fromUTF8(reason_string->value());
websocket_->close(code, web_reason);
return PP_OK_COMPLETIONPENDING;
« no previous file with comments | « ppapi/tests/test_websocket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698