| 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 "ppapi/proxy/websocket_resource.h" | 5 #include "ppapi/proxy/websocket_resource.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include <limits> | 9 #include <limits> |
| 8 #include <set> | 10 #include <set> |
| 9 #include <string> | 11 #include <string> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 14 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
| 15 #include "ppapi/proxy/dispatch_reply_message.h" | 17 #include "ppapi/proxy/dispatch_reply_message.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (!message_string.get()) | 268 if (!message_string.get()) |
| 267 return PP_ERROR_BADARGUMENT; | 269 return PP_ERROR_BADARGUMENT; |
| 268 Post(RENDERER, PpapiHostMsg_WebSocket_SendText(message_string->value())); | 270 Post(RENDERER, PpapiHostMsg_WebSocket_SendText(message_string->value())); |
| 269 } else if (message.type == PP_VARTYPE_ARRAY_BUFFER) { | 271 } else if (message.type == PP_VARTYPE_ARRAY_BUFFER) { |
| 270 // Convert message to std::vector<uint8_t>, then send it. | 272 // Convert message to std::vector<uint8_t>, then send it. |
| 271 scoped_refptr<ArrayBufferVar> message_arraybuffer = | 273 scoped_refptr<ArrayBufferVar> message_arraybuffer = |
| 272 ArrayBufferVar::FromPPVar(message); | 274 ArrayBufferVar::FromPPVar(message); |
| 273 if (!message_arraybuffer.get()) | 275 if (!message_arraybuffer.get()) |
| 274 return PP_ERROR_BADARGUMENT; | 276 return PP_ERROR_BADARGUMENT; |
| 275 uint8_t* message_data = static_cast<uint8_t*>(message_arraybuffer->Map()); | 277 uint8_t* message_data = static_cast<uint8_t*>(message_arraybuffer->Map()); |
| 276 uint32 message_length = message_arraybuffer->ByteLength(); | 278 uint32_t message_length = message_arraybuffer->ByteLength(); |
| 277 std::vector<uint8_t> message_vector(message_data, | 279 std::vector<uint8_t> message_vector(message_data, |
| 278 message_data + message_length); | 280 message_data + message_length); |
| 279 Post(RENDERER, PpapiHostMsg_WebSocket_SendBinary(message_vector)); | 281 Post(RENDERER, PpapiHostMsg_WebSocket_SendBinary(message_vector)); |
| 280 } else { | 282 } else { |
| 281 // TODO(toyoshim): Support Blob. | 283 // TODO(toyoshim): Support Blob. |
| 282 return PP_ERROR_NOTSUPPORTED; | 284 return PP_ERROR_NOTSUPPORTED; |
| 283 } | 285 } |
| 284 return PP_OK; | 286 return PP_OK; |
| 285 } | 287 } |
| 286 | 288 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return PP_OK; | 481 return PP_OK; |
| 480 | 482 |
| 481 *receive_callback_var_ = received_messages_.front()->GetPPVar(); | 483 *receive_callback_var_ = received_messages_.front()->GetPPVar(); |
| 482 received_messages_.pop(); | 484 received_messages_.pop(); |
| 483 receive_callback_var_ = NULL; | 485 receive_callback_var_ = NULL; |
| 484 return PP_OK; | 486 return PP_OK; |
| 485 } | 487 } |
| 486 | 488 |
| 487 } // namespace proxy | 489 } // namespace proxy |
| 488 } // namespace ppapi | 490 } // namespace ppapi |
| OLD | NEW |