| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 LOG(ERROR) << "DNS hosts watch failed."; | 434 LOG(ERROR) << "DNS hosts watch failed."; |
| 435 set_watch_failed(true); | 435 set_watch_failed(true); |
| 436 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus", | 436 UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus", |
| 437 DNS_CONFIG_WATCH_FAILED_HOSTS, | 437 DNS_CONFIG_WATCH_FAILED_HOSTS, |
| 438 DNS_CONFIG_WATCH_MAX); | 438 DNS_CONFIG_WATCH_MAX); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 void DnsConfigServicePosix::SetDnsConfigForTesting( | 442 void DnsConfigServicePosix::SetDnsConfigForTesting( |
| 443 const DnsConfig* dns_config) { | 443 const DnsConfig* dns_config) { |
| 444 DCHECK(CalledOnValidThread()); | 444 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 445 dns_config_for_testing_ = dns_config; | 445 dns_config_for_testing_ = dns_config; |
| 446 // Reset ConfigReader to bind new DnsConfig for testing. | 446 // Reset ConfigReader to bind new DnsConfig for testing. |
| 447 config_reader_->Cancel(); | 447 config_reader_->Cancel(); |
| 448 config_reader_ = make_scoped_refptr(new ConfigReader(this)); | 448 config_reader_ = make_scoped_refptr(new ConfigReader(this)); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void DnsConfigServicePosix::SetHostsFilePathForTesting( | 451 void DnsConfigServicePosix::SetHostsFilePathForTesting( |
| 452 const base::FilePath::CharType* file_path) { | 452 const base::FilePath::CharType* file_path) { |
| 453 DCHECK(CalledOnValidThread()); | 453 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 454 file_path_hosts_ = file_path; | 454 file_path_hosts_ = file_path; |
| 455 // Reset HostsReader to bind new hosts file path. | 455 // Reset HostsReader to bind new hosts file path. |
| 456 hosts_reader_->Cancel(); | 456 hosts_reader_->Cancel(); |
| 457 hosts_reader_ = make_scoped_refptr(new HostsReader(this)); | 457 hosts_reader_ = make_scoped_refptr(new HostsReader(this)); |
| 458 // If watching, reset to bind new hosts file path and resume watching. | 458 // If watching, reset to bind new hosts file path and resume watching. |
| 459 if (watcher_) { | 459 if (watcher_) { |
| 460 watcher_.reset(new Watcher(this)); | 460 watcher_.reset(new Watcher(this)); |
| 461 watcher_->Watch(); | 461 watcher_->Watch(); |
| 462 } | 462 } |
| 463 } | 463 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 if (dns_config->nameservers[i].address().IsZero()) | 567 if (dns_config->nameservers[i].address().IsZero()) |
| 568 return CONFIG_PARSE_POSIX_NULL_ADDRESS; | 568 return CONFIG_PARSE_POSIX_NULL_ADDRESS; |
| 569 } | 569 } |
| 570 return CONFIG_PARSE_POSIX_OK; | 570 return CONFIG_PARSE_POSIX_OK; |
| 571 } | 571 } |
| 572 | 572 |
| 573 #else // defined(OS_ANDROID) | 573 #else // defined(OS_ANDROID) |
| 574 | 574 |
| 575 bool DnsConfigServicePosix::SeenChangeSince( | 575 bool DnsConfigServicePosix::SeenChangeSince( |
| 576 const base::Time& since_time) const { | 576 const base::Time& since_time) const { |
| 577 DCHECK(CalledOnValidThread()); | 577 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 578 return seen_config_change_; | 578 return seen_config_change_; |
| 579 } | 579 } |
| 580 | 580 |
| 581 void DnsConfigServicePosix::OnNetworkChanged( | 581 void DnsConfigServicePosix::OnNetworkChanged( |
| 582 NetworkChangeNotifier::ConnectionType type) { | 582 NetworkChangeNotifier::ConnectionType type) { |
| 583 DCHECK(CalledOnValidThread()); | 583 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 584 DCHECK(watcher_); | 584 DCHECK(watcher_); |
| 585 watcher_->OnNetworkChanged(type); | 585 watcher_->OnNetworkChanged(type); |
| 586 } | 586 } |
| 587 #endif // !defined(OS_ANDROID) | 587 #endif // !defined(OS_ANDROID) |
| 588 | 588 |
| 589 } // namespace internal | 589 } // namespace internal |
| 590 | 590 |
| 591 // static | 591 // static |
| 592 std::unique_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { | 592 std::unique_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { |
| 593 return std::unique_ptr<DnsConfigService>( | 593 return std::unique_ptr<DnsConfigService>( |
| 594 new internal::DnsConfigServicePosix()); | 594 new internal::DnsConfigServicePosix()); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace net | 597 } // namespace net |
| OLD | NEW |