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 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 // The response started on the IO thread and is ready to be committed. This | 46 // The response started on the IO thread and is ready to be committed. This |
47 // is one of the two final states for the request. | 47 // is one of the two final states for the request. |
48 RESPONSE_STARTED, | 48 RESPONSE_STARTED, |
49 | 49 |
50 // The request failed on the IO thread and an error page should be | 50 // The request failed on the IO thread and an error page should be |
51 // displayed. This is one of the two final states for the request. | 51 // displayed. This is one of the two final states for the request. |
52 FAILED, | 52 FAILED, |
53 }; | 53 }; |
54 | 54 |
55 static scoped_ptr<NavigationRequest> Create( | 55 // Creates a request for a browser-intiated navigation. |
56 FrameTreeNode* frame_tree_node, | 56 static scoped_ptr<NavigationRequest> CreateBrowserInitiated( |
57 const NavigationEntryImpl& entry, | 57 FrameTreeNode* frame_tree_node, |
58 FrameMsg_Navigate_Type::Value navigation_type, | 58 const NavigationEntryImpl& entry, |
59 base::TimeTicks navigation_start); | 59 FrameMsg_Navigate_Type::Value navigation_type, |
60 base::TimeTicks navigation_start); | |
60 | 61 |
61 NavigationRequest(FrameTreeNode* frame_tree_node, | 62 // Creates a request for a renderer-intiated navigation. |
62 const CommonNavigationParams& common_params, | 63 // Note: |body| is sent to the IO thread when calling BeginNavigation, and |
63 const CommitNavigationParams& commit_params, | 64 // should no longer be manipulated afterwards on the UI thread. |
64 const NavigationEntryImpl* navitation_entry); | 65 static scoped_ptr<NavigationRequest> CreateRendererInitiated( |
66 FrameTreeNode* frame_tree_node, | |
67 const CommonNavigationParams& common_params, | |
68 const BeginNavigationParams& begin_params, | |
69 scoped_refptr<ResourceRequestBody> body); | |
65 | 70 |
66 ~NavigationRequest() override; | 71 ~NavigationRequest() override; |
67 | 72 |
68 // Called on the UI thread by the RenderFrameHostManager which owns the | 73 // Called on the UI thread by the Navigator to start the navigation on the IO |
69 // NavigationRequest. Takes ownership of |info|. After calling this function, | 74 // thread. After calling this function, |body_| can no longer be manipulated |
davidben
2015/02/03 02:23:20
body_ doesn't seem to exist. I think this sentence
clamy
2015/02/03 16:17:09
Done.
| |
70 // |body| can no longer be manipulated on the UI thread. | 75 // on the UI thread. |
71 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, | 76 void BeginNavigation(); |
72 scoped_refptr<ResourceRequestBody> body); | |
73 | 77 |
74 CommonNavigationParams& common_params() { return common_params_; } | 78 CommonNavigationParams& common_params() { return common_params_; } |
davidben
2015/02/03 02:23:21
I think this is no longer needed now that Navigato
carlosk
2015/02/03 16:06:02
It's still needed because it's accessed in some pl
clamy
2015/02/03 16:17:09
We already have a const accessor, so I removed the
| |
75 | 79 |
76 const CommonNavigationParams& common_params() const { return common_params_; } | 80 const CommonNavigationParams& common_params() const { return common_params_; } |
77 | 81 |
78 const CommitNavigationParams& commit_params() const { return commit_params_; } | 82 const CommitNavigationParams& commit_params() const { return commit_params_; } |
79 | 83 |
80 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } | 84 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } |
81 | 85 |
82 NavigationState state() const { return state_; } | 86 NavigationState state() const { return state_; } |
83 | 87 |
84 SiteInstanceImpl* source_site_instance() const { | 88 SiteInstanceImpl* source_site_instance() const { |
85 return source_site_instance_.get(); | 89 return source_site_instance_.get(); |
86 } | 90 } |
87 | 91 |
88 SiteInstanceImpl* dest_site_instance() const { | 92 SiteInstanceImpl* dest_site_instance() const { |
89 return dest_site_instance_.get(); | 93 return dest_site_instance_.get(); |
90 } | 94 } |
91 | 95 |
92 NavigationEntryImpl::RestoreType restore_type() const { | 96 NavigationEntryImpl::RestoreType restore_type() const { |
93 return restore_type_; | 97 return restore_type_; |
94 }; | 98 }; |
95 | 99 |
96 bool is_view_source() const { return is_view_source_; }; | 100 bool is_view_source() const { return is_view_source_; }; |
97 | 101 |
98 int bindings() const { return bindings_; }; | 102 int bindings() const { return bindings_; }; |
99 | 103 |
104 bool browser_initiated() const { return browser_initiated_ ; } | |
105 | |
100 void SetWaitingForRendererResponse() { | 106 void SetWaitingForRendererResponse() { |
101 DCHECK(state_ == NOT_STARTED); | 107 DCHECK(state_ == NOT_STARTED); |
102 state_ = WAITING_FOR_RENDERER_RESPONSE; | 108 state_ = WAITING_FOR_RENDERER_RESPONSE; |
103 } | 109 } |
104 | 110 |
105 private: | 111 private: |
112 NavigationRequest(FrameTreeNode* frame_tree_node, | |
113 const CommonNavigationParams& common_params, | |
114 const BeginNavigationParams& begin_params, | |
115 const CommitNavigationParams& commit_params, | |
116 scoped_refptr<ResourceRequestBody> body, | |
117 bool browser_initiated, | |
118 const NavigationEntryImpl* navitation_entry); | |
119 | |
106 // NavigationURLLoaderDelegate implementation. | 120 // NavigationURLLoaderDelegate implementation. |
107 void OnRequestRedirected( | 121 void OnRequestRedirected( |
108 const net::RedirectInfo& redirect_info, | 122 const net::RedirectInfo& redirect_info, |
109 const scoped_refptr<ResourceResponse>& response) override; | 123 const scoped_refptr<ResourceResponse>& response) override; |
110 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 124 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
111 scoped_ptr<StreamHandle> body) override; | 125 scoped_ptr<StreamHandle> body) override; |
112 void OnRequestFailed(int net_error) override; | 126 void OnRequestFailed(int net_error) override; |
113 | 127 |
114 FrameTreeNode* frame_tree_node_; | 128 FrameTreeNode* frame_tree_node_; |
115 | 129 |
116 // Initialized on creation of the NavigationRequest. Sent to the renderer when | 130 // Initialized on creation of the NavigationRequest. Sent to the renderer when |
117 // the navigation is ready to commit. | 131 // the navigation is ready to commit. |
118 // Note: When the navigation is ready to commit, the url in |common_params| | 132 // Note: When the navigation is ready to commit, the url in |common_params| |
119 // will be set to the final navigation url, obtained after following all | 133 // will be set to the final navigation url, obtained after following all |
120 // redirects. | 134 // redirects. |
121 CommonNavigationParams common_params_; | 135 CommonNavigationParams common_params_; |
carlosk
2015/02/03 16:06:02
I think this one could become const as well.
clamy
2015/02/03 16:17:09
No, because redirects will modify the url there.
| |
136 const BeginNavigationParams begin_params_; | |
122 const CommitNavigationParams commit_params_; | 137 const CommitNavigationParams commit_params_; |
138 const bool browser_initiated_; | |
123 | 139 |
124 NavigationState state_; | 140 NavigationState state_; |
125 | 141 |
142 | |
143 // The parameters to send to the IO thread. |loader_| takes ownership of | |
144 // |info_| after calling BeginNavigation. | |
145 scoped_ptr<NavigationRequestInfo> info_; | |
146 | |
126 scoped_ptr<NavigationURLLoader> loader_; | 147 scoped_ptr<NavigationURLLoader> loader_; |
127 | 148 |
128 // These next items are used in browser-initiated navigations to store | 149 // These next items are used in browser-initiated navigations to store |
129 // information from the NavigationEntryImpl that is required after request | 150 // information from the NavigationEntryImpl that is required after request |
130 // creation time. | 151 // creation time. |
131 scoped_refptr<SiteInstanceImpl> source_site_instance_; | 152 scoped_refptr<SiteInstanceImpl> source_site_instance_; |
132 scoped_refptr<SiteInstanceImpl> dest_site_instance_; | 153 scoped_refptr<SiteInstanceImpl> dest_site_instance_; |
133 NavigationEntryImpl::RestoreType restore_type_; | 154 NavigationEntryImpl::RestoreType restore_type_; |
134 bool is_view_source_; | 155 bool is_view_source_; |
135 int bindings_; | 156 int bindings_; |
136 | 157 |
137 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); | 158 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); |
138 }; | 159 }; |
139 | 160 |
140 } // namespace content | 161 } // namespace content |
141 | 162 |
142 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 163 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
OLD | NEW |