Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Side by Side Diff: content/browser/loader/navigation_resource_handler.cc

Issue 2510083003: PlzNavigate: properly update NavigationHandle for 204/205 and download responses (Closed)
Patch Set: address comments of clamy@ Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
117 NavigationData* navigation_data = 107 NavigationData* navigation_data =
118 resource_dispatcher_host_delegate_->GetNavigationData(request()); 108 resource_dispatcher_host_delegate_->GetNavigationData(request());
119 109
120 // Clone the embedder's NavigationData before moving it to the UI thread. 110 // Clone the embedder's NavigationData before moving it to the UI thread.
121 if (navigation_data) 111 if (navigation_data)
122 cloned_data = navigation_data->Clone(); 112 cloned_data = navigation_data->Clone();
123 } 113 }
124 114
125 SSLStatus ssl_status; 115 SSLStatus ssl_status;
126 if (request()->ssl_info().cert.get()) { 116 if (request()->ssl_info().cert.get()) {
127 GetSSLStatusForRequest(request()->url(), request()->ssl_info(), 117 GetSSLStatusForRequest(request()->url(), request()->ssl_info(),
128 info->GetChildID(), &ssl_status); 118 info->GetChildID(), &ssl_status);
129 } 119 }
130 120
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
136 // mime type sniffing, etc. 126 // Don't defer stream based or download requests. This includes requests
127 // initiated via mime type sniffing, etc.
137 // TODO(ananta) 128 // TODO(ananta)
138 // Make sure that the requests go through the throttle checks. Currently this 129 // 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 130 // does not work as the InterceptingResourceHandler is above us and hence it
140 // does not expect the old handler to defer the request. 131 // does not expect the old handler to defer the request.
141 if (!info->is_stream()) 132 if (!info->is_stream() && !info->IsDownload())
142 *defer = true; 133 *defer = true;
134
135 if (info->IsDownload())
136 DetachFromCore();
137
143 return true; 138 return true;
144 } 139 }
145 140
146 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { 141 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) {
147 return true; 142 return true;
148 } 143 }
149 144
150 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf, 145 bool NavigationResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
151 int* buf_size, 146 int* buf_size,
152 int min_size) { 147 int min_size) {
(...skipping 27 matching lines...) Expand all
180 NOTREACHED(); 175 NOTREACHED();
181 } 176 }
182 177
183 void NavigationResourceHandler::DetachFromCore() { 178 void NavigationResourceHandler::DetachFromCore() {
184 DCHECK(core_); 179 DCHECK(core_);
185 core_->set_resource_handler(nullptr); 180 core_->set_resource_handler(nullptr);
186 core_ = nullptr; 181 core_ = nullptr;
187 } 182 }
188 183
189 } // namespace content 184 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.cc ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698