diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 23:23:30 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 23:23:30 +0000 |
commit | 86dbc72dd6030f7796ac602279fab6ad85eeca60 (patch) | |
tree | 6f4eafd5ed6d7b00437f23bf2c797b841783a8b8 /remoting/protocol/buffered_socket_writer.cc | |
parent | 44d461e80c337d7baa8b9b9055d3b17ee7bc66b6 (diff) | |
download | chromium_src-86dbc72dd6030f7796ac602279fab6ad85eeca60.zip chromium_src-86dbc72dd6030f7796ac602279fab6ad85eeca60.tar.gz chromium_src-86dbc72dd6030f7796ac602279fab6ad85eeca60.tar.bz2 |
Close all writers before JingleSession is destroyed.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7218061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/buffered_socket_writer.cc')
-rw-r--r-- | remoting/protocol/buffered_socket_writer.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/remoting/protocol/buffered_socket_writer.cc b/remoting/protocol/buffered_socket_writer.cc index db069b2..4da41d7 100644 --- a/remoting/protocol/buffered_socket_writer.cc +++ b/remoting/protocol/buffered_socket_writer.cc @@ -56,11 +56,11 @@ void BufferedSocketWriterBase::Init(net::Socket* socket, bool BufferedSocketWriterBase::Write( scoped_refptr<net::IOBufferWithSize> data, Task* done_task) { - base::AutoLock auto_lock(lock_); - if (!socket_) - return false; - queue_.push_back(new PendingPacket(data, done_task)); - buffer_size_ += data->size(); + { + base::AutoLock auto_lock(lock_); + queue_.push_back(new PendingPacket(data, done_task)); + buffer_size_ += data->size(); + } message_loop_->PostTask( FROM_HERE, NewRunnableMethod(this, &BufferedSocketWriterBase::DoWrite)); return true; @@ -75,11 +75,8 @@ void BufferedSocketWriterBase::DoWrite() { return; // Don't write after Close(). - { - base::AutoLock auto_lock(lock_); - if (closed_) - return; - } + if (closed_) + return; while (true) { net::IOBuffer* current_packet; @@ -133,8 +130,11 @@ void BufferedSocketWriterBase::OnWritten(int result) { } void BufferedSocketWriterBase::HandleError(int result) { - base::AutoLock auto_lock(lock_); + DCHECK_EQ(message_loop_, MessageLoop::current()); + closed_ = true; + + base::AutoLock auto_lock(lock_); STLDeleteElements(&queue_); // Notify subclass that an error is received. @@ -152,7 +152,7 @@ int BufferedSocketWriterBase::GetBufferChunks() { } void BufferedSocketWriterBase::Close() { - base::AutoLock auto_lock(lock_); + DCHECK_EQ(message_loop_, MessageLoop::current()); closed_ = true; } |