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

Side by Side Diff: components/network_hints/browser/network_hints_impl.cc

Issue 2144533002: Convert network hints to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add untracked dependency on mojom Created 4 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/network_hints/browser/network_hints_message_filter.h" 5 #include "components/network_hints/browser/network_hints_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "components/network_hints/common/network_hints_common.h" 9 #include "components/network_hints/common/network_hints_common.h"
10 #include "components/network_hints/common/network_hints_messages.h"
11 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
12 #include "net/base/address_list.h" 11 #include "net/base/address_list.h"
13 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
14 #include "net/dns/host_resolver.h" 13 #include "net/dns/host_resolver.h"
15 #include "net/dns/single_request_host_resolver.h" 14 #include "net/dns/single_request_host_resolver.h"
16 #include "url/gurl.h" 15 #include "url/gurl.h"
17 16
18 namespace network_hints { 17 namespace network_hints {
19 18
20 namespace { 19 namespace {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 55
57 const std::string hostname_; 56 const std::string hostname_;
58 net::SingleRequestHostResolver resolver_; 57 net::SingleRequestHostResolver resolver_;
59 net::AddressList addresses_; 58 net::AddressList addresses_;
60 59
61 DISALLOW_COPY_AND_ASSIGN(DnsLookupRequest); 60 DISALLOW_COPY_AND_ASSIGN(DnsLookupRequest);
62 }; 61 };
63 62
64 } // namespace 63 } // namespace
65 64
66 NetworkHintsMessageFilter::NetworkHintsMessageFilter( 65 void NetworkHintsImpl::Bind(mojom::NetworkHintsRequest request) {
67 net::HostResolver* host_resolver) 66 bindings_.AddBinding(this, std::move(request));
68 : content::BrowserMessageFilter(NetworkHintsMsgStart), 67 }
69 host_resolver_(host_resolver) { 68
69 NetworkHintsImpl::NetworkHintsImpl(net::HostResolver* host_resolver)
70 : host_resolver_(host_resolver) {
70 DCHECK(host_resolver_); 71 DCHECK(host_resolver_);
71 } 72 }
72 73
73 NetworkHintsMessageFilter::~NetworkHintsMessageFilter() { 74 NetworkHintsImpl::~NetworkHintsImpl() {}
74 }
75 75
76 bool NetworkHintsMessageFilter::OnMessageReceived(const IPC::Message& message) { 76 void NetworkHintsImpl::DNSPrefetch(const LookupRequest& lookup_request) {
77 bool handled = true;
78 IPC_BEGIN_MESSAGE_MAP(NetworkHintsMessageFilter, message)
79 IPC_MESSAGE_HANDLER(NetworkHintsMsg_DNSPrefetch, OnDnsPrefetch)
80 IPC_MESSAGE_UNHANDLED(handled = false)
81 IPC_END_MESSAGE_MAP()
82 return handled;
83 }
84
85 void NetworkHintsMessageFilter::OnDnsPrefetch(
86 const LookupRequest& lookup_request) {
87 DCHECK(host_resolver_); 77 DCHECK(host_resolver_);
88 for (const std::string& hostname : lookup_request.hostname_list) { 78 for (const std::string& hostname : lookup_request.hostname_list) {
89 DnsLookupRequest* request = new DnsLookupRequest(host_resolver_, hostname); 79 DnsLookupRequest* request = new DnsLookupRequest(host_resolver_, hostname);
90 // Note: DnsLookupRequest will be freed by the base::Owned call when 80 // Note: DnsLookupRequest will be freed by the base::Owned call when
91 // resolving has completed. 81 // resolving has completed.
92 request->Start(); 82 request->Start();
93 } 83 }
94 } 84 }
95 85
96 } // namespace network_hints 86 } // namespace network_hints
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698