| 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 // TODO(ananta) |
| 138 // 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 |
| 140 // does not expect the old handler to defer the request. |
| 141 if (!info->is_stream()) |
| 142 *defer = true; |
| 137 return true; | 143 return true; |
| 138 } | 144 } |
| 139 | 145 |
| 140 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { | 146 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { |
| 141 return true; | 147 return true; |
| 142 } | 148 } |
| 143 | 149 |
| 144 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 150 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
| 145 int* buf_size, | 151 int* buf_size, |
| 146 int min_size) { | 152 int min_size) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 177 NOTREACHED(); | 183 NOTREACHED(); |
| 178 } | 184 } |
| 179 | 185 |
| 180 void NavigationResourceHandler::DetachFromCore() { | 186 void NavigationResourceHandler::DetachFromCore() { |
| 181 DCHECK(core_); | 187 DCHECK(core_); |
| 182 core_->set_resource_handler(nullptr); | 188 core_->set_resource_handler(nullptr); |
| 183 core_ = nullptr; | 189 core_ = nullptr; |
| 184 } | 190 } |
| 185 | 191 |
| 186 } // namespace content | 192 } // namespace content |
| OLD | NEW |