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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } | 416 } |
417 | 417 |
418 void WebSocketResource::OnPluginMsgReceiveBinaryReply( | 418 void WebSocketResource::OnPluginMsgReceiveBinaryReply( |
419 const ResourceMessageReplyParams& params, | 419 const ResourceMessageReplyParams& params, |
420 const std::vector<uint8_t>& message) { | 420 const std::vector<uint8_t>& message) { |
421 // Dispose packets after receiving an error or in invalid state. | 421 // Dispose packets after receiving an error or in invalid state. |
422 if (error_was_received_ || !InValidStateToReceive(state_)) | 422 if (error_was_received_ || !InValidStateToReceive(state_)) |
423 return; | 423 return; |
424 | 424 |
425 // Append received data to queue. | 425 // Append received data to queue. |
426 scoped_refptr<Var> message_var(ArrayBufferVar::FromPPVar( | 426 scoped_refptr<Var> message_var( |
427 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 427 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( |
428 message.size(), | 428 message.size(), |
429 &message.front()))); | 429 &message.front())); |
430 received_messages_.push(message_var); | 430 received_messages_.push(message_var); |
431 | 431 |
432 if (!TrackedCallback::IsPending(receive_callback_)) | 432 if (!TrackedCallback::IsPending(receive_callback_)) |
433 return; | 433 return; |
434 | 434 |
435 receive_callback_->Run(DoReceive()); | 435 receive_callback_->Run(DoReceive()); |
436 } | 436 } |
437 | 437 |
438 void WebSocketResource::OnPluginMsgErrorReply( | 438 void WebSocketResource::OnPluginMsgErrorReply( |
439 const ResourceMessageReplyParams& params) { | 439 const ResourceMessageReplyParams& params) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 return PP_OK; | 474 return PP_OK; |
475 | 475 |
476 *receive_callback_var_ = received_messages_.front()->GetPPVar(); | 476 *receive_callback_var_ = received_messages_.front()->GetPPVar(); |
477 received_messages_.pop(); | 477 received_messages_.pop(); |
478 receive_callback_var_ = NULL; | 478 receive_callback_var_ = NULL; |
479 return PP_OK; | 479 return PP_OK; |
480 } | 480 } |
481 | 481 |
482 } // namespace proxy | 482 } // namespace proxy |
483 } // namespace ppapi | 483 } // namespace ppapi |
OLD | NEW |