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

Side by Side Diff: ppapi/proxy/websocket_resource.cc

Issue 12096099: PPAPI: Fix WebSocket Var ref leak receiving binary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/shared_impl/var_tracker.h » ('j') | ppapi/tests/test_websocket.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ppapi/shared_impl/var_tracker.h » ('j') | ppapi/tests/test_websocket.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698