| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/url_response_body_consumer.h" | 5 #include "content/child/url_response_body_consumer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 URLResponseBodyConsumer::URLResponseBodyConsumer( | 40 URLResponseBodyConsumer::URLResponseBodyConsumer( |
| 41 int request_id, | 41 int request_id, |
| 42 ResourceDispatcher* resource_dispatcher, | 42 ResourceDispatcher* resource_dispatcher, |
| 43 mojo::ScopedDataPipeConsumerHandle handle, | 43 mojo::ScopedDataPipeConsumerHandle handle, |
| 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 45 : request_id_(request_id), | 45 : request_id_(request_id), |
| 46 resource_dispatcher_(resource_dispatcher), | 46 resource_dispatcher_(resource_dispatcher), |
| 47 handle_(std::move(handle)), | 47 handle_(std::move(handle)), |
| 48 handle_watcher_(task_runner), | 48 handle_watcher_(FROM_HERE, task_runner), |
| 49 task_runner_(task_runner), | 49 task_runner_(task_runner), |
| 50 has_seen_end_of_data_(!handle_.is_valid()) {} | 50 has_seen_end_of_data_(!handle_.is_valid()) {} |
| 51 | 51 |
| 52 URLResponseBodyConsumer::~URLResponseBodyConsumer() {} | 52 URLResponseBodyConsumer::~URLResponseBodyConsumer() {} |
| 53 | 53 |
| 54 void URLResponseBodyConsumer::Start() { | 54 void URLResponseBodyConsumer::Start() { |
| 55 if (has_been_cancelled_) | 55 if (has_been_cancelled_) |
| 56 return; | 56 return; |
| 57 handle_watcher_.Start( | 57 handle_watcher_.Start( |
| 58 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, | 58 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return; | 141 return; |
| 142 // Cancel this instance in order not to notify twice. | 142 // Cancel this instance in order not to notify twice. |
| 143 Cancel(); | 143 Cancel(); |
| 144 | 144 |
| 145 resource_dispatcher_->DispatchMessage( | 145 resource_dispatcher_->DispatchMessage( |
| 146 ResourceMsg_RequestComplete(request_id_, completion_status_)); | 146 ResourceMsg_RequestComplete(request_id_, completion_status_)); |
| 147 // |this| may be deleted. | 147 // |this| may be deleted. |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace content | 150 } // namespace content |
| OLD | NEW |