OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
6 #define CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 6 #define CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | |
16 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 16 #include "content/browser/loader/resource_requester_info.h" |
18 #include "content/common/resource_request_body_impl.h" | 17 #include "content/common/resource_request_body_impl.h" |
19 #include "content/public/browser/navigation_ui_data.h" | 18 #include "content/public/browser/navigation_ui_data.h" |
20 #include "content/public/browser/resource_request_info.h" | 19 #include "content/public/browser/resource_request_info.h" |
21 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
22 #include "content/public/common/resource_type.h" | 21 #include "content/public/common/resource_type.h" |
23 #include "net/base/load_states.h" | 22 #include "net/base/load_states.h" |
24 | 23 |
25 namespace content { | 24 namespace content { |
26 class DetachableResourceHandler; | 25 class DetachableResourceHandler; |
27 class ResourceContext; | 26 class ResourceContext; |
28 class ResourceMessageFilter; | |
29 struct GlobalRequestID; | 27 struct GlobalRequestID; |
30 struct GlobalRoutingID; | 28 struct GlobalRoutingID; |
31 | 29 |
32 // Holds the data ResourceDispatcherHost associates with each request. | 30 // Holds the data ResourceDispatcherHost associates with each request. |
33 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. | 31 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. |
34 class ResourceRequestInfoImpl : public ResourceRequestInfo, | 32 class ResourceRequestInfoImpl : public ResourceRequestInfo, |
35 public base::SupportsUserData::Data { | 33 public base::SupportsUserData::Data { |
36 public: | 34 public: |
37 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. | 35 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. |
38 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( | 36 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( |
39 net::URLRequest* request); | 37 net::URLRequest* request); |
40 | 38 |
41 // And, a const version for cases where you only need read access. | 39 // And, a const version for cases where you only need read access. |
42 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( | 40 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( |
43 const net::URLRequest* request); | 41 const net::URLRequest* request); |
44 | 42 |
45 CONTENT_EXPORT ResourceRequestInfoImpl( | 43 CONTENT_EXPORT ResourceRequestInfoImpl( |
46 int process_type, | 44 scoped_refptr<ResourceRequesterInfo> requester_info, |
47 int child_id, | |
48 int route_id, | 45 int route_id, |
49 int frame_tree_node_id, | 46 int frame_tree_node_id, |
50 int origin_pid, | 47 int origin_pid, |
51 int request_id, | 48 int request_id, |
52 int render_frame_id, | 49 int render_frame_id, |
53 bool is_main_frame, | 50 bool is_main_frame, |
54 bool parent_is_main_frame, | 51 bool parent_is_main_frame, |
55 ResourceType resource_type, | 52 ResourceType resource_type, |
56 ui::PageTransition transition_type, | 53 ui::PageTransition transition_type, |
57 bool should_replace_current_entry, | 54 bool should_replace_current_entry, |
58 bool is_download, | 55 bool is_download, |
59 bool is_stream, | 56 bool is_stream, |
60 bool allow_download, | 57 bool allow_download, |
61 bool has_user_gesture, | 58 bool has_user_gesture, |
62 bool enable_load_timing, | 59 bool enable_load_timing, |
63 bool enable_upload_progress, | 60 bool enable_upload_progress, |
64 bool do_not_prompt_for_login, | 61 bool do_not_prompt_for_login, |
65 blink::WebReferrerPolicy referrer_policy, | 62 blink::WebReferrerPolicy referrer_policy, |
66 blink::WebPageVisibilityState visibility_state, | 63 blink::WebPageVisibilityState visibility_state, |
67 ResourceContext* context, | 64 ResourceContext* context, |
68 base::WeakPtr<ResourceMessageFilter> filter, | |
69 bool report_raw_headers, | 65 bool report_raw_headers, |
70 bool is_async, | 66 bool is_async, |
71 bool is_using_lofi, | 67 bool is_using_lofi, |
72 const std::string& original_headers, | 68 const std::string& original_headers, |
73 const scoped_refptr<ResourceRequestBodyImpl> body, | 69 const scoped_refptr<ResourceRequestBodyImpl> body, |
74 bool initiated_in_secure_context); | 70 bool initiated_in_secure_context); |
75 ~ResourceRequestInfoImpl() override; | 71 ~ResourceRequestInfoImpl() override; |
76 | 72 |
77 // ResourceRequestInfo implementation: | 73 // ResourceRequestInfo implementation: |
78 WebContentsGetter GetWebContentsGetterForRequest() const override; | 74 WebContentsGetter GetWebContentsGetterForRequest() const override; |
(...skipping 24 matching lines...) Expand all Loading... | |
103 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); | 99 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); |
104 | 100 |
105 CONTENT_EXPORT int GetRequestID() const; | 101 CONTENT_EXPORT int GetRequestID() const; |
106 GlobalRoutingID GetGlobalRoutingID() const; | 102 GlobalRoutingID GetGlobalRoutingID() const; |
107 | 103 |
108 // PlzNavigate | 104 // PlzNavigate |
109 // The id of the FrameTreeNode that initiated this request (for a navigation | 105 // The id of the FrameTreeNode that initiated this request (for a navigation |
110 // request). | 106 // request). |
111 int frame_tree_node_id() const { return frame_tree_node_id_; } | 107 int frame_tree_node_id() const { return frame_tree_node_id_; } |
112 | 108 |
113 // May be NULL (e.g., if process dies during a transfer). | 109 ResourceRequesterInfo& requester_info() { return *requester_info_; } |
mmenke
2016/11/22 17:44:12
Returning non-const references is forbidden. Retu
horo
2016/11/24 04:07:11
Done.
| |
114 ResourceMessageFilter* filter() const { | |
115 return filter_.get(); | |
116 } | |
117 | 110 |
118 // Updates the data associated with this request after it is is transferred | 111 // Updates the data associated with this request after it is is transferred |
119 // to a new renderer process. Not all data will change during a transfer. | 112 // to a new renderer process. Not all data will change during a transfer. |
120 // We do not expect the ResourceContext to change during navigation, so that | 113 // We do not expect the ResourceContext to change during navigation, so that |
121 // does not need to be updated. | 114 // does not need to be updated. |
122 void UpdateForTransfer(int child_id, | 115 void UpdateForTransfer(int route_id, |
123 int route_id, | |
124 int render_frame_id, | 116 int render_frame_id, |
125 int origin_pid, | 117 int origin_pid, |
126 int request_id, | 118 int request_id, |
127 base::WeakPtr<ResourceMessageFilter> filter); | 119 ResourceRequesterInfo* requester_info); |
128 | 120 |
129 // Whether this request is part of a navigation that should replace the | 121 // Whether this request is part of a navigation that should replace the |
130 // current session history entry. This state is shuffled up and down the stack | 122 // current session history entry. This state is shuffled up and down the stack |
131 // for request transfers. | 123 // for request transfers. |
132 bool should_replace_current_entry() const { | 124 bool should_replace_current_entry() const { |
133 return should_replace_current_entry_; | 125 return should_replace_current_entry_; |
134 } | 126 } |
135 | 127 |
136 // DetachableResourceHandler for this request. May be NULL. | 128 // DetachableResourceHandler for this request. May be NULL. |
137 DetachableResourceHandler* detachable_handler() const { | 129 DetachableResourceHandler* detachable_handler() const { |
138 return detachable_handler_; | 130 return detachable_handler_; |
139 } | 131 } |
140 void set_detachable_handler(DetachableResourceHandler* h) { | 132 void set_detachable_handler(DetachableResourceHandler* h) { |
141 detachable_handler_ = h; | 133 detachable_handler_ = h; |
142 } | 134 } |
143 | 135 |
144 // Identifies the type of process (renderer, plugin, etc.) making the request. | |
145 int process_type() const { return process_type_; } | |
146 | |
147 // Downloads are allowed only as a top level request. | 136 // Downloads are allowed only as a top level request. |
148 bool allow_download() const { return allow_download_; } | 137 bool allow_download() const { return allow_download_; } |
149 | 138 |
150 // Whether this is a download. | 139 // Whether this is a download. |
151 void set_is_download(bool download) { is_download_ = download; } | 140 void set_is_download(bool download) { is_download_ = download; } |
152 | 141 |
153 // Whether this is a stream. | 142 // Whether this is a stream. |
154 bool is_stream() const { return is_stream_; } | 143 bool is_stream() const { return is_stream_; } |
155 void set_is_stream(bool stream) { is_stream_ = stream; } | 144 void set_is_stream(bool stream) { is_stream_ = stream; } |
156 | 145 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 } | 180 } |
192 void set_initiated_in_secure_context_for_testing(bool secure) { | 181 void set_initiated_in_secure_context_for_testing(bool secure) { |
193 initiated_in_secure_context_ = secure; | 182 initiated_in_secure_context_ = secure; |
194 } | 183 } |
195 | 184 |
196 void set_navigation_ui_data( | 185 void set_navigation_ui_data( |
197 std::unique_ptr<NavigationUIData> navigation_ui_data) { | 186 std::unique_ptr<NavigationUIData> navigation_ui_data) { |
198 navigation_ui_data_ = std::move(navigation_ui_data); | 187 navigation_ui_data_ = std::move(navigation_ui_data); |
199 } | 188 } |
200 | 189 |
201 // PlzNavigate: used in navigations to store the ServiceWorkerContext, since | |
202 // the ResourceMessageFilter will be null in this case. All other requests | |
203 // should access the ServiceWorkerContext through the ResourceMessageFilter. | |
204 void set_service_worker_context( | |
205 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { | |
206 service_worker_context_ = service_worker_context; | |
207 } | |
208 ServiceWorkerContextWrapper* service_worker_context() const { | |
209 return service_worker_context_.get(); | |
210 } | |
211 | |
212 private: | 190 private: |
213 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 191 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
214 DeletedFilterDetached); | 192 DeletedFilterDetached); |
215 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 193 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
216 DeletedFilterDetachedRedirect); | 194 DeletedFilterDetachedRedirect); |
217 // Non-owning, may be NULL. | 195 // Non-owning, may be NULL. |
218 DetachableResourceHandler* detachable_handler_; | 196 DetachableResourceHandler* detachable_handler_; |
219 | 197 |
220 int process_type_; | 198 scoped_refptr<ResourceRequesterInfo> requester_info_; |
221 int child_id_; | |
222 int route_id_; | 199 int route_id_; |
223 const int frame_tree_node_id_; | 200 const int frame_tree_node_id_; |
224 int origin_pid_; | 201 int origin_pid_; |
225 int request_id_; | 202 int request_id_; |
226 int render_frame_id_; | 203 int render_frame_id_; |
227 bool is_main_frame_; | 204 bool is_main_frame_; |
228 bool parent_is_main_frame_; | 205 bool parent_is_main_frame_; |
229 bool should_replace_current_entry_; | 206 bool should_replace_current_entry_; |
230 bool is_download_; | 207 bool is_download_; |
231 bool is_stream_; | 208 bool is_stream_; |
232 bool allow_download_; | 209 bool allow_download_; |
233 bool has_user_gesture_; | 210 bool has_user_gesture_; |
234 bool enable_load_timing_; | 211 bool enable_load_timing_; |
235 bool enable_upload_progress_; | 212 bool enable_upload_progress_; |
236 bool do_not_prompt_for_login_; | 213 bool do_not_prompt_for_login_; |
237 bool was_ignored_by_handler_; | 214 bool was_ignored_by_handler_; |
238 bool counted_as_in_flight_request_; | 215 bool counted_as_in_flight_request_; |
239 ResourceType resource_type_; | 216 ResourceType resource_type_; |
240 ui::PageTransition transition_type_; | 217 ui::PageTransition transition_type_; |
241 int memory_cost_; | 218 int memory_cost_; |
242 blink::WebReferrerPolicy referrer_policy_; | 219 blink::WebReferrerPolicy referrer_policy_; |
243 blink::WebPageVisibilityState visibility_state_; | 220 blink::WebPageVisibilityState visibility_state_; |
244 ResourceContext* context_; | 221 ResourceContext* context_; |
245 // The filter might be deleted without deleting this object if the process | |
246 // exits during a transfer. | |
247 base::WeakPtr<ResourceMessageFilter> filter_; | |
248 bool report_raw_headers_; | 222 bool report_raw_headers_; |
249 bool is_async_; | 223 bool is_async_; |
250 bool is_using_lofi_; | 224 bool is_using_lofi_; |
251 const std::string original_headers_; | 225 const std::string original_headers_; |
252 scoped_refptr<ResourceRequestBodyImpl> body_; | 226 scoped_refptr<ResourceRequestBodyImpl> body_; |
253 bool initiated_in_secure_context_; | 227 bool initiated_in_secure_context_; |
254 std::unique_ptr<NavigationUIData> navigation_ui_data_; | 228 std::unique_ptr<NavigationUIData> navigation_ui_data_; |
255 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
256 | 229 |
257 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); | 230 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); |
258 }; | 231 }; |
259 | 232 |
260 } // namespace content | 233 } // namespace content |
261 | 234 |
262 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 235 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
OLD | NEW |