Chromium Code Reviews| Index: content/browser/loader/navigation_resource_handler.cc |
| diff --git a/content/browser/loader/navigation_resource_handler.cc b/content/browser/loader/navigation_resource_handler.cc |
| index 6e1694be6cdabb8555bb05bcc77362db99c4bdef..f38dc2a1b4a89b157aba617cb6e4c88503afaecb 100644 |
| --- a/content/browser/loader/navigation_resource_handler.cc |
| +++ b/content/browser/loader/navigation_resource_handler.cc |
| @@ -1,36 +1,42 @@ |
| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "content/browser/loader/navigation_resource_handler.h" |
| +#include <memory> |
| + |
| #include "base/logging.h" |
| #include "content/browser/devtools/devtools_netlog_observer.h" |
| #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| #include "content/browser/loader/resource_request_info_impl.h" |
| #include "content/browser/resource_context_impl.h" |
| #include "content/browser/streams/stream.h" |
| #include "content/browser/streams/stream_context.h" |
| +#include "content/public/browser/navigation_data.h" |
| #include "content/public/browser/resource_controller.h" |
| +#include "content/public/browser/resource_dispatcher_host_delegate.h" |
| #include "content/public/browser/stream_handle.h" |
| #include "content/public/common/resource_response.h" |
| #include "net/base/net_errors.h" |
| #include "net/url_request/url_request.h" |
| namespace content { |
| NavigationResourceHandler::NavigationResourceHandler( |
| net::URLRequest* request, |
| - NavigationURLLoaderImplCore* core) |
| + NavigationURLLoaderImplCore* core, |
| + ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate) |
| : ResourceHandler(request), |
| - core_(core) { |
| + core_(core), |
| + resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate) { |
| core_->set_resource_handler(this); |
| writer_.set_immediate_mode(true); |
| } |
| NavigationResourceHandler::~NavigationResourceHandler() { |
| if (core_) { |
| core_->NotifyRequestFailed(false, net::ERR_ABORTED); |
| DetachFromCore(); |
| } |
| } |
| @@ -85,22 +91,36 @@ bool NavigationResourceHandler::OnResponseStarted(ResourceResponse* response, |
| // dispatched at the navigation layer. |
| if (info->IsDownload() || info->is_stream()) |
| return true; |
| StreamContext* stream_context = |
| GetStreamContextForResourceContext(info->GetContext()); |
| writer_.InitializeStream(stream_context->registry(), |
| request()->url().GetOrigin()); |
| DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
| - core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); |
| + |
| + std::unique_ptr<NavigationData> cloned_data; |
|
mmenke
2016/05/06 18:59:36
Should this be std::unique_ptr<const NavigationDat
RyanSturm
2016/05/06 20:55:44
Done.
|
| + if (resource_dispatcher_host_delegate_) { |
| + // Ask the embedder for a NavigationData instance. |
| + NavigationData* navigation_data = |
| + resource_dispatcher_host_delegate_->GetNavigationData(request()); |
| + |
| + // Clone the embedder's NavigationData before moving it to the UI thread. |
| + if (navigation_data) |
| + cloned_data = navigation_data->Clone(); |
| + } |
| + |
| + core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), |
| + std::move(cloned_data)); |
| *defer = true; |
| + |
| return true; |
| } |
| bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| return true; |
| } |
| bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, |
| bool* defer) { |
| return true; |