Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / net / dns / host_resolver_mojo.h
blobff8ea1f4639555ecda24b57679d1852acc829178
1 // Copyright 2015 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.
5 #ifndef NET_DNS_HOST_RESOLVER_MOJO_H_
6 #define NET_DNS_HOST_RESOLVER_MOJO_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "net/dns/host_cache.h"
12 #include "net/dns/host_resolver.h"
13 #include "net/interfaces/host_resolver_service.mojom.h"
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
16 namespace net {
17 class AddressList;
18 class BoundNetLog;
20 // A HostResolver implementation that delegates to an interfaces::HostResolver
21 // mojo interface.
22 class HostResolverMojo : public HostResolver, public mojo::ErrorHandler {
23 public:
24 HostResolverMojo(interfaces::HostResolverPtr resolver,
25 const base::Closure& disconnect_callback);
26 ~HostResolverMojo() override;
28 // HostResolver overrides.
29 int Resolve(const RequestInfo& info,
30 RequestPriority priority,
31 AddressList* addresses,
32 const CompletionCallback& callback,
33 RequestHandle* request_handle,
34 const BoundNetLog& source_net_log) override;
35 int ResolveFromCache(const RequestInfo& info,
36 AddressList* addresses,
37 const BoundNetLog& source_net_log) override;
38 void CancelRequest(RequestHandle req) override;
39 HostCache* GetHostCache() override;
41 void set_disconnect_callback(const base::Closure& disconnect_callback) {
42 disconnect_callback_ = disconnect_callback;
45 private:
46 class Job;
48 // mojo::ErrorHandler override.
49 void OnConnectionError() override;
51 int ResolveFromCacheInternal(const RequestInfo& info,
52 const HostCache::Key& key,
53 AddressList* addresses);
55 interfaces::HostResolverPtr resolver_;
57 base::Closure disconnect_callback_;
59 scoped_ptr<HostCache> host_cache_;
60 base::WeakPtrFactory<HostCache> host_cache_weak_factory_;
62 base::ThreadChecker thread_checker_;
64 DISALLOW_COPY_AND_ASSIGN(HostResolverMojo);
67 } // namespace net
69 #endif // NET_DNS_HOST_RESOLVER_MOJO_H_