Chromium Code Reviews| 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> | |
| 8 | |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "content/browser/devtools/devtools_netlog_observer.h" | 10 #include "content/browser/devtools/devtools_netlog_observer.h" |
| 9 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 11 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| 12 #include "content/browser/loader/resource_dispatcher_host_impl.h" | |
| 10 #include "content/browser/loader/resource_request_info_impl.h" | 13 #include "content/browser/loader/resource_request_info_impl.h" |
| 11 #include "content/browser/resource_context_impl.h" | 14 #include "content/browser/resource_context_impl.h" |
| 12 #include "content/browser/streams/stream.h" | 15 #include "content/browser/streams/stream.h" |
| 13 #include "content/browser/streams/stream_context.h" | 16 #include "content/browser/streams/stream_context.h" |
| 17 #include "content/public/browser/navigation_data.h" | |
| 14 #include "content/public/browser/resource_controller.h" | 18 #include "content/public/browser/resource_controller.h" |
| 19 #include "content/public/browser/resource_dispatcher_host_delegate.h" | |
| 15 #include "content/public/browser/stream_handle.h" | 20 #include "content/public/browser/stream_handle.h" |
| 16 #include "content/public/common/resource_response.h" | 21 #include "content/public/common/resource_response.h" |
| 17 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 18 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 19 | 24 |
| 20 namespace content { | 25 namespace content { |
| 21 | 26 |
| 22 NavigationResourceHandler::NavigationResourceHandler( | 27 NavigationResourceHandler::NavigationResourceHandler( |
| 23 net::URLRequest* request, | 28 net::URLRequest* request, |
| 24 NavigationURLLoaderImplCore* core) | 29 NavigationURLLoaderImplCore* core, |
| 25 : ResourceHandler(request), | 30 ResourceDispatcherHostImpl* rdh) |
| 26 core_(core) { | 31 : ResourceHandler(request), core_(core), rdh_(rdh) { |
| 27 core_->set_resource_handler(this); | 32 core_->set_resource_handler(this); |
| 28 writer_.set_immediate_mode(true); | 33 writer_.set_immediate_mode(true); |
| 29 } | 34 } |
| 30 | 35 |
| 31 NavigationResourceHandler::~NavigationResourceHandler() { | 36 NavigationResourceHandler::~NavigationResourceHandler() { |
| 32 if (core_) { | 37 if (core_) { |
| 33 core_->NotifyRequestFailed(false, net::ERR_ABORTED); | 38 core_->NotifyRequestFailed(false, net::ERR_ABORTED); |
| 34 DetachFromCore(); | 39 DetachFromCore(); |
| 35 } | 40 } |
| 36 } | 41 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // dispatched at the navigation layer. | 90 // dispatched at the navigation layer. |
| 86 if (info->IsDownload() || info->is_stream()) | 91 if (info->IsDownload() || info->is_stream()) |
| 87 return true; | 92 return true; |
| 88 | 93 |
| 89 StreamContext* stream_context = | 94 StreamContext* stream_context = |
| 90 GetStreamContextForResourceContext(info->GetContext()); | 95 GetStreamContextForResourceContext(info->GetContext()); |
| 91 writer_.InitializeStream(stream_context->registry(), | 96 writer_.InitializeStream(stream_context->registry(), |
| 92 request()->url().GetOrigin()); | 97 request()->url().GetOrigin()); |
| 93 | 98 |
| 94 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); | 99 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
| 95 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); | 100 // Ask the embedder for a NavigationData instance. |
|
nasko
2016/04/26 20:18:39
nit: Empty line above comment.
RyanSturm
2016/04/27 23:27:47
Done.
| |
| 101 std::unique_ptr<NavigationData> navigation_data(nullptr); | |
| 102 if (rdh_ && rdh_->delegate()) | |
| 103 navigation_data = rdh_->delegate()->GetNavigationData(request()); | |
| 104 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), | |
| 105 navigation_data.get()); | |
|
nasko
2016/04/26 20:18:39
Why not clone the data here and pass it to the met
RyanSturm
2016/04/27 23:27:47
Done.
| |
| 96 *defer = true; | 106 *defer = true; |
| 107 | |
| 97 return true; | 108 return true; |
| 98 } | 109 } |
| 99 | 110 |
| 100 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { | 111 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| 101 return true; | 112 return true; |
| 102 } | 113 } |
| 103 | 114 |
| 104 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, | 115 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, |
| 105 bool* defer) { | 116 bool* defer) { |
| 106 return true; | 117 return true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 NOTREACHED(); | 154 NOTREACHED(); |
| 144 } | 155 } |
| 145 | 156 |
| 146 void NavigationResourceHandler::DetachFromCore() { | 157 void NavigationResourceHandler::DetachFromCore() { |
| 147 DCHECK(core_); | 158 DCHECK(core_); |
| 148 core_->set_resource_handler(nullptr); | 159 core_->set_resource_handler(nullptr); |
| 149 core_ = nullptr; | 160 core_ = nullptr; |
| 150 } | 161 } |
| 151 | 162 |
| 152 } // namespace content | 163 } // namespace content |
| OLD | NEW |