| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/numerics/safe_conversions.h" |
| 12 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/proxy/dispatch_reply_message.h" | 14 #include "ppapi/proxy/dispatch_reply_message.h" |
| 14 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/shared_impl/ppapi_globals.h" | 16 #include "ppapi/shared_impl/ppapi_globals.h" |
| 16 #include "ppapi/shared_impl/var.h" | 17 #include "ppapi/shared_impl/var.h" |
| 17 #include "ppapi/shared_impl/var_tracker.h" | 18 #include "ppapi/shared_impl/var_tracker.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const uint32_t kMaxReasonSizeInBytes = 123; | 22 const uint32_t kMaxReasonSizeInBytes = 123; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 void WebSocketResource::OnPluginMsgReceiveBinaryReply( | 418 void WebSocketResource::OnPluginMsgReceiveBinaryReply( |
| 418 const ResourceMessageReplyParams& params, | 419 const ResourceMessageReplyParams& params, |
| 419 const std::vector<uint8_t>& message) { | 420 const std::vector<uint8_t>& message) { |
| 420 // Dispose packets after receiving an error or in invalid state. | 421 // Dispose packets after receiving an error or in invalid state. |
| 421 if (error_was_received_ || !InValidStateToReceive(state_)) | 422 if (error_was_received_ || !InValidStateToReceive(state_)) |
| 422 return; | 423 return; |
| 423 | 424 |
| 424 // Append received data to queue. | 425 // Append received data to queue. |
| 425 scoped_refptr<Var> message_var( | 426 scoped_refptr<Var> message_var( |
| 426 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( | 427 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( |
| 427 message.size(), | 428 base::checked_cast<uint32_t>(message.size()), |
| 428 &message.front())); | 429 &message.front())); |
| 429 received_messages_.push(message_var); | 430 received_messages_.push(message_var); |
| 430 | 431 |
| 431 if (!TrackedCallback::IsPending(receive_callback_) || | 432 if (!TrackedCallback::IsPending(receive_callback_) || |
| 432 TrackedCallback::IsScheduledToRun(receive_callback_)) { | 433 TrackedCallback::IsScheduledToRun(receive_callback_)) { |
| 433 return; | 434 return; |
| 434 } | 435 } |
| 435 | 436 |
| 436 receive_callback_->Run(DoReceive()); | 437 receive_callback_->Run(DoReceive()); |
| 437 } | 438 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 return PP_OK; | 478 return PP_OK; |
| 478 | 479 |
| 479 *receive_callback_var_ = received_messages_.front()->GetPPVar(); | 480 *receive_callback_var_ = received_messages_.front()->GetPPVar(); |
| 480 received_messages_.pop(); | 481 received_messages_.pop(); |
| 481 receive_callback_var_ = NULL; | 482 receive_callback_var_ = NULL; |
| 482 return PP_OK; | 483 return PP_OK; |
| 483 } | 484 } |
| 484 | 485 |
| 485 } // namespace proxy | 486 } // namespace proxy |
| 486 } // namespace ppapi | 487 } // namespace ppapi |
| OLD | NEW |