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

Unified Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 2459143002: Avoid GURL allocations/copies/frees in RenderFrameImpl::willSendRequest (Closed)
Patch Set: compile fix Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/chrome_content_renderer_client.cc
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index f18ed51967a4c02316a3e3e0a8f52c36c4d2912b..0e1817ca5b611858554bc0c28fc2461e35b121ca 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1122,11 +1122,10 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
bool ChromeContentRendererClient::WillSendRequest(
WebFrame* frame,
ui::PageTransition transition_type,
- const GURL& url,
- const GURL& first_party_for_cookies,
+ const blink::WebURL& url,
GURL* new_url) {
- // Check whether the request should be allowed. If not allowed, we reset the
- // URL to something invalid to prevent the request and cause an error.
+// Check whether the request should be allowed. If not allowed, we reset the
+// URL to something invalid to prevent the request and cause an error.
#if defined(ENABLE_EXTENSIONS)
if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest(
frame, transition_type, url, new_url)) {
@@ -1134,18 +1133,24 @@ bool ChromeContentRendererClient::WillSendRequest(
}
#endif
+ // Early exit before fetching the RenderView or SearchBox.
Devlin 2016/10/31 15:17:39 optional nit: This comment doesn't seem to add muc
Charlie Harrison 2016/10/31 15:46:13 Done.
+ if (!url.protocolIs(chrome::kChromeSearchScheme))
+ return false;
+
const content::RenderView* render_view =
content::RenderView::FromWebView(frame->view());
SearchBox* search_box = SearchBox::Get(render_view);
- if (search_box && url.SchemeIs(chrome::kChromeSearchScheme)) {
+ if (search_box) {
+ // Note: this GURL copy could be avoided if host() were added to WebURL.
+ GURL gurl(url);
SearchBox::ImageSourceType type = SearchBox::NONE;
- if (url.host() == chrome::kChromeUIFaviconHost)
+ if (gurl.host() == chrome::kChromeUIFaviconHost)
type = SearchBox::FAVICON;
- else if (url.host() == chrome::kChromeUILargeIconHost)
+ else if (gurl.host() == chrome::kChromeUILargeIconHost)
type = SearchBox::LARGE_ICON;
- else if (url.host() == chrome::kChromeUIFallbackIconHost)
+ else if (gurl.host() == chrome::kChromeUIFallbackIconHost)
type = SearchBox::FALLBACK_ICON;
- else if (url.host() == chrome::kChromeUIThumbnailHost)
+ else if (gurl.host() == chrome::kChromeUIThumbnailHost)
type = SearchBox::THUMB;
if (type != SearchBox::NONE)

Powered by Google App Engine
This is Rietveld 408576698