| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Creates a HostResolver that caches up to |max_cache_entries| for | 44 // Creates a HostResolver that caches up to |max_cache_entries| for |
| 45 // |cache_duration_ms| milliseconds. |resolver_proc| is used to perform | 45 // |cache_duration_ms| milliseconds. |resolver_proc| is used to perform |
| 46 // the actual resolves; it must be thread-safe since it is run from | 46 // the actual resolves; it must be thread-safe since it is run from |
| 47 // multiple worker threads. If |resolver_proc| is NULL then the default | 47 // multiple worker threads. If |resolver_proc| is NULL then the default |
| 48 // host resolver procedure is used (which is SystemHostResolverProc except | 48 // host resolver procedure is used (which is SystemHostResolverProc except |
| 49 // if overridden) | 49 // if overridden) |
| 50 HostResolverImpl(HostResolverProc* resolver_proc, | 50 HostResolverImpl(HostResolverProc* resolver_proc, |
| 51 int max_cache_entries, | 51 int max_cache_entries, |
| 52 int cache_duration_ms); | 52 int cache_duration_ms); |
| 53 | 53 |
| 54 // If any completion callbacks are pending when the resolver is destroyed, | |
| 55 // the host resolutions are cancelled, and the completion callbacks will not | |
| 56 // be called. | |
| 57 virtual ~HostResolverImpl(); | |
| 58 | |
| 59 // HostResolver methods: | 54 // HostResolver methods: |
| 60 virtual int Resolve(const RequestInfo& info, | 55 virtual int Resolve(const RequestInfo& info, |
| 61 AddressList* addresses, | 56 AddressList* addresses, |
| 62 CompletionCallback* callback, | 57 CompletionCallback* callback, |
| 63 RequestHandle* out_req, | 58 RequestHandle* out_req, |
| 64 LoadLog* load_log); | 59 LoadLog* load_log); |
| 65 virtual void CancelRequest(RequestHandle req); | 60 virtual void CancelRequest(RequestHandle req); |
| 66 virtual void AddObserver(Observer* observer); | 61 virtual void AddObserver(Observer* observer); |
| 67 virtual void RemoveObserver(Observer* observer); | 62 virtual void RemoveObserver(Observer* observer); |
| 68 virtual HostCache* GetHostCache(); | 63 virtual HostCache* GetHostCache(); |
| 69 | 64 |
| 70 // TODO(eroman): temp hack for http://crbug.com/15513 | 65 // TODO(eroman): temp hack for http://crbug.com/15513 |
| 71 virtual void Shutdown(); | 66 virtual void Shutdown(); |
| 72 | 67 |
| 73 virtual void SetDefaultAddressFamily(AddressFamily address_family) { | 68 virtual void SetDefaultAddressFamily(AddressFamily address_family) { |
| 74 default_address_family_ = address_family; | 69 default_address_family_ = address_family; |
| 75 } | 70 } |
| 76 | 71 |
| 77 private: | 72 private: |
| 78 class Job; | 73 class Job; |
| 79 class Request; | 74 class Request; |
| 80 typedef std::vector<Request*> RequestsList; | 75 typedef std::vector<Request*> RequestsList; |
| 81 typedef HostCache::Key Key; | 76 typedef HostCache::Key Key; |
| 82 typedef std::map<Key, scoped_refptr<Job> > JobMap; | 77 typedef std::map<Key, scoped_refptr<Job> > JobMap; |
| 83 typedef std::vector<Observer*> ObserversList; | 78 typedef std::vector<Observer*> ObserversList; |
| 84 | 79 |
| 80 // If any completion callbacks are pending when the resolver is destroyed, |
| 81 // the host resolutions are cancelled, and the completion callbacks will not |
| 82 // be called. |
| 83 virtual ~HostResolverImpl(); |
| 84 |
| 85 // Returns the HostResolverProc to use for this instance. | 85 // Returns the HostResolverProc to use for this instance. |
| 86 HostResolverProc* effective_resolver_proc() const { | 86 HostResolverProc* effective_resolver_proc() const { |
| 87 return resolver_proc_ ? | 87 return resolver_proc_ ? |
| 88 resolver_proc_.get() : HostResolverProc::GetDefault(); | 88 resolver_proc_.get() : HostResolverProc::GetDefault(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Adds a job to outstanding jobs list. | 91 // Adds a job to outstanding jobs list. |
| 92 void AddOutstandingJob(Job* job); | 92 void AddOutstandingJob(Job* job); |
| 93 | 93 |
| 94 // Returns the outstanding job for |key|, or NULL if there is none. | 94 // Returns the outstanding job for |key|, or NULL if there is none. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 // TODO(eroman): temp hack for http://crbug.com/15513 | 143 // TODO(eroman): temp hack for http://crbug.com/15513 |
| 144 bool shutdown_; | 144 bool shutdown_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 146 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace net | 149 } // namespace net |
| 150 | 150 |
| 151 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 151 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |