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

Unified 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: Use WeakPtr to protect |this| Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« ppapi/tests/test_websocket.cc ('K') | « webkit/plugins/ppapi/ppb_websocket_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_websocket_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc
index bc9fae483d460f51ce2309dd3e402afc97a5ea1f..6bdf0372570884533d3d97a10bd483762ac45874 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -502,17 +502,26 @@ void PPB_WebSocket_Impl::didClose(unsigned long unhandled_buffered_amount,
PP_WebSocketReadyState state = state_;
state_ = PP_WEBSOCKETREADYSTATE_CLOSED;
- if (state == PP_WEBSOCKETREADYSTATE_CONNECTING)
+ const base::WeakPtr<PPB_WebSocket_Impl> weak_ptr = AsWeakPtr();
dmichael (off chromium) 2012/06/25 15:50:51 Another option might be to just take a reference f
Takashi Toyoshima 2012/06/26 09:19:10 If I took a reference of this here, I can continue
dmichael (off chromium) 2012/06/26 16:01:40 Are you sure? We keep 2 separate reference counts;
Takashi Toyoshima 2012/06/27 08:09:05 Thank you. I didn't understand TrackedCallback co
+ if (state == PP_WEBSOCKETREADYSTATE_CONNECTING) {
TrackedCallback::ClearAndRun(&connect_callback_, PP_ERROR_FAILED);
+ if (!weak_ptr)
+ return;
+ }
if (wait_for_receive_) {
wait_for_receive_ = false;
receive_callback_var_ = NULL;
TrackedCallback::ClearAndRun(&receive_callback_, PP_ERROR_FAILED);
+ if (!weak_ptr)
+ return;
}
- if ((state == PP_WEBSOCKETREADYSTATE_CLOSING) && close_callback_.get())
+ if ((state == PP_WEBSOCKETREADYSTATE_CLOSING) && close_callback_.get()) {
TrackedCallback::ClearAndRun(&close_callback_, PP_OK);
+ if (!weak_ptr)
+ return;
+ }
// Disconnect.
if (websocket_.get())
« ppapi/tests/test_websocket.cc ('K') | « webkit/plugins/ppapi/ppb_websocket_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698