OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 // A SerialWorker that uses libresolv to initialize res_state and converts | 66 // A SerialWorker that uses libresolv to initialize res_state and converts |
67 // it to DnsConfig. | 67 // it to DnsConfig. |
68 class ConfigReader : public SerialWorker { | 68 class ConfigReader : public SerialWorker { |
69 public: | 69 public: |
70 typedef base::Callback<void(const DnsConfig& config)> CallbackType; | 70 typedef base::Callback<void(const DnsConfig& config)> CallbackType; |
71 explicit ConfigReader(const CallbackType& callback) | 71 explicit ConfigReader(const CallbackType& callback) |
72 : callback_(callback), success_(false) {} | 72 : callback_(callback), success_(false) {} |
73 | 73 |
74 void DoWork() OVERRIDE { | 74 virtual void DoWork() OVERRIDE { |
75 base::TimeTicks start_time = base::TimeTicks::Now(); | 75 base::TimeTicks start_time = base::TimeTicks::Now(); |
76 ConfigParsePosixResult result = ReadDnsConfig(&dns_config_); | 76 ConfigParsePosixResult result = ReadDnsConfig(&dns_config_); |
77 success_ = (result == CONFIG_PARSE_POSIX_OK); | 77 success_ = (result == CONFIG_PARSE_POSIX_OK); |
78 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ConfigParsePosix", | 78 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ConfigParsePosix", |
79 result, CONFIG_PARSE_POSIX_MAX); | 79 result, CONFIG_PARSE_POSIX_MAX); |
80 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.ConfigParseResult", success_); | 80 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.ConfigParseResult", success_); |
81 UMA_HISTOGRAM_TIMES("AsyncDNS.ConfigParseDuration", | 81 UMA_HISTOGRAM_TIMES("AsyncDNS.ConfigParseDuration", |
82 base::TimeTicks::Now() - start_time); | 82 base::TimeTicks::Now() - start_time); |
83 } | 83 } |
84 | 84 |
85 void OnWorkFinished() OVERRIDE { | 85 virtual void OnWorkFinished() OVERRIDE { |
86 DCHECK(!IsCancelled()); | 86 DCHECK(!IsCancelled()); |
87 if (success_) { | 87 if (success_) { |
88 callback_.Run(dns_config_); | 88 callback_.Run(dns_config_); |
89 } else { | 89 } else { |
90 LOG(WARNING) << "Failed to read DnsConfig."; | 90 LOG(WARNING) << "Failed to read DnsConfig."; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 virtual ~ConfigReader() {} | 95 virtual ~ConfigReader() {} |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 virtual ~StubDnsConfigService() {} | 285 virtual ~StubDnsConfigService() {} |
286 virtual void OnDNSChanged(unsigned detail) OVERRIDE {} | 286 virtual void OnDNSChanged(unsigned detail) OVERRIDE {} |
287 }; | 287 }; |
288 // static | 288 // static |
289 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { | 289 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { |
290 return scoped_ptr<DnsConfigService>(new StubDnsConfigService()); | 290 return scoped_ptr<DnsConfigService>(new StubDnsConfigService()); |
291 } | 291 } |
292 #endif | 292 #endif |
293 | 293 |
294 } // namespace net | 294 } // namespace net |
OLD | NEW |