OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_BASE_HOST_RESOLVER_IMPL_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_IMPL_H_ |
6 #define NET_BASE_HOST_RESOLVER_IMPL_H_ | 6 #define NET_BASE_HOST_RESOLVER_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "net/base/capturing_net_log.h" | 16 #include "net/base/capturing_net_log.h" |
17 #include "net/base/host_cache.h" | 17 #include "net/base/host_cache.h" |
18 #include "net/base/host_resolver.h" | 18 #include "net/base/host_resolver.h" |
19 #include "net/base/host_resolver_proc.h" | 19 #include "net/base/host_resolver_proc.h" |
20 #include "net/base/net_api.h" | 20 #include "net/base/net_export.h" |
21 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 | 25 |
26 // For each hostname that is requested, HostResolver creates a | 26 // For each hostname that is requested, HostResolver creates a |
27 // HostResolverImpl::Job. This job gets dispatched to a thread in the global | 27 // HostResolverImpl::Job. This job gets dispatched to a thread in the global |
28 // WorkerPool, where it runs SystemHostResolverProc(). If requests for that same | 28 // WorkerPool, where it runs SystemHostResolverProc(). If requests for that same |
29 // host are made while the job is already outstanding, then they are attached | 29 // host are made while the job is already outstanding, then they are attached |
30 // to the existing job rather than creating a new one. This avoids doing | 30 // to the existing job rather than creating a new one. This avoids doing |
(...skipping 21 matching lines...) Expand all Loading... |
52 // threads. | 52 // threads. |
53 // | 53 // |
54 // Requests are ordered in the queue based on their priority. | 54 // Requests are ordered in the queue based on their priority. |
55 // | 55 // |
56 // Whenever we try to resolve the host, we post a delayed task to check if host | 56 // Whenever we try to resolve the host, we post a delayed task to check if host |
57 // resolution (OnLookupComplete) is completed or not. If the original attempt | 57 // resolution (OnLookupComplete) is completed or not. If the original attempt |
58 // hasn't completed, then we start another attempt for host resolution. We take | 58 // hasn't completed, then we start another attempt for host resolution. We take |
59 // the results from the first attempt that finishes and ignore the results from | 59 // the results from the first attempt that finishes and ignore the results from |
60 // all other attempts. | 60 // all other attempts. |
61 | 61 |
62 class NET_API HostResolverImpl | 62 class NET_EXPORT HostResolverImpl |
63 : public HostResolver, | 63 : public HostResolver, |
64 NON_EXPORTED_BASE(public base::NonThreadSafe), | 64 NON_EXPORTED_BASE(public base::NonThreadSafe), |
65 public NetworkChangeNotifier::IPAddressObserver { | 65 public NetworkChangeNotifier::IPAddressObserver { |
66 public: | 66 public: |
67 // The index into |job_pools_| for the various job pools. Pools with a higher | 67 // The index into |job_pools_| for the various job pools. Pools with a higher |
68 // index have lower priority. | 68 // index have lower priority. |
69 // | 69 // |
70 // Note: This is currently unused, since there is a single pool | 70 // Note: This is currently unused, since there is a single pool |
71 // for all requests. | 71 // for all requests. |
72 enum JobPoolIndex { | 72 enum JobPoolIndex { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 HostResolverFlags additional_resolver_flags_; | 364 HostResolverFlags additional_resolver_flags_; |
365 | 365 |
366 NetLog* net_log_; | 366 NetLog* net_log_; |
367 | 367 |
368 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 368 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
369 }; | 369 }; |
370 | 370 |
371 } // namespace net | 371 } // namespace net |
372 | 372 |
373 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 373 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |