OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/loader/resource_hints_handler_impl.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_process_host.h" |
| 11 #include "content/public/browser/resource_context.h" |
| 12 #include "content/public/browser/resource_hints.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // static |
| 17 void ResourceHintsHandlerImpl::RegisterConnection( |
| 18 RenderProcessHost* render_process_host, |
| 19 blink::mojom::ResourceHintsHandlerRequest request) { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 BrowserThread::PostTask( |
| 22 BrowserThread::IO, FROM_HERE, |
| 23 base::Bind(&ResourceHintsHandlerImpl::RegisterConnectionOnIOThread, |
| 24 render_process_host->GetBrowserContext()->GetResourceContext(), |
| 25 base::Passed(&request))); |
| 26 } |
| 27 |
| 28 // static |
| 29 void ResourceHintsHandlerImpl::RegisterConnectionOnIOThread( |
| 30 ResourceContext* resource_context, |
| 31 blink::mojom::ResourceHintsHandlerRequest request) { |
| 32 // Will be deleted when the connection goes away. |
| 33 new ResourceHintsHandlerImpl(std::move(request), resource_context); |
| 34 } |
| 35 |
| 36 ResourceHintsHandlerImpl::ResourceHintsHandlerImpl( |
| 37 blink::mojom::ResourceHintsHandlerRequest request, |
| 38 ResourceContext* resource_context) |
| 39 : resource_context_(resource_context), binding_(this, std::move(request)) {} |
| 40 |
| 41 ResourceHintsHandlerImpl::~ResourceHintsHandlerImpl() {} |
| 42 |
| 43 void ResourceHintsHandlerImpl::Preresolve(const GURL& url) { |
| 44 PreresolveUrl(resource_context_, url, net::CompletionCallback()); |
| 45 } |
| 46 |
| 47 void ResourceHintsHandlerImpl::Preconnect(const GURL& url, |
| 48 bool credentials_flag, |
| 49 uint8_t num_connections) { |
| 50 // TODO(csharrison): Remove HttpRequestInfo::RequestMotivation and add a |
| 51 // better enum at the //content layer. |
| 52 PreconnectUrl(resource_context_, url, GURL(), num_connections, |
| 53 credentials_flag, net::HttpRequestInfo::EARLY_LOAD_MOTIVATED); |
| 54 } |
| 55 |
| 56 } // namespace content |
OLD | NEW |