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> | 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 *defer = true; | 87 *defer = true; |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool NavigationResourceHandler::OnResponseStarted(ResourceResponse* response, | 91 bool NavigationResourceHandler::OnResponseStarted(ResourceResponse* response, |
| 92 bool* defer) { | 92 bool* defer) { |
| 93 DCHECK(core_); | 93 DCHECK(core_); |
| 94 | 94 |
| 95 ResourceRequestInfoImpl* info = GetRequestInfo(); | 95 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 96 | 96 |
| 97 // If the MimeTypeResourceHandler intercepted this request and converted it | |
| 98 // into a download, it will still call OnResponseStarted and immediately | |
| 99 // cancel. Ignore the call; OnReadCompleted will happen shortly. | |
| 100 // | |
| 101 // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps | |
| 102 // all the way to the UI thread. Downloads, user certificates, etc., should be | |
| 103 // dispatched at the navigation layer. | |
| 104 if (info->IsDownload()) | |
| 105 return true; | |
| 106 | |
| 107 StreamContext* stream_context = | 97 StreamContext* stream_context = |
| 108 GetStreamContextForResourceContext(info->GetContext()); | 98 GetStreamContextForResourceContext(info->GetContext()); |
| 109 writer_.InitializeStream(stream_context->registry(), | 99 writer_.InitializeStream(stream_context->registry(), |
| 110 request()->url().GetOrigin()); | 100 request()->url().GetOrigin()); |
| 111 | 101 |
| 112 NetLogObserver::PopulateResponseInfo(request(), response); | 102 NetLogObserver::PopulateResponseInfo(request(), response); |
| 113 | 103 |
| 114 std::unique_ptr<NavigationData> cloned_data; | 104 std::unique_ptr<NavigationData> cloned_data; |
| 115 if (resource_dispatcher_host_delegate_) { | 105 if (resource_dispatcher_host_delegate_) { |
| 116 // Ask the embedder for a NavigationData instance. | 106 // Ask the embedder for a NavigationData instance. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 131 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), | 121 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), |
| 132 ssl_status, std::move(cloned_data), | 122 ssl_status, std::move(cloned_data), |
| 133 info->GetGlobalRequestID(), info->IsDownload(), | 123 info->GetGlobalRequestID(), info->IsDownload(), |
| 134 info->is_stream()); | 124 info->is_stream()); |
| 135 // Don't defer stream based requests. This includes requests initiated via | 125 // Don't defer stream based requests. This includes requests initiated via |
| 136 // mime type sniffing, etc. | 126 // mime type sniffing, etc. |
| 137 // TODO(ananta) | 127 // TODO(ananta) |
| 138 // Make sure that the requests go through the throttle checks. Currently this | 128 // Make sure that the requests go through the throttle checks. Currently this |
| 139 // does not work as the InterceptingResourceHandler is above us and hence it | 129 // does not work as the InterceptingResourceHandler is above us and hence it |
| 140 // does not expect the old handler to defer the request. | 130 // does not expect the old handler to defer the request. |
| 141 if (!info->is_stream()) | 131 // TODO(clamy): check if we should also make the downloads wait on the |
| 132 // NavigationThrottle checks be performed. | |
|
nasko
2016/12/22 18:16:09
Why wouldn't we want downloads to go through the t
clamy
2016/12/23 16:54:35
That doesn't work because of the InterceptingResou
| |
| 133 if (!info->is_stream() && !info->IsDownload()) | |
| 142 *defer = true; | 134 *defer = true; |
| 135 | |
| 143 return true; | 136 return true; |
| 144 } | 137 } |
| 145 | 138 |
| 146 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { | 139 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| 147 return true; | 140 return true; |
| 148 } | 141 } |
| 149 | 142 |
| 150 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 143 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 151 int* buf_size, | 144 int* buf_size, |
| 152 int min_size) { | 145 int min_size) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 180 NOTREACHED(); | 173 NOTREACHED(); |
| 181 } | 174 } |
| 182 | 175 |
| 183 void NavigationResourceHandler::DetachFromCore() { | 176 void NavigationResourceHandler::DetachFromCore() { |
| 184 DCHECK(core_); | 177 DCHECK(core_); |
| 185 core_->set_resource_handler(nullptr); | 178 core_->set_resource_handler(nullptr); |
| 186 core_ = nullptr; | 179 core_ = nullptr; |
| 187 } | 180 } |
| 188 | 181 |
| 189 } // namespace content | 182 } // namespace content |
| OLD | NEW |