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

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

Issue 761013003: PlzNavigate: add support in several navigation controller unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Nasko's comments Created 6 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/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "content/browser/frame_host/frame_tree_node.h" 7 #include "content/browser/frame_host/frame_tree_node.h"
8 #include "content/browser/frame_host/navigation_request_info.h" 8 #include "content/browser/frame_host/navigation_request_info.h"
9 #include "content/browser/frame_host/navigator.h" 9 #include "content/browser/frame_host/navigator.h"
10 #include "content/browser/loader/navigation_url_loader.h" 10 #include "content/browser/loader/navigation_url_loader.h"
11 #include "content/common/resource_request_body.h" 11 #include "content/common/resource_request_body.h"
12 #include "content/public/browser/navigation_controller.h" 12 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/stream_handle.h" 13 #include "content/public/browser/stream_handle.h"
14 #include "net/url_request/redirect_info.h" 14 #include "net/url_request/redirect_info.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 NavigationRequest::NavigationRequest( 18 NavigationRequest::NavigationRequest(
19 FrameTreeNode* frame_tree_node, 19 FrameTreeNode* frame_tree_node,
20 const CommonNavigationParams& common_params, 20 const CommonNavigationParams& common_params,
21 const CommitNavigationParams& commit_params) 21 const CommitNavigationParams& commit_params)
22 : frame_tree_node_(frame_tree_node), 22 : frame_tree_node_(frame_tree_node),
23 common_params_(common_params), 23 common_params_(common_params),
24 commit_params_(commit_params) { 24 commit_params_(commit_params),
25 state_(NOT_STARTED) {
25 } 26 }
26 27
27 NavigationRequest::~NavigationRequest() { 28 NavigationRequest::~NavigationRequest() {
28 } 29 }
29 30
30 void NavigationRequest::BeginNavigation( 31 void NavigationRequest::BeginNavigation(
31 scoped_ptr<NavigationRequestInfo> info, 32 scoped_ptr<NavigationRequestInfo> info,
32 scoped_refptr<ResourceRequestBody> request_body) { 33 scoped_refptr<ResourceRequestBody> request_body) {
33 DCHECK(!loader_); 34 DCHECK(!loader_);
35 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
36 state_ = STARTED;
34 loader_ = NavigationURLLoader::Create( 37 loader_ = NavigationURLLoader::Create(
35 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 38 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
36 frame_tree_node_->frame_tree_node_id(), common_params_, info.Pass(), 39 frame_tree_node_->frame_tree_node_id(), common_params_, info.Pass(),
37 request_body.get(), this); 40 request_body.get(), this);
38 41
39 // TODO(davidben): Fire (and add as necessary) observer methods such as 42 // TODO(davidben): Fire (and add as necessary) observer methods such as
40 // DidStartProvisionalLoadForFrame for the navigation. 43 // DidStartProvisionalLoadForFrame for the navigation.
41 } 44 }
42 45
43 void NavigationRequest::OnRequestRedirected( 46 void NavigationRequest::OnRequestRedirected(
44 const net::RedirectInfo& redirect_info, 47 const net::RedirectInfo& redirect_info,
45 const scoped_refptr<ResourceResponse>& response) { 48 const scoped_refptr<ResourceResponse>& response) {
46 // TODO(davidben): Track other changes from redirects. These are important 49 // TODO(davidben): Track other changes from redirects. These are important
47 // for, e.g., reloads. 50 // for, e.g., reloads.
48 common_params_.url = redirect_info.new_url; 51 common_params_.url = redirect_info.new_url;
49 52
50 // TODO(davidben): This where prerender and navigation_interceptor should be 53 // TODO(davidben): This where prerender and navigation_interceptor should be
51 // integrated. For now, just always follow all redirects. 54 // integrated. For now, just always follow all redirects.
52 loader_->FollowRedirect(); 55 loader_->FollowRedirect();
53 } 56 }
54 57
55 void NavigationRequest::OnResponseStarted( 58 void NavigationRequest::OnResponseStarted(
56 const scoped_refptr<ResourceResponse>& response, 59 const scoped_refptr<ResourceResponse>& response,
57 scoped_ptr<StreamHandle> body) { 60 scoped_ptr<StreamHandle> body) {
61 DCHECK(state_ == STARTED);
62 state_ = RESPONSE_STARTED;
58 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, 63 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_,
59 response.get(), body.Pass()); 64 response.get(), body.Pass());
60 } 65 }
61 66
62 void NavigationRequest::OnRequestFailed(int net_error) { 67 void NavigationRequest::OnRequestFailed(int net_error) {
68 DCHECK(state_ == STARTED);
69 state_ = FAILED;
63 // TODO(davidben): Network failures should display a network error page. 70 // TODO(davidben): Network failures should display a network error page.
64 NOTIMPLEMENTED(); 71 NOTIMPLEMENTED();
65 } 72 }
66 73
67 } // namespace content 74 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698