| 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 #include "net/dns/dns_config_service_posix.h" | 5 #include "net/dns/dns_config_service_posix.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 success_(false) {} | 28 success_(false) {} |
| 29 | 29 |
| 30 void DoRead() OVERRIDE { | 30 void DoRead() OVERRIDE { |
| 31 struct __res_state res; | 31 struct __res_state res; |
| 32 if ((res_ninit(&res) == 0) && (res.options & RES_INIT)) { | 32 if ((res_ninit(&res) == 0) && (res.options & RES_INIT)) { |
| 33 success_ = ConvertResToConfig(res, &dns_config_); | 33 success_ = ConvertResToConfig(res, &dns_config_); |
| 34 } else { | 34 } else { |
| 35 // Note: res_ninit in glibc always returns 0 and sets RES_INIT. | 35 // Note: res_ninit in glibc always returns 0 and sets RES_INIT. |
| 36 success_ = false; | 36 success_ = false; |
| 37 } | 37 } |
| 38 #if defined(OS_MACOSX) |
| 39 res_ndestroy(&res); |
| 40 #else |
| 38 res_nclose(&res); | 41 res_nclose(&res); |
| 42 #endif |
| 39 } | 43 } |
| 40 | 44 |
| 41 void OnReadFinished() OVERRIDE { | 45 void OnReadFinished() OVERRIDE { |
| 42 if (success_) | 46 if (success_) |
| 43 service_->OnConfigRead(dns_config_); | 47 service_->OnConfigRead(dns_config_); |
| 44 } | 48 } |
| 45 | 49 |
| 46 private: | 50 private: |
| 47 virtual ~DnsConfigReader() {} | 51 virtual ~DnsConfigReader() {} |
| 48 | 52 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 dns_config->ndots = res.ndots; | 122 dns_config->ndots = res.ndots; |
| 119 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); | 123 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); |
| 120 dns_config->attempts = res.retry; | 124 dns_config->attempts = res.retry; |
| 121 dns_config->rotate = res.options & RES_ROTATE; | 125 dns_config->rotate = res.options & RES_ROTATE; |
| 122 dns_config->edns0 = res.options & RES_USE_EDNS0; | 126 dns_config->edns0 = res.options & RES_USE_EDNS0; |
| 123 | 127 |
| 124 return true; | 128 return true; |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace net | 131 } // namespace net |
| OLD | NEW |