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/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 state_ = RESPONSE_STARTED; | |
nasko
2014/12/16 01:40:26
DCHECK that the request has started?
clamy
2014/12/17 15:47:57
Done.
| |
58 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, | 62 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, |
59 response.get(), body.Pass()); | 63 response.get(), body.Pass()); |
60 } | 64 } |
61 | 65 |
62 void NavigationRequest::OnRequestFailed(int net_error) { | 66 void NavigationRequest::OnRequestFailed(int net_error) { |
67 state_ = FAILED; | |
nasko
2014/12/16 01:40:26
Similarly here, we shouldn't reach this code unles
clamy
2014/12/17 15:47:57
Done.
| |
63 // TODO(davidben): Network failures should display a network error page. | 68 // TODO(davidben): Network failures should display a network error page. |
64 NOTIMPLEMENTED(); | 69 NOTIMPLEMENTED(); |
65 } | 70 } |
66 | 71 |
67 } // namespace content | 72 } // namespace content |
OLD | NEW |