| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const FilePath path_; | 208 const FilePath path_; |
| 209 const CallbackType callback_; | 209 const CallbackType callback_; |
| 210 // Written in DoWork, read in OnWorkFinished, no locking necessary. | 210 // Written in DoWork, read in OnWorkFinished, no locking necessary. |
| 211 DnsHosts hosts_; | 211 DnsHosts hosts_; |
| 212 bool success_; | 212 bool success_; |
| 213 | 213 |
| 214 DISALLOW_COPY_AND_ASSIGN(HostsReader); | 214 DISALLOW_COPY_AND_ASSIGN(HostsReader); |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 DnsConfigServicePosix::DnsConfigServicePosix() | 217 DnsConfigServicePosix::DnsConfigServicePosix() |
| 218 : watcher_(new Watcher(this)), | 218 : config_reader_(new ConfigReader(this)), |
| 219 config_reader_(new ConfigReader(this)), | |
| 220 hosts_reader_(new HostsReader(this)) {} | 219 hosts_reader_(new HostsReader(this)) {} |
| 221 | 220 |
| 222 DnsConfigServicePosix::~DnsConfigServicePosix() { | 221 DnsConfigServicePosix::~DnsConfigServicePosix() { |
| 223 config_reader_->Cancel(); | 222 config_reader_->Cancel(); |
| 224 hosts_reader_->Cancel(); | 223 hosts_reader_->Cancel(); |
| 225 } | 224 } |
| 226 | 225 |
| 227 void DnsConfigServicePosix::ReadNow() { | 226 void DnsConfigServicePosix::ReadNow() { |
| 228 config_reader_->WorkNow(); | 227 config_reader_->WorkNow(); |
| 229 hosts_reader_->WorkNow(); | 228 hosts_reader_->WorkNow(); |
| 230 } | 229 } |
| 231 | 230 |
| 232 bool DnsConfigServicePosix::StartWatching() { | 231 bool DnsConfigServicePosix::StartWatching() { |
| 233 // TODO(szym): re-start watcher if that makes sense. http://crbug.com/116139 | 232 // TODO(szym): re-start watcher if that makes sense. http://crbug.com/116139 |
| 233 watcher_.reset(new Watcher(this)); |
| 234 return watcher_->Watch(); | 234 return watcher_->Watch(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void DnsConfigServicePosix::OnConfigChanged(bool succeeded) { | 237 void DnsConfigServicePosix::OnConfigChanged(bool succeeded) { |
| 238 InvalidateConfig(); | 238 InvalidateConfig(); |
| 239 if (succeeded) { | 239 if (succeeded) { |
| 240 config_reader_->WorkNow(); | 240 config_reader_->WorkNow(); |
| 241 } else { | 241 } else { |
| 242 LOG(ERROR) << "DNS config watch failed."; | 242 LOG(ERROR) << "DNS config watch failed."; |
| 243 set_watch_failed(true); | 243 set_watch_failed(true); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 virtual void ReadNow() OVERRIDE {} | 367 virtual void ReadNow() OVERRIDE {} |
| 368 virtual bool StartWatching() OVERRIDE { return false; } | 368 virtual bool StartWatching() OVERRIDE { return false; } |
| 369 }; | 369 }; |
| 370 // static | 370 // static |
| 371 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { | 371 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { |
| 372 return scoped_ptr<DnsConfigService>(new StubDnsConfigService()); | 372 return scoped_ptr<DnsConfigService>(new StubDnsConfigService()); |
| 373 } | 373 } |
| 374 #endif | 374 #endif |
| 375 | 375 |
| 376 } // namespace net | 376 } // namespace net |
| OLD | NEW |