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

Side by Side Diff: webkit/plugins/ppapi/ppb_websocket_impl.cc

Issue 10661026: WebSocket Pepper API: allow to release in completion callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remvoe redundant checker Created 8 years, 5 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 | « ppapi/tests/test_websocket.cc ('k') | no next file » | no next file with comments »
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 "webkit/plugins/ppapi/ppb_websocket_impl.h" 5 #include "webkit/plugins/ppapi/ppb_websocket_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 close_was_clean_ = was_clean ? PP_TRUE : PP_FALSE; 495 close_was_clean_ = was_clean ? PP_TRUE : PP_FALSE;
496 496
497 // Update buffered_amount_. 497 // Update buffered_amount_.
498 buffered_amount_ = unhandled_buffered_amount; 498 buffered_amount_ = unhandled_buffered_amount;
499 499
500 // Handle state transition and invoking callback. 500 // Handle state transition and invoking callback.
501 DCHECK_NE(PP_WEBSOCKETREADYSTATE_CLOSED, state_); 501 DCHECK_NE(PP_WEBSOCKETREADYSTATE_CLOSED, state_);
502 PP_WebSocketReadyState state = state_; 502 PP_WebSocketReadyState state = state_;
503 state_ = PP_WEBSOCKETREADYSTATE_CLOSED; 503 state_ = PP_WEBSOCKETREADYSTATE_CLOSED;
504 504
505 // User handlers may release WebSocket PP_Resource in the following
506 // completion callbacks. Retain |this| here to assure that this object
507 // keep on being valid in this function.
508 scoped_refptr<PPB_WebSocket_Impl> retain_this(this);
505 if (state == PP_WEBSOCKETREADYSTATE_CONNECTING) 509 if (state == PP_WEBSOCKETREADYSTATE_CONNECTING)
506 TrackedCallback::ClearAndRun(&connect_callback_, PP_ERROR_FAILED); 510 TrackedCallback::ClearAndRun(&connect_callback_, PP_ERROR_FAILED);
507 511
508 if (wait_for_receive_) { 512 if (wait_for_receive_) {
509 wait_for_receive_ = false; 513 wait_for_receive_ = false;
510 receive_callback_var_ = NULL; 514 receive_callback_var_ = NULL;
511 TrackedCallback::ClearAndRun(&receive_callback_, PP_ERROR_FAILED); 515 TrackedCallback::ClearAndRun(&receive_callback_, PP_ERROR_FAILED);
512 } 516 }
513 517
514 if ((state == PP_WEBSOCKETREADYSTATE_CLOSING) && close_callback_.get()) 518 if ((state == PP_WEBSOCKETREADYSTATE_CLOSING) && close_callback_.get())
(...skipping 10 matching lines...) Expand all
525 529
526 *receive_callback_var_ = received_messages_.front()->GetPPVar(); 530 *receive_callback_var_ = received_messages_.front()->GetPPVar();
527 received_messages_.pop(); 531 received_messages_.pop();
528 receive_callback_var_ = NULL; 532 receive_callback_var_ = NULL;
529 wait_for_receive_ = false; 533 wait_for_receive_ = false;
530 return PP_OK; 534 return PP_OK;
531 } 535 }
532 536
533 } // namespace ppapi 537 } // namespace ppapi
534 } // namespace webkit 538 } // namespace webkit
OLDNEW
« no previous file with comments | « ppapi/tests/test_websocket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698