| 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 #include "content/browser/loader/resource_request_info_impl.h" | 5 #include "content/browser/loader/resource_request_info_impl.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/loader/global_routing_id.h" | 8 #include "content/browser/loader/global_routing_id.h" |
| 9 #include "content/browser/loader/resource_message_filter.h" | 9 #include "content/browser/loader/resource_message_filter.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 bool is_using_lofi) { | 55 bool is_using_lofi) { |
| 56 // Make sure both |is_main_frame| and |parent_is_main_frame| aren't set at the | 56 // Make sure both |is_main_frame| and |parent_is_main_frame| aren't set at the |
| 57 // same time. | 57 // same time. |
| 58 DCHECK(!(is_main_frame && parent_is_main_frame)); | 58 DCHECK(!(is_main_frame && parent_is_main_frame)); |
| 59 | 59 |
| 60 // Make sure RESOURCE_TYPE_MAIN_FRAME is declared as being fetched as part of | 60 // Make sure RESOURCE_TYPE_MAIN_FRAME is declared as being fetched as part of |
| 61 // the main frame. | 61 // the main frame. |
| 62 DCHECK(resource_type != RESOURCE_TYPE_MAIN_FRAME || is_main_frame); | 62 DCHECK(resource_type != RESOURCE_TYPE_MAIN_FRAME || is_main_frame); |
| 63 | 63 |
| 64 ResourceRequestInfoImpl* info = new ResourceRequestInfoImpl( | 64 ResourceRequestInfoImpl* info = new ResourceRequestInfoImpl( |
| 65 PROCESS_TYPE_RENDERER, // process_type | 65 ResourceRequesterInfo::CreateForRendererTesting( |
| 66 render_process_id, // child_id | 66 render_process_id), // resource_requester_info |
| 67 render_view_id, // route_id | 67 render_view_id, // route_id |
| 68 -1, // frame_tree_node_id | 68 -1, // frame_tree_node_id |
| 69 0, // origin_pid | 69 0, // origin_pid |
| 70 0, // request_id | 70 0, // request_id |
| 71 render_frame_id, // render_frame_id | 71 render_frame_id, // render_frame_id |
| 72 is_main_frame, // is_main_frame | 72 is_main_frame, // is_main_frame |
| 73 parent_is_main_frame, // parent_is_main_frame | 73 parent_is_main_frame, // parent_is_main_frame |
| 74 resource_type, // resource_type | 74 resource_type, // resource_type |
| 75 ui::PAGE_TRANSITION_LINK, // transition_type | 75 ui::PAGE_TRANSITION_LINK, // transition_type |
| 76 false, // should_replace_current_entry | 76 false, // should_replace_current_entry |
| 77 false, // is_download | 77 false, // is_download |
| 78 false, // is_stream | 78 false, // is_stream |
| 79 allow_download, // allow_download | 79 allow_download, // allow_download |
| 80 false, // has_user_gesture | 80 false, // has_user_gesture |
| 81 false, // enable load timing | 81 false, // enable load timing |
| 82 request->has_upload(), // enable upload progress | 82 request->has_upload(), // enable upload progress |
| 83 false, // do_not_prompt_for_login | 83 false, // do_not_prompt_for_login |
| 84 blink::WebReferrerPolicyDefault, // referrer_policy | 84 blink::WebReferrerPolicyDefault, // referrer_policy |
| 85 blink::WebPageVisibilityStateVisible, // visibility_state | 85 blink::WebPageVisibilityStateVisible, // visibility_state |
| 86 context, // context | 86 context, // context |
| 87 base::WeakPtr<ResourceMessageFilter>(), // filter | 87 false, // report_raw_headers |
| 88 false, // report_raw_headers | 88 is_async, // is_async |
| 89 is_async, // is_async | 89 is_using_lofi, // is_using_lofi |
| 90 is_using_lofi, // is_using_lofi | 90 std::string(), // original_headers |
| 91 std::string(), // original_headers | 91 nullptr, // body |
| 92 nullptr, // body | 92 false); // initiated_in_secure_context |
| 93 false); // initiated_in_secure_context | |
| 94 info->AssociateWithRequest(request); | 93 info->AssociateWithRequest(request); |
| 95 } | 94 } |
| 96 | 95 |
| 97 // static | 96 // static |
| 98 bool ResourceRequestInfo::GetRenderFrameForRequest( | 97 bool ResourceRequestInfo::GetRenderFrameForRequest( |
| 99 const net::URLRequest* request, | 98 const net::URLRequest* request, |
| 100 int* render_process_id, | 99 int* render_process_id, |
| 101 int* render_frame_id) { | 100 int* render_frame_id) { |
| 102 URLRequestUserData* user_data = static_cast<URLRequestUserData*>( | 101 URLRequestUserData* user_data = static_cast<URLRequestUserData*>( |
| 103 request->GetUserData(URLRequestUserData::kUserDataKey)); | 102 request->GetUserData(URLRequestUserData::kUserDataKey)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 124 return static_cast<ResourceRequestInfoImpl*>(request->GetUserData(NULL)); | 123 return static_cast<ResourceRequestInfoImpl*>(request->GetUserData(NULL)); |
| 125 } | 124 } |
| 126 | 125 |
| 127 // static | 126 // static |
| 128 const ResourceRequestInfoImpl* ResourceRequestInfoImpl::ForRequest( | 127 const ResourceRequestInfoImpl* ResourceRequestInfoImpl::ForRequest( |
| 129 const net::URLRequest* request) { | 128 const net::URLRequest* request) { |
| 130 return ForRequest(const_cast<net::URLRequest*>(request)); | 129 return ForRequest(const_cast<net::URLRequest*>(request)); |
| 131 } | 130 } |
| 132 | 131 |
| 133 ResourceRequestInfoImpl::ResourceRequestInfoImpl( | 132 ResourceRequestInfoImpl::ResourceRequestInfoImpl( |
| 134 int process_type, | 133 scoped_refptr<ResourceRequesterInfo> requester_info, |
| 135 int child_id, | |
| 136 int route_id, | 134 int route_id, |
| 137 int frame_tree_node_id, | 135 int frame_tree_node_id, |
| 138 int origin_pid, | 136 int origin_pid, |
| 139 int request_id, | 137 int request_id, |
| 140 int render_frame_id, | 138 int render_frame_id, |
| 141 bool is_main_frame, | 139 bool is_main_frame, |
| 142 bool parent_is_main_frame, | 140 bool parent_is_main_frame, |
| 143 ResourceType resource_type, | 141 ResourceType resource_type, |
| 144 ui::PageTransition transition_type, | 142 ui::PageTransition transition_type, |
| 145 bool should_replace_current_entry, | 143 bool should_replace_current_entry, |
| 146 bool is_download, | 144 bool is_download, |
| 147 bool is_stream, | 145 bool is_stream, |
| 148 bool allow_download, | 146 bool allow_download, |
| 149 bool has_user_gesture, | 147 bool has_user_gesture, |
| 150 bool enable_load_timing, | 148 bool enable_load_timing, |
| 151 bool enable_upload_progress, | 149 bool enable_upload_progress, |
| 152 bool do_not_prompt_for_login, | 150 bool do_not_prompt_for_login, |
| 153 blink::WebReferrerPolicy referrer_policy, | 151 blink::WebReferrerPolicy referrer_policy, |
| 154 blink::WebPageVisibilityState visibility_state, | 152 blink::WebPageVisibilityState visibility_state, |
| 155 ResourceContext* context, | 153 ResourceContext* context, |
| 156 base::WeakPtr<ResourceMessageFilter> filter, | |
| 157 bool report_raw_headers, | 154 bool report_raw_headers, |
| 158 bool is_async, | 155 bool is_async, |
| 159 bool is_using_lofi, | 156 bool is_using_lofi, |
| 160 const std::string& original_headers, | 157 const std::string& original_headers, |
| 161 const scoped_refptr<ResourceRequestBodyImpl> body, | 158 const scoped_refptr<ResourceRequestBodyImpl> body, |
| 162 bool initiated_in_secure_context) | 159 bool initiated_in_secure_context) |
| 163 : detachable_handler_(NULL), | 160 : detachable_handler_(NULL), |
| 164 process_type_(process_type), | 161 requester_info_(std::move(requester_info)), |
| 165 child_id_(child_id), | |
| 166 route_id_(route_id), | 162 route_id_(route_id), |
| 167 frame_tree_node_id_(frame_tree_node_id), | 163 frame_tree_node_id_(frame_tree_node_id), |
| 168 origin_pid_(origin_pid), | 164 origin_pid_(origin_pid), |
| 169 request_id_(request_id), | 165 request_id_(request_id), |
| 170 render_frame_id_(render_frame_id), | 166 render_frame_id_(render_frame_id), |
| 171 is_main_frame_(is_main_frame), | 167 is_main_frame_(is_main_frame), |
| 172 parent_is_main_frame_(parent_is_main_frame), | 168 parent_is_main_frame_(parent_is_main_frame), |
| 173 should_replace_current_entry_(should_replace_current_entry), | 169 should_replace_current_entry_(should_replace_current_entry), |
| 174 is_download_(is_download), | 170 is_download_(is_download), |
| 175 is_stream_(is_stream), | 171 is_stream_(is_stream), |
| 176 allow_download_(allow_download), | 172 allow_download_(allow_download), |
| 177 has_user_gesture_(has_user_gesture), | 173 has_user_gesture_(has_user_gesture), |
| 178 enable_load_timing_(enable_load_timing), | 174 enable_load_timing_(enable_load_timing), |
| 179 enable_upload_progress_(enable_upload_progress), | 175 enable_upload_progress_(enable_upload_progress), |
| 180 do_not_prompt_for_login_(do_not_prompt_for_login), | 176 do_not_prompt_for_login_(do_not_prompt_for_login), |
| 181 was_ignored_by_handler_(false), | 177 was_ignored_by_handler_(false), |
| 182 counted_as_in_flight_request_(false), | 178 counted_as_in_flight_request_(false), |
| 183 resource_type_(resource_type), | 179 resource_type_(resource_type), |
| 184 transition_type_(transition_type), | 180 transition_type_(transition_type), |
| 185 memory_cost_(0), | 181 memory_cost_(0), |
| 186 referrer_policy_(referrer_policy), | 182 referrer_policy_(referrer_policy), |
| 187 visibility_state_(visibility_state), | 183 visibility_state_(visibility_state), |
| 188 context_(context), | 184 context_(context), |
| 189 filter_(filter), | |
| 190 report_raw_headers_(report_raw_headers), | 185 report_raw_headers_(report_raw_headers), |
| 191 is_async_(is_async), | 186 is_async_(is_async), |
| 192 is_using_lofi_(is_using_lofi), | 187 is_using_lofi_(is_using_lofi), |
| 193 original_headers_(original_headers), | 188 original_headers_(original_headers), |
| 194 body_(body), | 189 body_(body), |
| 195 initiated_in_secure_context_(initiated_in_secure_context) {} | 190 initiated_in_secure_context_(initiated_in_secure_context) {} |
| 196 | 191 |
| 197 ResourceRequestInfoImpl::~ResourceRequestInfoImpl() { | 192 ResourceRequestInfoImpl::~ResourceRequestInfoImpl() { |
| 198 } | 193 } |
| 199 | 194 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 218 | 213 |
| 219 return base::Bind(&WebContentsImpl::FromRenderFrameHostID, | 214 return base::Bind(&WebContentsImpl::FromRenderFrameHostID, |
| 220 render_process_host_id, render_frame_host_id); | 215 render_process_host_id, render_frame_host_id); |
| 221 } | 216 } |
| 222 | 217 |
| 223 ResourceContext* ResourceRequestInfoImpl::GetContext() const { | 218 ResourceContext* ResourceRequestInfoImpl::GetContext() const { |
| 224 return context_; | 219 return context_; |
| 225 } | 220 } |
| 226 | 221 |
| 227 int ResourceRequestInfoImpl::GetChildID() const { | 222 int ResourceRequestInfoImpl::GetChildID() const { |
| 228 return child_id_; | 223 return requester_info_->child_id(); |
| 229 } | 224 } |
| 230 | 225 |
| 231 int ResourceRequestInfoImpl::GetRouteID() const { | 226 int ResourceRequestInfoImpl::GetRouteID() const { |
| 232 return route_id_; | 227 return route_id_; |
| 233 } | 228 } |
| 234 | 229 |
| 235 GlobalRequestID ResourceRequestInfoImpl::GetGlobalRequestID() const { | 230 GlobalRequestID ResourceRequestInfoImpl::GetGlobalRequestID() const { |
| 236 return GlobalRequestID(child_id_, request_id_); | 231 return GlobalRequestID(GetChildID(), request_id_); |
| 237 } | 232 } |
| 238 | 233 |
| 239 int ResourceRequestInfoImpl::GetOriginPID() const { | 234 int ResourceRequestInfoImpl::GetOriginPID() const { |
| 240 return origin_pid_; | 235 return origin_pid_; |
| 241 } | 236 } |
| 242 | 237 |
| 243 int ResourceRequestInfoImpl::GetRenderFrameID() const { | 238 int ResourceRequestInfoImpl::GetRenderFrameID() const { |
| 244 return render_frame_id_; | 239 return render_frame_id_; |
| 245 } | 240 } |
| 246 | 241 |
| 247 int ResourceRequestInfoImpl::GetFrameTreeNodeId() const { | 242 int ResourceRequestInfoImpl::GetFrameTreeNodeId() const { |
| 248 return frame_tree_node_id_; | 243 return frame_tree_node_id_; |
| 249 } | 244 } |
| 250 | 245 |
| 251 bool ResourceRequestInfoImpl::IsMainFrame() const { | 246 bool ResourceRequestInfoImpl::IsMainFrame() const { |
| 252 return is_main_frame_; | 247 return is_main_frame_; |
| 253 } | 248 } |
| 254 | 249 |
| 255 bool ResourceRequestInfoImpl::ParentIsMainFrame() const { | 250 bool ResourceRequestInfoImpl::ParentIsMainFrame() const { |
| 256 return parent_is_main_frame_; | 251 return parent_is_main_frame_; |
| 257 } | 252 } |
| 258 | 253 |
| 259 ResourceType ResourceRequestInfoImpl::GetResourceType() const { | 254 ResourceType ResourceRequestInfoImpl::GetResourceType() const { |
| 260 return resource_type_; | 255 return resource_type_; |
| 261 } | 256 } |
| 262 | 257 |
| 263 int ResourceRequestInfoImpl::GetProcessType() const { | 258 int ResourceRequestInfoImpl::GetProcessType() const { |
| 264 return process_type_; | 259 return requester_info_->IsBrowserSideNavigation() ? PROCESS_TYPE_BROWSER |
| 260 : PROCESS_TYPE_RENDERER; |
| 265 } | 261 } |
| 266 | 262 |
| 267 blink::WebReferrerPolicy ResourceRequestInfoImpl::GetReferrerPolicy() const { | 263 blink::WebReferrerPolicy ResourceRequestInfoImpl::GetReferrerPolicy() const { |
| 268 return referrer_policy_; | 264 return referrer_policy_; |
| 269 } | 265 } |
| 270 | 266 |
| 271 blink::WebPageVisibilityState | 267 blink::WebPageVisibilityState |
| 272 ResourceRequestInfoImpl::GetVisibilityState() const { | 268 ResourceRequestInfoImpl::GetVisibilityState() const { |
| 273 return visibility_state_; | 269 return visibility_state_; |
| 274 } | 270 } |
| 275 | 271 |
| 276 ui::PageTransition ResourceRequestInfoImpl::GetPageTransition() const { | 272 ui::PageTransition ResourceRequestInfoImpl::GetPageTransition() const { |
| 277 return transition_type_; | 273 return transition_type_; |
| 278 } | 274 } |
| 279 | 275 |
| 280 bool ResourceRequestInfoImpl::HasUserGesture() const { | 276 bool ResourceRequestInfoImpl::HasUserGesture() const { |
| 281 return has_user_gesture_; | 277 return has_user_gesture_; |
| 282 } | 278 } |
| 283 | 279 |
| 284 bool ResourceRequestInfoImpl::WasIgnoredByHandler() const { | 280 bool ResourceRequestInfoImpl::WasIgnoredByHandler() const { |
| 285 return was_ignored_by_handler_; | 281 return was_ignored_by_handler_; |
| 286 } | 282 } |
| 287 | 283 |
| 288 bool ResourceRequestInfoImpl::GetAssociatedRenderFrame( | 284 bool ResourceRequestInfoImpl::GetAssociatedRenderFrame( |
| 289 int* render_process_id, | 285 int* render_process_id, |
| 290 int* render_frame_id) const { | 286 int* render_frame_id) const { |
| 291 *render_process_id = child_id_; | 287 *render_process_id = GetChildID(); |
| 292 *render_frame_id = render_frame_id_; | 288 *render_frame_id = render_frame_id_; |
| 293 return true; | 289 return true; |
| 294 } | 290 } |
| 295 | 291 |
| 296 bool ResourceRequestInfoImpl::IsAsync() const { | 292 bool ResourceRequestInfoImpl::IsAsync() const { |
| 297 return is_async_; | 293 return is_async_; |
| 298 } | 294 } |
| 299 | 295 |
| 300 bool ResourceRequestInfoImpl::IsDownload() const { | 296 bool ResourceRequestInfoImpl::IsDownload() const { |
| 301 return is_download_; | 297 return is_download_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 322 URLRequestUserData::kUserDataKey, | 318 URLRequestUserData::kUserDataKey, |
| 323 new URLRequestUserData(render_process_id, render_frame_id)); | 319 new URLRequestUserData(render_process_id, render_frame_id)); |
| 324 } | 320 } |
| 325 } | 321 } |
| 326 | 322 |
| 327 int ResourceRequestInfoImpl::GetRequestID() const { | 323 int ResourceRequestInfoImpl::GetRequestID() const { |
| 328 return request_id_; | 324 return request_id_; |
| 329 } | 325 } |
| 330 | 326 |
| 331 GlobalRoutingID ResourceRequestInfoImpl::GetGlobalRoutingID() const { | 327 GlobalRoutingID ResourceRequestInfoImpl::GetGlobalRoutingID() const { |
| 332 return GlobalRoutingID(child_id_, route_id_); | 328 return GlobalRoutingID(GetChildID(), route_id_); |
| 333 } | 329 } |
| 334 | 330 |
| 335 void ResourceRequestInfoImpl::UpdateForTransfer( | 331 void ResourceRequestInfoImpl::UpdateForTransfer( |
| 336 int child_id, | |
| 337 int route_id, | 332 int route_id, |
| 338 int render_frame_id, | 333 int render_frame_id, |
| 339 int origin_pid, | 334 int origin_pid, |
| 340 int request_id, | 335 int request_id, |
| 341 base::WeakPtr<ResourceMessageFilter> filter, | 336 ResourceRequesterInfo* requester_info, |
| 342 mojom::URLLoaderAssociatedRequest url_loader_request, | 337 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 343 mojom::URLLoaderClientAssociatedPtr url_loader_client) { | 338 mojom::URLLoaderClientAssociatedPtr url_loader_client) { |
| 344 child_id_ = child_id; | |
| 345 route_id_ = route_id; | 339 route_id_ = route_id; |
| 346 render_frame_id_ = render_frame_id; | 340 render_frame_id_ = render_frame_id; |
| 347 origin_pid_ = origin_pid; | 341 origin_pid_ = origin_pid; |
| 348 request_id_ = request_id; | 342 request_id_ = request_id; |
| 349 filter_ = filter; | 343 requester_info_ = requester_info; |
| 350 | 344 |
| 351 // on_transfer_ is non-null only when MojoAsyncResourceHandler is used. | 345 // on_transfer_ is non-null only when MojoAsyncResourceHandler is used. |
| 352 if (on_transfer_) { | 346 if (on_transfer_) { |
| 353 on_transfer_.Run(std::move(url_loader_request), | 347 on_transfer_.Run(std::move(url_loader_request), |
| 354 std::move(url_loader_client)); | 348 std::move(url_loader_client)); |
| 355 } | 349 } |
| 356 } | 350 } |
| 357 | 351 |
| 358 void ResourceRequestInfoImpl::ResetBody() { | 352 void ResourceRequestInfoImpl::ResetBody() { |
| 359 body_ = nullptr; | 353 body_ = nullptr; |
| 360 } | 354 } |
| 361 | 355 |
| 362 } // namespace content | 356 } // namespace content |
| OLD | NEW |