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

Unified Diff: content/browser/loader/resource_hints_impl.cc

Issue 2043753002: Declarative resource hints go through mojo IPC to //content Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove gmocking + add another browser test Created 4 years, 6 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: content/browser/loader/resource_hints_impl.cc
diff --git a/content/browser/loader/resource_hints_impl.cc b/content/browser/loader/resource_hints_impl.cc
index e6f18c00346c3c0139c406a7862fe7b0ea14131c..a8b9558698ee0fb8aa70e43084d99b1865c44e5b 100644
--- a/content/browser/loader/resource_hints_impl.cc
+++ b/content/browser/loader/resource_hints_impl.cc
@@ -29,7 +29,13 @@ void OnResolveComplete(net::SingleRequestHostResolver* request,
int result) {
// Plumb the resolution result into the callback if future consumers want
// that information.
- callback.Run(result);
+ if (!callback.is_null())
+ callback.Run(result);
+}
+
+bool ValidUrl(const GURL& url) {
+ return url.is_valid() && url.has_host() && url.has_scheme() &&
+ url.SchemeIsHTTPOrHTTPS();
}
} // namespace
@@ -43,6 +49,9 @@ void PreconnectUrl(content::ResourceContext* resource_context,
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(resource_context);
+ if (!ValidUrl(url))
+ return;
+
net::URLRequestContext* context = resource_context->GetRequestContext();
net::HttpTransactionFactory* factory = context->http_transaction_factory();
net::HttpNetworkSession* session = factory->GetSession();
@@ -81,6 +90,9 @@ int PreresolveUrl(content::ResourceContext* resource_context,
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(resource_context);
+ if (!ValidUrl(url))
+ return net::ERR_INVALID_URL;
+
net::AddressList* addresses = new net::AddressList;
net::SingleRequestHostResolver* resolver =
new net::SingleRequestHostResolver(resource_context->GetHostResolver());

Powered by Google App Engine
This is Rietveld 408576698