Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: content/browser/loader/resource_request_info_impl.cc

Issue 2798953002: [PageLoadMetrics] Keep track of Ad Sizes on Pages (Closed)
Patch Set: Remove dcheck Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 RenderFrameHost* GetRenderFrameHostFromFTNID(int frame_tree_node_id) {
34 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 FrameTreeNode* frame_tree_node =
36 FrameTreeNode::GloballyFindByID(frame_tree_node_id);
37 if (!frame_tree_node)
38 return nullptr;
39 return frame_tree_node->current_frame_host();
40 }
41
33 } // namespace 42 } // namespace
34 43
35 // ---------------------------------------------------------------------------- 44 // ----------------------------------------------------------------------------
36 // ResourceRequestInfo 45 // ResourceRequestInfo
37 46
38 // static 47 // static
39 const ResourceRequestInfo* ResourceRequestInfo::ForRequest( 48 const ResourceRequestInfo* ResourceRequestInfo::ForRequest(
40 const net::URLRequest* request) { 49 const net::URLRequest* request) {
41 return ResourceRequestInfoImpl::ForRequest(request); 50 return ResourceRequestInfoImpl::ForRequest(request);
42 } 51 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 int render_frame_host_id = -1; 214 int render_frame_host_id = -1;
206 if (!GetAssociatedRenderFrame(&render_process_host_id, 215 if (!GetAssociatedRenderFrame(&render_process_host_id,
207 &render_frame_host_id)) { 216 &render_frame_host_id)) {
208 NOTREACHED(); 217 NOTREACHED();
209 } 218 }
210 219
211 return base::Bind(&WebContentsImpl::FromRenderFrameHostID, 220 return base::Bind(&WebContentsImpl::FromRenderFrameHostID,
212 render_process_host_id, render_frame_host_id); 221 render_process_host_id, render_frame_host_id);
213 } 222 }
214 223
224 ResourceRequestInfo::RenderFrameHostGetter
225 ResourceRequestInfoImpl::GetRenderFrameHostGetterForRequest() const {
226 // PlzNavigate: navigation requests are created with a valid FrameTreeNode
227 // ID and invalid RenderProcessHost and RenderFrameHost IDs. The
228 // FrameTreeNode ID should be used to access the RenderFrameHost.
229 if (frame_tree_node_id_ != -1) {
230 DCHECK(IsBrowserSideNavigationEnabled());
231 return base::Bind(&GetRenderFrameHostFromFTNID, frame_tree_node_id_);
232 }
233
234 // In other cases, use the RenderProcessHost ID + RenderFrameHost ID to get
235 // the WebContents.
236 int render_process_host_id = -1;
237 int render_frame_host_id = -1;
238 if (!GetAssociatedRenderFrame(&render_process_host_id,
239 &render_frame_host_id)) {
240 NOTREACHED();
241 }
242
243 return base::Bind(&RenderFrameHost::FromID, render_process_host_id,
244 render_frame_host_id);
245 }
246
215 ResourceContext* ResourceRequestInfoImpl::GetContext() const { 247 ResourceContext* ResourceRequestInfoImpl::GetContext() const {
216 return context_; 248 return context_;
217 } 249 }
218 250
219 int ResourceRequestInfoImpl::GetChildID() const { 251 int ResourceRequestInfoImpl::GetChildID() const {
220 return requester_info_->child_id(); 252 return requester_info_->child_id();
221 } 253 }
222 254
223 int ResourceRequestInfoImpl::GetRouteID() const { 255 int ResourceRequestInfoImpl::GetRouteID() const {
224 return route_id_; 256 return route_id_;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 on_transfer_.Run(std::move(url_loader_request), 376 on_transfer_.Run(std::move(url_loader_request),
345 std::move(url_loader_client)); 377 std::move(url_loader_client));
346 } 378 }
347 } 379 }
348 380
349 void ResourceRequestInfoImpl::ResetBody() { 381 void ResourceRequestInfoImpl::ResetBody() {
350 body_ = nullptr; 382 body_ = nullptr;
351 } 383 }
352 384
353 } // namespace content 385 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698