Index: net/base/file_stream_posix.cc |
=================================================================== |
--- net/base/file_stream_posix.cc (revision 16872) |
+++ net/base/file_stream_posix.cc (working copy) |
@@ -200,6 +200,8 @@ |
int result_; |
CancelableCallbackTask* message_loop_task_; |
+ bool is_closing_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AsyncContext); |
}; |
@@ -209,9 +211,11 @@ |
background_io_completed_callback_( |
this, &AsyncContext::OnBackgroundIOCompleted), |
background_io_completed_(true, false), |
- message_loop_task_(NULL) {} |
+ message_loop_task_(NULL), |
+ is_closing_(false) {} |
FileStream::AsyncContext::~AsyncContext() { |
+ is_closing_ = true; |
if (callback_) { |
// If |callback_| is non-NULL, that implies either the worker thread is |
// still running the IO task, or the completion callback is queued up on the |
@@ -271,6 +275,11 @@ |
message_loop_task_->Cancel(); |
message_loop_task_ = NULL; |
+ if (is_closing_) { |
+ callback_ = NULL; |
+ return; |
+ } |
+ |
DCHECK(callback_); |
CompletionCallback* temp = NULL; |
std::swap(temp, callback_); |