Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: net/dns/dns_config_service_posix.cc

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/dns_config_service_posix.h ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 }; 256 };
257 257
258 // A SerialWorker that uses libresolv to initialize res_state and converts 258 // A SerialWorker that uses libresolv to initialize res_state and converts
259 // it to DnsConfig (except on Android, where it reads system properties 259 // it to DnsConfig (except on Android, where it reads system properties
260 // net.dns1 and net.dns2; see #if around ReadDnsConfig above.) 260 // net.dns1 and net.dns2; see #if around ReadDnsConfig above.)
261 class DnsConfigServicePosix::ConfigReader : public SerialWorker { 261 class DnsConfigServicePosix::ConfigReader : public SerialWorker {
262 public: 262 public:
263 explicit ConfigReader(DnsConfigServicePosix* service) 263 explicit ConfigReader(DnsConfigServicePosix* service)
264 : service_(service), success_(false) {} 264 : service_(service), success_(false) {}
265 265
266 virtual void DoWork() override { 266 void DoWork() override {
267 base::TimeTicks start_time = base::TimeTicks::Now(); 267 base::TimeTicks start_time = base::TimeTicks::Now();
268 ConfigParsePosixResult result = ReadDnsConfig(&dns_config_); 268 ConfigParsePosixResult result = ReadDnsConfig(&dns_config_);
269 switch (result) { 269 switch (result) {
270 case CONFIG_PARSE_POSIX_MISSING_OPTIONS: 270 case CONFIG_PARSE_POSIX_MISSING_OPTIONS:
271 case CONFIG_PARSE_POSIX_UNHANDLED_OPTIONS: 271 case CONFIG_PARSE_POSIX_UNHANDLED_OPTIONS:
272 DCHECK(dns_config_.unhandled_options); 272 DCHECK(dns_config_.unhandled_options);
273 // Fall through. 273 // Fall through.
274 case CONFIG_PARSE_POSIX_OK: 274 case CONFIG_PARSE_POSIX_OK:
275 success_ = true; 275 success_ = true;
276 break; 276 break;
277 default: 277 default:
278 success_ = false; 278 success_ = false;
279 break; 279 break;
280 } 280 }
281 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ConfigParsePosix", 281 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ConfigParsePosix",
282 result, CONFIG_PARSE_POSIX_MAX); 282 result, CONFIG_PARSE_POSIX_MAX);
283 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.ConfigParseResult", success_); 283 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.ConfigParseResult", success_);
284 UMA_HISTOGRAM_TIMES("AsyncDNS.ConfigParseDuration", 284 UMA_HISTOGRAM_TIMES("AsyncDNS.ConfigParseDuration",
285 base::TimeTicks::Now() - start_time); 285 base::TimeTicks::Now() - start_time);
286 } 286 }
287 287
288 virtual void OnWorkFinished() override { 288 void OnWorkFinished() override {
289 DCHECK(!IsCancelled()); 289 DCHECK(!IsCancelled());
290 if (success_) { 290 if (success_) {
291 service_->OnConfigRead(dns_config_); 291 service_->OnConfigRead(dns_config_);
292 } else { 292 } else {
293 LOG(WARNING) << "Failed to read DnsConfig."; 293 LOG(WARNING) << "Failed to read DnsConfig.";
294 } 294 }
295 } 295 }
296 296
297 private: 297 private:
298 virtual ~ConfigReader() {} 298 ~ConfigReader() override {}
299 299
300 DnsConfigServicePosix* service_; 300 DnsConfigServicePosix* service_;
301 // Written in DoWork, read in OnWorkFinished, no locking necessary. 301 // Written in DoWork, read in OnWorkFinished, no locking necessary.
302 DnsConfig dns_config_; 302 DnsConfig dns_config_;
303 bool success_; 303 bool success_;
304 304
305 DISALLOW_COPY_AND_ASSIGN(ConfigReader); 305 DISALLOW_COPY_AND_ASSIGN(ConfigReader);
306 }; 306 };
307 307
308 // A SerialWorker that reads the HOSTS file and runs Callback. 308 // A SerialWorker that reads the HOSTS file and runs Callback.
309 class DnsConfigServicePosix::HostsReader : public SerialWorker { 309 class DnsConfigServicePosix::HostsReader : public SerialWorker {
310 public: 310 public:
311 explicit HostsReader(DnsConfigServicePosix* service) 311 explicit HostsReader(DnsConfigServicePosix* service)
312 : service_(service), path_(kFilePathHosts), success_(false) {} 312 : service_(service), path_(kFilePathHosts), success_(false) {}
313 313
314 private: 314 private:
315 virtual ~HostsReader() {} 315 ~HostsReader() override {}
316 316
317 virtual void DoWork() override { 317 void DoWork() override {
318 base::TimeTicks start_time = base::TimeTicks::Now(); 318 base::TimeTicks start_time = base::TimeTicks::Now();
319 success_ = ParseHostsFile(path_, &hosts_); 319 success_ = ParseHostsFile(path_, &hosts_);
320 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HostParseResult", success_); 320 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HostParseResult", success_);
321 UMA_HISTOGRAM_TIMES("AsyncDNS.HostsParseDuration", 321 UMA_HISTOGRAM_TIMES("AsyncDNS.HostsParseDuration",
322 base::TimeTicks::Now() - start_time); 322 base::TimeTicks::Now() - start_time);
323 } 323 }
324 324
325 virtual void OnWorkFinished() override { 325 void OnWorkFinished() override {
326 if (success_) { 326 if (success_) {
327 service_->OnHostsRead(hosts_); 327 service_->OnHostsRead(hosts_);
328 } else { 328 } else {
329 LOG(WARNING) << "Failed to read DnsHosts."; 329 LOG(WARNING) << "Failed to read DnsHosts.";
330 } 330 }
331 } 331 }
332 332
333 DnsConfigServicePosix* service_; 333 DnsConfigServicePosix* service_;
334 const base::FilePath path_; 334 const base::FilePath path_;
335 // Written in DoWork, read in OnWorkFinished, no locking necessary. 335 // Written in DoWork, read in OnWorkFinished, no locking necessary.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 #endif // !defined(OS_ANDROID) 490 #endif // !defined(OS_ANDROID)
491 491
492 } // namespace internal 492 } // namespace internal
493 493
494 // static 494 // static
495 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { 495 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
496 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix()); 496 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix());
497 } 497 }
498 498
499 } // namespace net 499 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_posix.h ('k') | net/dns/dns_config_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698