Chromium Code Reviews| Index: mojo/system/raw_channel.cc |
| diff --git a/mojo/system/raw_channel.cc b/mojo/system/raw_channel.cc |
| index 80f21765fcd641a5ad8e28ef25d9e7a69ad671e6..0f42f8302d0859b3808486880754d70292c5cce5 100644 |
| --- a/mojo/system/raw_channel.cc |
| +++ b/mojo/system/raw_channel.cc |
| @@ -92,8 +92,8 @@ size_t RawChannel::WriteBuffer::GetTotalBytesToWrite() const { |
| } |
| RawChannel::RawChannel() |
| - : delegate_(NULL), |
| - message_loop_for_io_(NULL), |
| + : message_loop_for_io_(NULL), |
| + delegate_(NULL), |
| read_stopped_(false), |
| write_stopped_(false), |
| weak_ptr_factory_(this) { |
| @@ -140,10 +140,10 @@ void RawChannel::Shutdown() { |
| LOG_IF(WARNING, !write_buffer_->message_queue_.empty()) |
| << "Shutting down RawChannel with write buffer nonempty"; |
| - weak_ptr_factory_.InvalidateWeakPtrs(); |
| - |
| + delegate_ = NULL; |
|
sky
2014/04/24 19:58:28
Add a comment as to why it's important to NULL out
|
| read_stopped_ = true; |
| write_stopped_ = true; |
| + weak_ptr_factory_.InvalidateWeakPtrs(); |
| OnShutdownNoLock(read_buffer_.Pass(), write_buffer_.Pass()); |
| } |
| @@ -254,6 +254,7 @@ void RawChannel::OnReadCompleted(bool result, size_t bytes_read) { |
| DCHECK_EQ(message_view.total_size(), message_size); |
| // Dispatch the message. |
| + DCHECK(delegate_); |
| delegate_->OnReadMessage(message_view); |
| if (read_stopped_) { |
| // |Shutdown()| was called in |OnReadMessage()|. |
| @@ -328,7 +329,8 @@ void RawChannel::OnWriteCompleted(bool result, size_t bytes_written) { |
| void RawChannel::CallOnFatalError(Delegate::FatalError fatal_error) { |
| DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io_); |
| // TODO(vtl): Add a "write_lock_.AssertNotAcquired()"? |
| - delegate_->OnFatalError(fatal_error); |
| + if (delegate_) |
| + delegate_->OnFatalError(fatal_error); |
| } |
| bool RawChannel::OnWriteCompletedNoLock(bool result, size_t bytes_written) { |