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

Unified Diff: components/network_hints/browser/network_hints_impl.cc

Issue 2179693002: Revert of Convert network hints to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/network_hints/browser/network_hints_impl.cc
diff --git a/components/network_hints/browser/network_hints_impl.cc b/components/network_hints/browser/network_hints_impl.cc
deleted file mode 100644
index 1462d58d5be82de249289fe36ded0e87248df4e8..0000000000000000000000000000000000000000
--- a/components/network_hints/browser/network_hints_impl.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2014 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 "components/network_hints/browser/network_hints_impl.h"
-
-#include "base/logging.h"
-#include "base/macros.h"
-#include "components/network_hints/common/network_hints_common.h"
-#include "ipc/ipc_message_macros.h"
-#include "net/base/address_list.h"
-#include "net/base/net_errors.h"
-#include "net/dns/host_resolver.h"
-#include "net/dns/single_request_host_resolver.h"
-#include "url/gurl.h"
-
-namespace network_hints {
-
-namespace {
-
-const int kDefaultPort = 80;
-
-class DnsLookupRequest {
- public:
- DnsLookupRequest(net::HostResolver* host_resolver,
- const std::string& hostname)
- : hostname_(hostname),
- resolver_(host_resolver) {
- }
-
- // Return underlying network resolver status.
- // net::OK ==> Host was found synchronously.
- // net:ERR_IO_PENDING ==> Network will callback later with result.
- // anything else ==> Host was not found synchronously.
- int Start() {
- net::HostResolver::RequestInfo resolve_info(
- net::HostPortPair(hostname_, kDefaultPort));
-
- // Make a note that this is a speculative resolve request. This allows
- // separating it from real navigations in the observer's callback, and
- // lets the HostResolver know it can be de-prioritized.
- resolve_info.set_is_speculative(true);
- return resolver_.Resolve(
- resolve_info,
- net::DEFAULT_PRIORITY,
- &addresses_,
- base::Bind(&DnsLookupRequest::OnLookupFinished, base::Owned(this)),
- net::BoundNetLog());
- }
-
- private:
- void OnLookupFinished(int result) {
- VLOG(2) << __FUNCTION__ << ": " << hostname_ << ", result=" << result;
- }
-
- const std::string hostname_;
- net::SingleRequestHostResolver resolver_;
- net::AddressList addresses_;
-
- DISALLOW_COPY_AND_ASSIGN(DnsLookupRequest);
-};
-
-} // namespace
-
-void NetworkHintsImpl::Bind(mojom::NetworkHintsRequest request) {
- bindings_.AddBinding(this, std::move(request));
-}
-
-NetworkHintsImpl::NetworkHintsImpl(net::HostResolver* host_resolver)
- : host_resolver_(host_resolver) {
- DCHECK(host_resolver_);
-}
-
-NetworkHintsImpl::~NetworkHintsImpl() {}
-
-void NetworkHintsImpl::DNSPrefetch(const LookupRequest& lookup_request) {
- DCHECK(host_resolver_);
- for (const std::string& hostname : lookup_request.hostname_list) {
- DnsLookupRequest* request = new DnsLookupRequest(host_resolver_, hostname);
- // Note: DnsLookupRequest will be freed by the base::Owned call when
- // resolving has completed.
- request->Start();
- }
-}
-
-} // namespace network_hints
« no previous file with comments | « components/network_hints/browser/network_hints_impl.h ('k') | components/network_hints/browser/network_hints_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698