diff options
author | yutak@chromium.org <yutak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 11:55:50 +0000 |
---|---|---|
committer | yutak@chromium.org <yutak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 11:55:50 +0000 |
commit | b18ffe27527b73d41c5d31ea6fca39ca6dd50f48 (patch) | |
tree | 73548944d4617c2a19af14dd6262d23f71cfb93f /net/websockets | |
parent | ed7b123cdab30a82f0517671605666e9fffe4928 (diff) | |
download | chromium_src-b18ffe27527b73d41c5d31ea6fca39ca6dd50f48.zip chromium_src-b18ffe27527b73d41c5d31ea6fca39ca6dd50f48.tar.gz chromium_src-b18ffe27527b73d41c5d31ea6fca39ca6dd50f48.tar.bz2 |
Convert ScopedRunnableMethodFactory in WebSocketJob.
BUG=105683
TEST=none
Review URL: http://codereview.chromium.org/8728025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets')
-rw-r--r-- | net/websockets/websocket_job.cc | 13 | ||||
-rw-r--r-- | net/websockets/websocket_job.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc index 6a5df55..794586b 100644 --- a/net/websockets/websocket_job.cc +++ b/net/websockets/websocket_job.cc @@ -84,8 +84,8 @@ WebSocketJob::WebSocketJob(SocketStream::Delegate* delegate) response_cookies_save_index_(0), send_frame_handler_(new WebSocketFrameHandler), receive_frame_handler_(new WebSocketFrameHandler), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_send_pending_(this)) { } WebSocketJob::~WebSocketJob() { @@ -167,6 +167,7 @@ void WebSocketJob::DetachDelegate() { scoped_refptr<WebSocketJob> protect(this); weak_ptr_factory_.InvalidateWeakPtrs(); + weak_ptr_factory_for_send_pending_.InvalidateWeakPtrs(); delegate_ = NULL; if (socket_) @@ -233,10 +234,11 @@ void WebSocketJob::OnSentData(SocketStream* socket, int amount_sent) { DCHECK_GT(amount_sent, 0); current_buffer_ = NULL; send_frame_handler_->ReleaseCurrentBuffer(); - if (method_factory_.empty()) { + if (!weak_ptr_factory_for_send_pending_.HasWeakPtrs()) { MessageLoopForIO::current()->PostTask( FROM_HERE, - method_factory_.NewRunnableMethod(&WebSocketJob::SendPending)); + base::Bind(&WebSocketJob::SendPending, + weak_ptr_factory_for_send_pending_.GetWeakPtr())); } delegate_->OnSentData(socket, amount_sent); } @@ -616,7 +618,8 @@ void WebSocketJob::Wakeup() { DCHECK(callback_); MessageLoopForIO::current()->PostTask( FROM_HERE, - method_factory_.NewRunnableMethod(&WebSocketJob::RetryPendingIO)); + base::Bind(&WebSocketJob::RetryPendingIO, + weak_ptr_factory_.GetWeakPtr())); } void WebSocketJob::RetryPendingIO() { diff --git a/net/websockets/websocket_job.h b/net/websockets/websocket_job.h index 4df3315..1fcf256 100644 --- a/net/websockets/websocket_job.h +++ b/net/websockets/websocket_job.h @@ -137,8 +137,8 @@ class NET_EXPORT WebSocketJob scoped_ptr<SpdyWebSocketStream> spdy_websocket_stream_; std::string challenge_; - ScopedRunnableMethodFactory<WebSocketJob> method_factory_; base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_; + base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_for_send_pending_; DISALLOW_COPY_AND_ASSIGN(WebSocketJob); }; |