From f2f852a3107df270fba6a37b1577ffb58df50c1c Mon Sep 17 00:00:00 2001 From: davidben Date: Thu, 3 Sep 2015 20:06:35 -0700 Subject: [PATCH] Don't assume ResourceRequestInfo is at UserData key NULL. This is faster anyway since it avoids querying UserData twice. BUG=none Review URL: https://codereview.chromium.org/1314643005 Cr-Commit-Position: refs/heads/master@{#347327} --- .../chrome_extension_web_request_event_router_delegate.cc | 8 +++++--- extensions/browser/api/web_request/web_request_api.cc | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.cc b/chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.cc index 41e9b02d61b9..40ab80151cfc 100644 --- a/chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.cc +++ b/chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.cc @@ -23,11 +23,13 @@ namespace { void ExtractExtraRequestDetailsInternal(const net::URLRequest* request, int* tab_id, int* window_id) { - if (!request->GetUserData(NULL)) + const content::ResourceRequestInfo* info = + content::ResourceRequestInfo::ForRequest(request); + if (!info) return; - ExtensionRendererState::GetInstance()->GetTabAndWindowId( - content::ResourceRequestInfo::ForRequest(request), tab_id, window_id); + ExtensionRendererState::GetInstance()->GetTabAndWindowId(info, tab_id, + window_id); } } // namespace diff --git a/extensions/browser/api/web_request/web_request_api.cc b/extensions/browser/api/web_request/web_request_api.cc index 0aaa4fad49fd..798e646d55c0 100644 --- a/extensions/browser/api/web_request/web_request_api.cc +++ b/extensions/browser/api/web_request/web_request_api.cc @@ -165,9 +165,9 @@ bool IsRequestFromExtension(const net::URLRequest* request, void ExtractRequestRoutingInfo(const net::URLRequest* request, int* render_process_host_id, int* routing_id) { - if (!request->GetUserData(NULL)) - return; const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); + if (!info) + return; *render_process_host_id = info->GetChildID(); *routing_id = info->GetRouteID(); } @@ -193,10 +193,10 @@ void ExtractRequestInfoDetails(const net::URLRequest* request, int* render_process_host_id, int* routing_id, ResourceType* resource_type) { - if (!request->GetUserData(NULL)) + const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); + if (!info) return; - const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); *frame_id = info->GetRenderFrameID(); *is_main_frame = info->IsMainFrame(); *parent_frame_id = info->GetParentRenderFrameID(); -- 2.11.4.GIT