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 12 matching lines...) Expand all Loading... |
23 WebContents* GetWebContentsFromFTNID(int frame_tree_node_id) { | 23 WebContents* GetWebContentsFromFTNID(int frame_tree_node_id) { |
24 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 24 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
25 FrameTreeNode* frame_tree_node = | 25 FrameTreeNode* frame_tree_node = |
26 FrameTreeNode::GloballyFindByID(frame_tree_node_id); | 26 FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
27 if (!frame_tree_node) | 27 if (!frame_tree_node) |
28 return nullptr; | 28 return nullptr; |
29 | 29 |
30 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); | 30 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
31 } | 31 } |
32 | 32 |
33 int FrameTreeNodeIdFromHostIds(int render_process_host_id, | |
34 int render_frame_host_id) { | |
35 RenderFrameHost* render_frame_host = | |
36 RenderFrameHost::FromID(render_process_host_id, render_frame_host_id); | |
37 return render_frame_host ? render_frame_host->GetFrameTreeNodeId() : -1; | |
38 } | |
39 | |
40 } // namespace | 33 } // namespace |
41 | 34 |
42 // ---------------------------------------------------------------------------- | 35 // ---------------------------------------------------------------------------- |
43 // ResourceRequestInfo | 36 // ResourceRequestInfo |
44 | 37 |
45 // static | 38 // static |
46 const ResourceRequestInfo* ResourceRequestInfo::ForRequest( | 39 const ResourceRequestInfo* ResourceRequestInfo::ForRequest( |
47 const net::URLRequest* request) { | 40 const net::URLRequest* request) { |
48 return ResourceRequestInfoImpl::ForRequest(request); | 41 return ResourceRequestInfoImpl::ForRequest(request); |
49 } | 42 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 int render_frame_host_id = -1; | 205 int render_frame_host_id = -1; |
213 if (!GetAssociatedRenderFrame(&render_process_host_id, | 206 if (!GetAssociatedRenderFrame(&render_process_host_id, |
214 &render_frame_host_id)) { | 207 &render_frame_host_id)) { |
215 NOTREACHED(); | 208 NOTREACHED(); |
216 } | 209 } |
217 | 210 |
218 return base::Bind(&WebContentsImpl::FromRenderFrameHostID, | 211 return base::Bind(&WebContentsImpl::FromRenderFrameHostID, |
219 render_process_host_id, render_frame_host_id); | 212 render_process_host_id, render_frame_host_id); |
220 } | 213 } |
221 | 214 |
222 ResourceRequestInfo::FrameTreeNodeIdGetter | |
223 ResourceRequestInfoImpl::GetFrameTreeNodeIdGetterForRequest() const { | |
224 if (frame_tree_node_id_ != -1) { | |
225 DCHECK(IsBrowserSideNavigationEnabled()); | |
226 return base::Bind([](int id) { return id; }, frame_tree_node_id_); | |
227 } | |
228 | |
229 int render_process_host_id = -1; | |
230 int render_frame_host_id = -1; | |
231 if (!GetAssociatedRenderFrame(&render_process_host_id, | |
232 &render_frame_host_id)) { | |
233 NOTREACHED(); | |
234 } | |
235 | |
236 return base::Bind(&FrameTreeNodeIdFromHostIds, render_process_host_id, | |
237 render_frame_host_id); | |
238 } | |
239 | |
240 ResourceContext* ResourceRequestInfoImpl::GetContext() const { | 215 ResourceContext* ResourceRequestInfoImpl::GetContext() const { |
241 return context_; | 216 return context_; |
242 } | 217 } |
243 | 218 |
244 int ResourceRequestInfoImpl::GetChildID() const { | 219 int ResourceRequestInfoImpl::GetChildID() const { |
245 return requester_info_->child_id(); | 220 return requester_info_->child_id(); |
246 } | 221 } |
247 | 222 |
248 int ResourceRequestInfoImpl::GetRouteID() const { | 223 int ResourceRequestInfoImpl::GetRouteID() const { |
249 return route_id_; | 224 return route_id_; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 on_transfer_.Run(std::move(url_loader_request), | 344 on_transfer_.Run(std::move(url_loader_request), |
370 std::move(url_loader_client)); | 345 std::move(url_loader_client)); |
371 } | 346 } |
372 } | 347 } |
373 | 348 |
374 void ResourceRequestInfoImpl::ResetBody() { | 349 void ResourceRequestInfoImpl::ResetBody() { |
375 body_ = nullptr; | 350 body_ = nullptr; |
376 } | 351 } |
377 | 352 |
378 } // namespace content | 353 } // namespace content |
OLD | NEW |