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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 96 |
| 97 ResourceRequestInfoImpl* info = GetRequestInfo(); | 97 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 98 | 98 |
| 99 // If the MimeTypeResourceHandler intercepted this request and converted it | 99 // If the MimeTypeResourceHandler intercepted this request and converted it |
| 100 // into a download, it will still call OnResponseStarted and immediately | 100 // into a download, it will still call OnResponseStarted and immediately |
| 101 // cancel. Ignore the call; OnReadCompleted will happen shortly. | 101 // cancel. Ignore the call; OnReadCompleted will happen shortly. |
| 102 // | 102 // |
| 103 // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps | 103 // TODO(davidben): Move the dispatch out of MimeTypeResourceHandler. Perhaps |
| 104 // all the way to the UI thread. Downloads, user certificates, etc., should be | 104 // all the way to the UI thread. Downloads, user certificates, etc., should be |
| 105 // dispatched at the navigation layer. | 105 // dispatched at the navigation layer. |
| 106 if (info->IsDownload() || info->is_stream()) | 106 if (info->IsDownload()) |
| 107 return true; | 107 return true; |
| 108 | 108 |
| 109 StreamContext* stream_context = | 109 StreamContext* stream_context = |
| 110 GetStreamContextForResourceContext(info->GetContext()); | 110 GetStreamContextForResourceContext(info->GetContext()); |
| 111 writer_.InitializeStream(stream_context->registry(), | 111 writer_.InitializeStream(stream_context->registry(), |
| 112 request()->url().GetOrigin()); | 112 request()->url().GetOrigin()); |
| 113 | 113 |
| 114 NetLogObserver::PopulateResponseInfo(request(), response); | 114 NetLogObserver::PopulateResponseInfo(request(), response); |
| 115 | 115 |
| 116 std::unique_ptr<NavigationData> cloned_data; | 116 std::unique_ptr<NavigationData> cloned_data; |
| 117 if (resource_dispatcher_host_delegate_) { | 117 if (resource_dispatcher_host_delegate_) { |
| 118 // Ask the embedder for a NavigationData instance. | 118 // Ask the embedder for a NavigationData instance. |
| 119 NavigationData* navigation_data = | 119 NavigationData* navigation_data = |
| 120 resource_dispatcher_host_delegate_->GetNavigationData(request()); | 120 resource_dispatcher_host_delegate_->GetNavigationData(request()); |
| 121 | 121 |
| 122 // Clone the embedder's NavigationData before moving it to the UI thread. | 122 // Clone the embedder's NavigationData before moving it to the UI thread. |
| 123 if (navigation_data) | 123 if (navigation_data) |
| 124 cloned_data = navigation_data->Clone(); | 124 cloned_data = navigation_data->Clone(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 SSLStatus ssl_status; | 127 SSLStatus ssl_status; |
| 128 if (request()->ssl_info().cert.get()) { | 128 if (request()->ssl_info().cert.get()) { |
| 129 GetSSLStatusForRequest(request()->url(), request()->ssl_info(), | 129 GetSSLStatusForRequest(request()->url(), request()->ssl_info(), |
| 130 info->GetChildID(), &ssl_status); | 130 info->GetChildID(), &ssl_status); |
| 131 } | 131 } |
| 132 | 132 |
| 133 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), | 133 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(), |
| 134 ssl_status, std::move(cloned_data)); | 134 ssl_status, std::move(cloned_data)); |
| 135 *defer = true; | 135 // Don't defer stream based requests. This includes requests initiated via |
| 136 | 136 // mime type sniffing, etc. |
| 137 if (!info->is_stream()) | |
|
ananta
2016/09/14 02:14:16
Deferring this causes a DCHECK to fire in Intercep
| |
| 138 *defer = true; | |
| 137 return true; | 139 return true; |
| 138 } | 140 } |
| 139 | 141 |
| 140 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { | 142 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| 141 return true; | 143 return true; |
| 142 } | 144 } |
| 143 | 145 |
| 144 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 146 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 145 int* buf_size, | 147 int* buf_size, |
| 146 int min_size) { | 148 int min_size) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 177 NOTREACHED(); | 179 NOTREACHED(); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void NavigationResourceHandler::DetachFromCore() { | 182 void NavigationResourceHandler::DetachFromCore() { |
| 181 DCHECK(core_); | 183 DCHECK(core_); |
| 182 core_->set_resource_handler(nullptr); | 184 core_->set_resource_handler(nullptr); |
| 183 core_ = nullptr; | 185 core_ = nullptr; |
| 184 } | 186 } |
| 185 | 187 |
| 186 } // namespace content | 188 } // namespace content |
| OLD | NEW |