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

Unified Diff: content/renderer/pepper/pepper_websocket_host.cc

Issue 202143007: Move Blink dependency out of plugin proxy code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments. Created 6 years, 9 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 | « no previous file | ppapi/proxy/websocket_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_websocket_host.cc
diff --git a/content/renderer/pepper/pepper_websocket_host.cc b/content/renderer/pepper/pepper_websocket_host.cc
index a88fdb54e47ddd8f211fe4e5ef4c296905c19cf9..7df7796c82f48ac4b4e15ae5fd91d2f6c7f38869 100644
--- a/content/renderer/pepper/pepper_websocket_host.cc
+++ b/content/renderer/pepper/pepper_websocket_host.cc
@@ -30,6 +30,40 @@ using blink::WebURL;
namespace content {
+#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \
+ COMPILE_ASSERT(static_cast<int>(WebSocket::webkit_name) \
+ == static_cast<int>(np_name), \
+ mismatching_enums)
+
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNormalClosure,
+ PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeGoingAway,
+ PP_WEBSOCKETSTATUSCODE_GOING_AWAY);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeProtocolError,
+ PP_WEBSOCKETSTATUSCODE_PROTOCOL_ERROR);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeUnsupportedData,
+ PP_WEBSOCKETSTATUSCODE_UNSUPPORTED_DATA);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeNoStatusRcvd,
+ PP_WEBSOCKETSTATUSCODE_NO_STATUS_RECEIVED);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeAbnormalClosure,
+ PP_WEBSOCKETSTATUSCODE_ABNORMAL_CLOSURE);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeInvalidFramePayloadData,
+ PP_WEBSOCKETSTATUSCODE_INVALID_FRAME_PAYLOAD_DATA);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodePolicyViolation,
+ PP_WEBSOCKETSTATUSCODE_POLICY_VIOLATION);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMessageTooBig,
+ PP_WEBSOCKETSTATUSCODE_MESSAGE_TOO_BIG);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMandatoryExt,
+ PP_WEBSOCKETSTATUSCODE_MANDATORY_EXTENSION);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeInternalError,
+ PP_WEBSOCKETSTATUSCODE_INTERNAL_SERVER_ERROR);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeTLSHandshake,
+ PP_WEBSOCKETSTATUSCODE_TLS_HANDSHAKE);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMinimumUserDefined,
+ PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN);
+COMPILE_ASSERT_MATCHING_ENUM(CloseEventCodeMaximumUserDefined,
+ PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX);
+
PepperWebSocketHost::PepperWebSocketHost(
RendererPpapiHost* host,
PP_Instance instance,
@@ -253,8 +287,18 @@ int32_t PepperWebSocketHost::OnHostMsgClose(
return PP_ERROR_FAILED;
close_reply_ = context->MakeReplyMessageContext();
initiating_close_ = true;
+
+ blink::WebSocket::CloseEventCode event_code =
+ static_cast<blink::WebSocket::CloseEventCode>(code);
+ if (code == PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) {
+ // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED and CloseEventCodeNotSpecified are
+ // assigned to different values. A conversion is needed if
+ // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED is specified.
+ event_code = blink::WebSocket::CloseEventCodeNotSpecified;
+ }
+
WebString web_reason = WebString::fromUTF8(reason);
- websocket_->close(code, web_reason);
+ websocket_->close(event_code, web_reason);
return PP_OK_COMPLETIONPENDING;
}
« no previous file with comments | « no previous file | ppapi/proxy/websocket_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698