perf: prefer GURL string_view getters (#43443)

* chore: avoid double-call to url.scheme() in WebContentsZoomController::SetZoomMode()

* perf: use gurl.scheme_piece() in GetAppInfoHelperForProtocol()

* perf: use gurl.scheme_piece() in Browser::GetApplicationNameForProtocol()

* refactor: add std::less<> to HandlersMap

This lets us search it using string_view keys

* refactor: ProtocolRegistry::FindRegistered() now takes a std::string_view

* perf: use gurl.scheme_piece() in InspectableWebContents::LoadNetworkResource()

* refactor: ProtocolRegistry::FindIntercepted() now takes a std::string_view

* perf: use gurl.scheme_piece() in SimpleURLLoaderWrapper::GetURLLoaderFactoryForURL()

* perf: use gurl.scheme_piece() in ProxyingURLLoaderFactory::CreateLoaderAndStart()

* perf: use gurl.host_piece() in ElectronWebUIControllerFactory::GetWebUIType()

* perf: use gurl.host_piece() in ElectronWebUIControllerFactory::CreateWebUIControllerForURL()
This commit is contained in:
Charles Kerr 2024-08-23 17:15:45 -05:00 committed by GitHub
parent 7f34b0e6f5
commit 5a1eeea102
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 26 additions and 19 deletions

View file

@ -25,8 +25,9 @@ ElectronWebUIControllerFactory::~ElectronWebUIControllerFactory() = default;
content::WebUI::TypeID ElectronWebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context,
const GURL& url) {
if (url.host() == chrome::kChromeUIDevToolsHost ||
url.host() == chrome::kChromeUIAccessibilityHost) {
if (const std::string_view host = url.host_piece();
host == chrome::kChromeUIDevToolsHost ||
host == chrome::kChromeUIAccessibilityHost) {
return const_cast<ElectronWebUIControllerFactory*>(this);
}
@ -43,13 +44,16 @@ std::unique_ptr<content::WebUIController>
ElectronWebUIControllerFactory::CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) {
if (url.host() == chrome::kChromeUIDevToolsHost) {
const std::string_view host = url.host_piece();
if (host == chrome::kChromeUIDevToolsHost) {
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
return std::make_unique<DevToolsUI>(browser_context, web_ui);
} else if (url.host() == chrome::kChromeUIAccessibilityHost) {
return std::make_unique<ElectronAccessibilityUI>(web_ui);
}
if (host == chrome::kChromeUIAccessibilityHost)
return std::make_unique<ElectronAccessibilityUI>(web_ui);
return std::unique_ptr<content::WebUIController>();
}