| 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 #ifndef NET_DNS_DNS_HOSTS_H_ | 5 #ifndef NET_DNS_DNS_HOSTS_H_ |
| 6 #define NET_DNS_DNS_HOSTS_H_ | 6 #define NET_DNS_DNS_HOSTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // A SerialWorker that reads a HOSTS file and runs Callback. | 41 // A SerialWorker that reads a HOSTS file and runs Callback. |
| 42 // Call WorkNow() to indicate file needs to be re-read. | 42 // Call WorkNow() to indicate file needs to be re-read. |
| 43 // Call Cancel() to disable the callback. | 43 // Call Cancel() to disable the callback. |
| 44 class NET_EXPORT_PRIVATE DnsHostsReader | 44 class NET_EXPORT_PRIVATE DnsHostsReader |
| 45 : NON_EXPORTED_BASE(public SerialWorker) { | 45 : NON_EXPORTED_BASE(public SerialWorker) { |
| 46 public: | 46 public: |
| 47 typedef base::Callback<void(const DnsHosts& hosts)> CallbackType; | 47 typedef base::Callback<void(const DnsHosts& hosts)> CallbackType; |
| 48 | 48 |
| 49 DnsHostsReader(const FilePath& path, const CallbackType& callback); | 49 DnsHostsReader(const FilePath& path, const CallbackType& callback); |
| 50 | 50 |
| 51 private: | 51 const FilePath& path() const { return path_; } |
| 52 |
| 53 protected: |
| 54 explicit DnsHostsReader(const FilePath& path); |
| 52 virtual ~DnsHostsReader(); | 55 virtual ~DnsHostsReader(); |
| 53 | 56 |
| 54 virtual void DoWork() OVERRIDE; | 57 virtual void DoWork() OVERRIDE; |
| 55 virtual void OnWorkFinished() OVERRIDE; | 58 virtual void OnWorkFinished() OVERRIDE; |
| 56 | 59 |
| 57 FilePath path_; | 60 FilePath path_; |
| 58 CallbackType callback_; | 61 CallbackType callback_; |
| 59 // Written in DoWork, read in OnWorkFinished, no locking necessary. | 62 // Written in DoWork, read in OnWorkFinished, no locking necessary. |
| 60 DnsHosts dns_hosts_; | 63 DnsHosts dns_hosts_; |
| 61 bool success_; | 64 bool success_; |
| 62 | 65 |
| 63 DISALLOW_COPY_AND_ASSIGN(DnsHostsReader); | 66 DISALLOW_COPY_AND_ASSIGN(DnsHostsReader); |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 | 69 |
| 67 } // namespace net | 70 } // namespace net |
| 68 | 71 |
| 69 #endif // NET_DNS_DNS_HOSTS_H_ | 72 #endif // NET_DNS_DNS_HOSTS_H_ |
| 70 | 73 |
| OLD | NEW |