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

Unified Diff: chrome/browser/renderer_host/chrome_render_message_filter.cc

Issue 899883004: Added chrome-side support for link rel=preconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed formatting nit Created 5 years, 10 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
« no previous file with comments | « chrome/browser/renderer_host/chrome_render_message_filter.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/chrome_render_message_filter.cc
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 18d11c8c0a2fc0b5759f3e6491dbd170bd1aa4c5..f38bd409684c197b2b0b3f3c73da05a855d8a987 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -45,7 +46,7 @@ namespace {
const uint32 kFilteredMessageClasses[] = {
ChromeMsgStart,
- DnsPrefetchMsgStart,
+ NetworkHintsMsgStart,
};
} // namespace
@@ -67,8 +68,8 @@ ChromeRenderMessageFilter::~ChromeRenderMessageFilter() {
bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ChromeRenderMessageFilter, message)
- IPC_MESSAGE_HANDLER(DnsPrefetchMsg_RequestPrefetch, OnDnsPrefetch)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Preconnect, OnPreconnect)
+ IPC_MESSAGE_HANDLER(NetworkHintsMsg_DNSPrefetch, OnDnsPrefetch)
+ IPC_MESSAGE_HANDLER(NetworkHintsMsg_Preconnect, OnPreconnect)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ResourceTypeStats,
OnResourceTypeStats)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats,
@@ -112,10 +113,17 @@ void ChromeRenderMessageFilter::OnDnsPrefetch(
predictor_->DnsPrefetchList(request.hostname_list);
}
-void ChromeRenderMessageFilter::OnPreconnect(const GURL& url) {
- if (predictor_)
+void ChromeRenderMessageFilter::OnPreconnect(const GURL& url, int count) {
+ if (count < 1) {
+ LOG(WARNING) << "NetworkHintsMsg_Preconnect IPC with invalid count: "
+ << count;
+ return;
+ }
+ if (predictor_ && url.is_valid() && url.has_host() && url.has_scheme() &&
+ url.SchemeIsHTTPOrHTTPS()) {
predictor_->PreconnectUrl(
- url, GURL(), chrome_browser_net::UrlInfo::MOUSE_OVER_MOTIVATED, 1);
+ url, GURL(), chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, count);
+ }
}
void ChromeRenderMessageFilter::OnResourceTypeStats(
« no previous file with comments | « chrome/browser/renderer_host/chrome_render_message_filter.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698