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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 static const FilePath::CharType* kFilePathConfig = | 53 static const FilePath::CharType* kFilePathConfig = |
54 FILE_PATH_LITERAL(_PATH_RESCONF); | 54 FILE_PATH_LITERAL(_PATH_RESCONF); |
55 | 55 |
56 class ConfigWatcher { | 56 class ConfigWatcher { |
57 public: | 57 public: |
58 typedef base::Callback<void(bool succeeded)> CallbackType; | 58 typedef base::Callback<void(bool succeeded)> CallbackType; |
59 | 59 |
60 bool Watch(const CallbackType& callback) { | 60 bool Watch(const CallbackType& callback) { |
61 callback_ = callback; | 61 callback_ = callback; |
62 return watcher_.Watch(FilePath(kFilePathConfig), | 62 return watcher_.Watch(FilePath(kFilePathConfig), false, |
63 base::Bind(&ConfigWatcher::OnCallback, | 63 base::Bind(&ConfigWatcher::OnCallback, |
64 base::Unretained(this))); | 64 base::Unretained(this))); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 void OnCallback(const FilePath& path, bool error) { | 68 void OnCallback(const FilePath& path, bool error) { |
69 callback_.Run(!error); | 69 callback_.Run(!error); |
70 } | 70 } |
71 | 71 |
72 base::files::FilePathWatcher watcher_; | 72 base::files::FilePathWatcher watcher_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 ~Watcher() {} | 113 ~Watcher() {} |
114 | 114 |
115 bool Watch() { | 115 bool Watch() { |
116 bool success = true; | 116 bool success = true; |
117 if (!config_watcher_.Watch( | 117 if (!config_watcher_.Watch( |
118 base::Bind(&DnsConfigServicePosix::OnConfigChanged, | 118 base::Bind(&DnsConfigServicePosix::OnConfigChanged, |
119 base::Unretained(service_)))) { | 119 base::Unretained(service_)))) { |
120 LOG(ERROR) << "DNS config watch failed to start."; | 120 LOG(ERROR) << "DNS config watch failed to start."; |
121 success = false; | 121 success = false; |
122 } | 122 } |
123 if (!hosts_watcher_.Watch(FilePath(kFilePathHosts), | 123 if (!hosts_watcher_.Watch(FilePath(kFilePathHosts), false, |
124 base::Bind(&Watcher::OnHostsChanged, | 124 base::Bind(&Watcher::OnHostsChanged, |
125 base::Unretained(this)))) { | 125 base::Unretained(this)))) { |
126 LOG(ERROR) << "DNS hosts watch failed to start."; | 126 LOG(ERROR) << "DNS hosts watch failed to start."; |
127 success = false; | 127 success = false; |
128 } | 128 } |
129 return success; | 129 return success; |
130 } | 130 } |
131 | 131 |
132 private: | 132 private: |
133 void OnHostsChanged(const FilePath& path, bool error) { | 133 void OnHostsChanged(const FilePath& path, bool error) { |
(...skipping 233 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 |