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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698