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

Unified Diff: content/browser/loader/resource_hints_handler_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_handler_impl.cc
diff --git a/content/browser/loader/resource_hints_handler_impl.cc b/content/browser/loader/resource_hints_handler_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ee8f1153cb16a39dc3184d682a21e119917f898
--- /dev/null
+++ b/content/browser/loader/resource_hints_handler_impl.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/loader/resource_hints_handler_impl.h"
+
+#include "base/memory/ptr_util.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/resource_context.h"
+#include "content/public/browser/resource_hints.h"
+
+namespace content {
+
+// static
+void ResourceHintsHandlerImpl::RegisterConnection(
+ RenderProcessHost* render_process_host,
+ blink::mojom::ResourceHintsHandlerRequest request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ResourceHintsHandlerImpl::RegisterConnectionOnIOThread,
+ render_process_host->GetBrowserContext()->GetResourceContext(),
+ base::Passed(&request)));
+}
+
+// static
+void ResourceHintsHandlerImpl::RegisterConnectionOnIOThread(
+ ResourceContext* resource_context,
+ blink::mojom::ResourceHintsHandlerRequest request) {
+ // Will be deleted when the connection goes away.
+ new ResourceHintsHandlerImpl(std::move(request), resource_context);
+}
+
+ResourceHintsHandlerImpl::ResourceHintsHandlerImpl(
+ blink::mojom::ResourceHintsHandlerRequest request,
+ ResourceContext* resource_context)
+ : resource_context_(resource_context), binding_(this, std::move(request)) {}
+
+ResourceHintsHandlerImpl::~ResourceHintsHandlerImpl() {}
+
+void ResourceHintsHandlerImpl::Preresolve(const GURL& url) {
+ PreresolveUrl(resource_context_, url, net::CompletionCallback());
+}
+
+void ResourceHintsHandlerImpl::Preconnect(const GURL& url,
+ bool credentials_flag,
+ uint8_t num_connections) {
+ // TODO(csharrison): Remove HttpRequestInfo::RequestMotivation and add a
+ // better enum at the //content layer.
+ PreconnectUrl(resource_context_, url, GURL(), num_connections,
+ credentials_flag, net::HttpRequestInfo::EARLY_LOAD_MOTIVATED);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698