| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/loader/navigation_resource_handler.h" | 5 #include "content/browser/loader/navigation_resource_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 10 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool NavigationResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { | 142 bool NavigationResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { |
| 143 writer_.OnReadCompleted(bytes_read, defer); | 143 writer_.OnReadCompleted(bytes_read, defer); |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void NavigationResourceHandler::OnResponseCompleted( | 147 void NavigationResourceHandler::OnResponseCompleted( |
| 148 const net::URLRequestStatus& status, | 148 const net::URLRequestStatus& status, |
| 149 const std::string& security_info, | |
| 150 bool* defer) { | 149 bool* defer) { |
| 151 // If the request has already committed, close the stream and leave it as-is. | 150 // If the request has already committed, close the stream and leave it as-is. |
| 152 // | 151 // |
| 153 // TODO(davidben): The net error code should be passed through StreamWriter | 152 // TODO(davidben): The net error code should be passed through StreamWriter |
| 154 // down to the stream's consumer. See https://crbug.com/426162. | 153 // down to the stream's consumer. See https://crbug.com/426162. |
| 155 if (writer_.stream()) { | 154 if (writer_.stream()) { |
| 156 writer_.Finalize(); | 155 writer_.Finalize(); |
| 157 return; | 156 return; |
| 158 } | 157 } |
| 159 | 158 |
| 160 if (core_) { | 159 if (core_) { |
| 161 DCHECK_NE(net::OK, status.error()); | 160 DCHECK_NE(net::OK, status.error()); |
| 162 core_->NotifyRequestFailed(request()->response_info().was_cached, | 161 core_->NotifyRequestFailed(request()->response_info().was_cached, |
| 163 status.error()); | 162 status.error()); |
| 164 DetachFromCore(); | 163 DetachFromCore(); |
| 165 } | 164 } |
| 166 } | 165 } |
| 167 | 166 |
| 168 void NavigationResourceHandler::OnDataDownloaded(int bytes_downloaded) { | 167 void NavigationResourceHandler::OnDataDownloaded(int bytes_downloaded) { |
| 169 NOTREACHED(); | 168 NOTREACHED(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 void NavigationResourceHandler::DetachFromCore() { | 171 void NavigationResourceHandler::DetachFromCore() { |
| 173 DCHECK(core_); | 172 DCHECK(core_); |
| 174 core_->set_resource_handler(nullptr); | 173 core_->set_resource_handler(nullptr); |
| 175 core_ = nullptr; | 174 core_ = nullptr; |
| 176 } | 175 } |
| 177 | 176 |
| 178 } // namespace content | 177 } // namespace content |
| OLD | NEW |