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 |