Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_throttle.h" | 5 #include "content/browser/loader/navigation_resource_throttle.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/callback_helpers.h" | |
| 11 #include "base/location.h" | 12 #include "base/location.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "content/browser/frame_host/navigation_handle_impl.h" | 15 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 16 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/render_frame_host_impl.h" | 17 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 17 #include "content/browser/loader/navigation_resource_handler.h" | 18 #include "content/browser/loader/navigation_resource_handler.h" |
| 18 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 19 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 19 #include "content/browser/loader/resource_loader.h" | 20 #include "content/browser/loader/resource_loader.h" |
| 20 #include "content/browser/loader/resource_request_info_impl.h" | 21 #include "content/browser/loader/resource_request_info_impl.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 render_frame_host, headers, connection_info, ssl_status, request_id, | 173 render_frame_host, headers, connection_info, ssl_status, request_id, |
| 173 should_replace_current_entry, is_download, is_stream, transfer_callback, | 174 should_replace_current_entry, is_download, is_stream, transfer_callback, |
| 174 base::Bind(&SendCheckResultToIOThread, callback)); | 175 base::Bind(&SendCheckResultToIOThread, callback)); |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace | 178 } // namespace |
| 178 | 179 |
| 179 NavigationResourceThrottle::NavigationResourceThrottle( | 180 NavigationResourceThrottle::NavigationResourceThrottle( |
| 180 net::URLRequest* request, | 181 net::URLRequest* request, |
| 181 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, | 182 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
| 182 RequestContextType request_context_type) | 183 RequestContextType request_context_type, |
| 184 const TransferCallback& on_transfer) | |
| 183 : request_(request), | 185 : request_(request), |
| 184 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), | 186 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), |
| 185 request_context_type_(request_context_type), | 187 request_context_type_(request_context_type), |
| 186 in_cross_site_transition_(false), | 188 in_cross_site_transition_(false), |
| 187 on_transfer_done_result_(NavigationThrottle::DEFER), | 189 on_transfer_done_result_(NavigationThrottle::DEFER), |
| 190 on_transfer_(on_transfer), | |
| 188 weak_ptr_factory_(this) {} | 191 weak_ptr_factory_(this) {} |
| 189 | 192 |
| 190 NavigationResourceThrottle::~NavigationResourceThrottle() {} | 193 NavigationResourceThrottle::~NavigationResourceThrottle() {} |
| 191 | 194 |
| 192 void NavigationResourceThrottle::WillStartRequest(bool* defer) { | 195 void NavigationResourceThrottle::WillStartRequest(bool* defer) { |
| 193 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 196 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 194 const ResourceRequestInfoImpl* info = | 197 const ResourceRequestInfoImpl* info = |
| 195 ResourceRequestInfoImpl::ForRequest(request_); | 198 ResourceRequestInfoImpl::ForRequest(request_); |
| 196 if (!info) | 199 if (!info) |
| 197 return; | 200 return; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 358 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 356 in_cross_site_transition_ = true; | 359 in_cross_site_transition_ = true; |
| 357 ResourceRequestInfoImpl* info = | 360 ResourceRequestInfoImpl* info = |
| 358 ResourceRequestInfoImpl::ForRequest(request_); | 361 ResourceRequestInfoImpl::ForRequest(request_); |
| 359 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation( | 362 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation( |
| 360 info->GetGlobalRequestID(), | 363 info->GetGlobalRequestID(), |
| 361 base::Bind(&NavigationResourceThrottle::OnTransferComplete, | 364 base::Bind(&NavigationResourceThrottle::OnTransferComplete, |
| 362 weak_ptr_factory_.GetWeakPtr())); | 365 weak_ptr_factory_.GetWeakPtr())); |
| 363 } | 366 } |
| 364 | 367 |
| 365 void NavigationResourceThrottle::OnTransferComplete() { | 368 void NavigationResourceThrottle::OnTransferComplete( |
| 369 mojom::URLLoaderAssociatedRequest mojo_request, | |
| 370 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | |
| 366 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 371 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 367 DCHECK(in_cross_site_transition_); | 372 DCHECK(in_cross_site_transition_); |
| 368 in_cross_site_transition_ = false; | 373 in_cross_site_transition_ = false; |
| 369 | 374 |
| 375 if (on_transfer_) { | |
|
clamy
2016/11/21 17:55:54
Could you dcheck this only happens when loading wi
| |
| 376 base::ResetAndReturn(&on_transfer_) | |
| 377 .Run(std::move(mojo_request), std::move(url_loader_client)); | |
| 378 } | |
| 379 | |
| 370 // If the results of the checks on the UI thread are known, unblock the | 380 // If the results of the checks on the UI thread are known, unblock the |
| 371 // navigation. Otherwise, wait until the callback has executed. | 381 // navigation. Otherwise, wait until the callback has executed. |
| 372 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 382 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 373 OnUIChecksPerformed(on_transfer_done_result_); | 383 OnUIChecksPerformed(on_transfer_done_result_); |
| 374 on_transfer_done_result_ = NavigationThrottle::DEFER; | 384 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 375 } | 385 } |
| 376 } | 386 } |
| 377 | 387 |
| 378 } // namespace content | 388 } // namespace content |
| OLD | NEW |