Chromium Code Reviews| 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_log.h" | 21 #include "net/base/net_log.h" |
| 21 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| 25 // For each hostname that is requested, HostResolver creates a | 26 // For each hostname that is requested, HostResolver creates a |
| 26 // 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 |
| 27 // WorkerPool, where it runs SystemHostResolverProc(). If requests for that same | 28 // WorkerPool, where it runs SystemHostResolverProc(). If requests for that same |
| 28 // 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 |
| 29 // 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... | |
| 51 // threads. | 52 // threads. |
| 52 // | 53 // |
| 53 // Requests are ordered in the queue based on their priority. | 54 // Requests are ordered in the queue based on their priority. |
| 54 // | 55 // |
| 55 // 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 |
| 56 // resolution (OnLookupComplete) is completed or not. If the original attempt | 57 // resolution (OnLookupComplete) is completed or not. If the original attempt |
| 57 // 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 |
| 58 // 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 |
| 59 // all other attempts. | 60 // all other attempts. |
| 60 | 61 |
| 61 class HostResolverImpl : public HostResolver, | 62 MSVC_PUSH_DISABLE_WARNING(4275) |
| 62 public base::NonThreadSafe, | 63 class NET_API HostResolverImpl |
|
wtc
2011/05/16 20:55:17
Can this be NET_TEST? "Impl" seems to imply it is
rvargas (doing something else)
2011/05/16 22:41:56
Yup. It is used by four different files in chrome/
| |
| 63 public NetworkChangeNotifier::IPAddressObserver { | 64 : public HostResolver, |
| 65 public base::NonThreadSafe, | |
| 66 public NetworkChangeNotifier::IPAddressObserver { | |
| 67 MSVC_POP_WARNING() | |
| 64 public: | 68 public: |
| 65 // The index into |job_pools_| for the various job pools. Pools with a higher | 69 // The index into |job_pools_| for the various job pools. Pools with a higher |
| 66 // index have lower priority. | 70 // index have lower priority. |
| 67 // | 71 // |
| 68 // Note: This is currently unused, since there is a single pool | 72 // Note: This is currently unused, since there is a single pool |
| 69 // for all requests. | 73 // for all requests. |
| 70 enum JobPoolIndex { | 74 enum JobPoolIndex { |
| 71 POOL_NORMAL = 0, | 75 POOL_NORMAL = 0, |
| 72 POOL_COUNT, | 76 POOL_COUNT, |
| 73 }; | 77 }; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 HostResolverFlags additional_resolver_flags_; | 342 HostResolverFlags additional_resolver_flags_; |
| 339 | 343 |
| 340 NetLog* net_log_; | 344 NetLog* net_log_; |
| 341 | 345 |
| 342 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 346 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 343 }; | 347 }; |
| 344 | 348 |
| 345 } // namespace net | 349 } // namespace net |
| 346 | 350 |
| 347 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 351 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |