| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PROC_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_PROC_H_ |
| 6 #define NET_BASE_HOST_RESOLVER_PROC_H_ | 6 #define NET_BASE_HOST_RESOLVER_PROC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "net/base/address_family.h" | 11 #include "net/base/address_family.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 40 // Asks the fallback procedure (if set) to do the resolve. | 40 // Asks the fallback procedure (if set) to do the resolve. |
| 41 int ResolveUsingPrevious(const std::string& host, | 41 int ResolveUsingPrevious(const std::string& host, |
| 42 AddressFamily address_family, | 42 AddressFamily address_family, |
| 43 AddressList* addrlist); | 43 AddressList* addrlist); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 friend class HostResolverImpl; | 46 friend class HostResolverImpl; |
| 47 friend class MockHostResolverBase; | 47 friend class MockHostResolverBase; |
| 48 friend class ScopedDefaultHostResolverProc; | 48 friend class ScopedDefaultHostResolverProc; |
| 49 | 49 |
| 50 // Sets the previous procedure in the chain. | 50 // Sets the previous procedure in the chain. Aborts if this would result in a |
| 51 void set_previous_proc(HostResolverProc* proc) { | 51 // cycle. |
| 52 previous_proc_ = proc; | 52 void SetPreviousProc(HostResolverProc* proc); |
| 53 } | 53 |
| 54 // Sets the last procedure in the chain, i.e. appends |proc| to the end of the |
| 55 // current chain. Aborts if this would result in a cycle. |
| 56 void SetLastProc(HostResolverProc* proc); |
| 57 |
| 58 // Returns the last procedure in the chain starting at |proc|. Will return |
| 59 // NULL iff |proc| is NULL. |
| 60 static HostResolverProc* GetLastProc(HostResolverProc* proc); |
| 54 | 61 |
| 55 // Sets the default host resolver procedure that is used by HostResolverImpl. | 62 // Sets the default host resolver procedure that is used by HostResolverImpl. |
| 56 // This can be used through ScopedDefaultHostResolverProc to set a catch-all | 63 // This can be used through ScopedDefaultHostResolverProc to set a catch-all |
| 57 // DNS block in unit-tests (individual tests should use MockHostResolver to | 64 // DNS block in unit-tests (individual tests should use MockHostResolver to |
| 58 // prevent hitting the network). | 65 // prevent hitting the network). |
| 59 static HostResolverProc* SetDefault(HostResolverProc* proc); | 66 static HostResolverProc* SetDefault(HostResolverProc* proc); |
| 60 static HostResolverProc* GetDefault(); | 67 static HostResolverProc* GetDefault(); |
| 61 | 68 |
| 62 private: | |
| 63 scoped_refptr<HostResolverProc> previous_proc_; | 69 scoped_refptr<HostResolverProc> previous_proc_; |
| 64 static HostResolverProc* default_proc_; | 70 static HostResolverProc* default_proc_; |
| 65 | 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); | 72 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 // Resolves |host| to an address list, using the system's default host resolver. | 75 // Resolves |host| to an address list, using the system's default host resolver. |
| 70 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills | 76 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills |
| 71 // |addrlist| with a list of socket addresses. Otherwise returns a | 77 // |addrlist| with a list of socket addresses. Otherwise returns a |
| 72 // network error code. | 78 // network error code. |
| 73 int SystemHostResolverProc(const std::string& host, | 79 int SystemHostResolverProc(const std::string& host, |
| 74 AddressFamily address_family, | 80 AddressFamily address_family, |
| 75 AddressList* addrlist); | 81 AddressList* addrlist); |
| 76 | 82 |
| 77 } // namespace net | 83 } // namespace net |
| 78 | 84 |
| 79 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ | 85 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ |
| OLD | NEW |