Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_websocket_host.h" | 5 #include "content/renderer/pepper/pepper_websocket_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 } | 246 } |
| 247 | 247 |
| 248 int32_t PepperWebSocketHost::OnHostMsgClose( | 248 int32_t PepperWebSocketHost::OnHostMsgClose( |
| 249 ppapi::host::HostMessageContext* context, | 249 ppapi::host::HostMessageContext* context, |
| 250 int32_t code, | 250 int32_t code, |
| 251 const std::string& reason) { | 251 const std::string& reason) { |
| 252 if (!websocket_) | 252 if (!websocket_) |
| 253 return PP_ERROR_FAILED; | 253 return PP_ERROR_FAILED; |
| 254 close_reply_ = context->MakeReplyMessageContext(); | 254 close_reply_ = context->MakeReplyMessageContext(); |
| 255 initiating_close_ = true; | 255 initiating_close_ = true; |
| 256 | |
| 257 blink::WebSocket::CloseEventCode event_code = | |
| 258 static_cast<blink::WebSocket::CloseEventCode>(code); | |
|
dmichael (off chromium)
2014/03/18 18:02:30
:-/
I like for us to do a compile assert on enum v
bbudge
2014/03/18 20:23:31
Done.
| |
| 259 if (code == PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED) { | |
| 260 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED and CloseEventCodeNotSpecified are | |
| 261 // assigned to different values. A conversion is needed if | |
| 262 // PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED is specified. | |
| 263 event_code = blink::WebSocket::CloseEventCodeNotSpecified; | |
| 264 } | |
| 265 | |
| 256 WebString web_reason = WebString::fromUTF8(reason); | 266 WebString web_reason = WebString::fromUTF8(reason); |
| 257 websocket_->close(code, web_reason); | 267 websocket_->close(event_code, web_reason); |
| 258 return PP_OK_COMPLETIONPENDING; | 268 return PP_OK_COMPLETIONPENDING; |
| 259 } | 269 } |
| 260 | 270 |
| 261 int32_t PepperWebSocketHost::OnHostMsgSendText( | 271 int32_t PepperWebSocketHost::OnHostMsgSendText( |
| 262 ppapi::host::HostMessageContext* context, | 272 ppapi::host::HostMessageContext* context, |
| 263 const std::string& message) { | 273 const std::string& message) { |
| 264 if (websocket_) { | 274 if (websocket_) { |
| 265 WebString web_message = WebString::fromUTF8(message); | 275 WebString web_message = WebString::fromUTF8(message); |
| 266 websocket_->sendText(web_message); | 276 websocket_->sendText(web_message); |
| 267 } | 277 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 281 | 291 |
| 282 int32_t PepperWebSocketHost::OnHostMsgFail( | 292 int32_t PepperWebSocketHost::OnHostMsgFail( |
| 283 ppapi::host::HostMessageContext* context, | 293 ppapi::host::HostMessageContext* context, |
| 284 const std::string& message) { | 294 const std::string& message) { |
| 285 if (websocket_) | 295 if (websocket_) |
| 286 websocket_->fail(WebString::fromUTF8(message)); | 296 websocket_->fail(WebString::fromUTF8(message)); |
| 287 return PP_OK; | 297 return PP_OK; |
| 288 } | 298 } |
| 289 | 299 |
| 290 } // namespace content | 300 } // namespace content |
| OLD | NEW |