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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 1257553002: [Proof-of-concept] PlzNavigate and Service Worker Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass navigation_provider_id Created 5 years, 4 months 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/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "content/browser/frame_host/frame_tree.h" 7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/frame_host/frame_tree_node.h" 8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "content/browser/frame_host/navigation_controller_impl.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h"
10 #include "content/browser/frame_host/navigation_request_info.h" 10 #include "content/browser/frame_host/navigation_request_info.h"
11 #include "content/browser/frame_host/navigator.h" 11 #include "content/browser/frame_host/navigator.h"
12 #include "content/browser/loader/navigation_url_loader.h" 12 #include "content/browser/loader/navigation_url_loader.h"
13 #include "content/browser/site_instance_impl.h" 13 #include "content/browser/site_instance_impl.h"
14 #include "content/common/resource_request_body.h" 14 #include "content/common/resource_request_body.h"
15 #include "content/common/service_worker/service_worker_types.h"
15 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/stream_handle.h" 17 #include "content/public/browser/stream_handle.h"
17 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/http/http_request_headers.h" 20 #include "net/http/http_request_headers.h"
20 #include "net/url_request/redirect_info.h" 21 #include "net/url_request/redirect_info.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 namespace { 25 namespace {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 loader_ = NavigationURLLoader::Create( 182 loader_ = NavigationURLLoader::Create(
182 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 183 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
183 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this); 184 frame_tree_node_->frame_tree_node_id(), info_.Pass(), this);
184 return true; 185 return true;
185 } 186 }
186 187
187 // There is no need to make a network request for this navigation, so commit 188 // There is no need to make a network request for this navigation, so commit
188 // it immediately. 189 // it immediately.
189 state_ = RESPONSE_STARTED; 190 state_ = RESPONSE_STARTED;
190 frame_tree_node_->navigator()->CommitNavigation( 191 frame_tree_node_->navigator()->CommitNavigation(
191 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); 192 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>(),
193 kInvalidServiceWorkerProviderId);
192 return false; 194 return false;
193 195
194 // TODO(davidben): Fire (and add as necessary) observer methods such as 196 // TODO(davidben): Fire (and add as necessary) observer methods such as
195 // DidStartProvisionalLoadForFrame for the navigation. 197 // DidStartProvisionalLoadForFrame for the navigation.
196 } 198 }
197 199
198 void NavigationRequest::OnRequestRedirected( 200 void NavigationRequest::OnRequestRedirected(
199 const net::RedirectInfo& redirect_info, 201 const net::RedirectInfo& redirect_info,
200 const scoped_refptr<ResourceResponse>& response) { 202 const scoped_refptr<ResourceResponse>& response) {
201 // TODO(davidben): Track other changes from redirects. These are important 203 // TODO(davidben): Track other changes from redirects. These are important
202 // for, e.g., reloads. 204 // for, e.g., reloads.
203 common_params_.url = redirect_info.new_url; 205 common_params_.url = redirect_info.new_url;
204 206
205 // TODO(davidben): This where prerender and navigation_interceptor should be 207 // TODO(davidben): This where prerender and navigation_interceptor should be
206 // integrated. For now, just always follow all redirects. 208 // integrated. For now, just always follow all redirects.
207 loader_->FollowRedirect(); 209 loader_->FollowRedirect();
208 } 210 }
209 211
210 void NavigationRequest::OnResponseStarted( 212 void NavigationRequest::OnResponseStarted(
211 const scoped_refptr<ResourceResponse>& response, 213 const scoped_refptr<ResourceResponse>& response,
212 scoped_ptr<StreamHandle> body) { 214 scoped_ptr<StreamHandle> body,
215 int navigation_provider_id) {
213 DCHECK(state_ == STARTED); 216 DCHECK(state_ == STARTED);
214 state_ = RESPONSE_STARTED; 217 state_ = RESPONSE_STARTED;
215 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, 218 frame_tree_node_->navigator()->CommitNavigation(
216 response.get(), body.Pass()); 219 frame_tree_node_, response.get(), body.Pass(), navigation_provider_id);
217 } 220 }
218 221
219 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, 222 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache,
220 int net_error) { 223 int net_error) {
221 DCHECK(state_ == STARTED); 224 DCHECK(state_ == STARTED);
222 state_ = FAILED; 225 state_ = FAILED;
223 frame_tree_node_->navigator()->FailedNavigation( 226 frame_tree_node_->navigator()->FailedNavigation(
224 frame_tree_node_, has_stale_copy_in_cache, net_error); 227 frame_tree_node_, has_stale_copy_in_cache, net_error);
225 } 228 }
226 229
227 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 230 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
228 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 231 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
229 common_params_.url); 232 common_params_.url);
230 } 233 }
231 234
232 } // namespace content 235 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698