| 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 const FilePath& path() const { return path_; } |
| 52 |
| 51 private: | 53 private: |
| 52 virtual ~DnsHostsReader(); | 54 virtual ~DnsHostsReader(); |
| 53 | 55 |
| 54 virtual void DoWork() OVERRIDE; | 56 virtual void DoWork() OVERRIDE; |
| 55 virtual void OnWorkFinished() OVERRIDE; | 57 virtual void OnWorkFinished() OVERRIDE; |
| 56 | 58 |
| 57 FilePath path_; | 59 FilePath path_; |
| 58 CallbackType callback_; | 60 CallbackType callback_; |
| 59 // Written in DoWork, read in OnWorkFinished, no locking necessary. | 61 // Written in DoWork, read in OnWorkFinished, no locking necessary. |
| 60 DnsHosts dns_hosts_; | 62 DnsHosts dns_hosts_; |
| 61 bool success_; | 63 bool success_; |
| 62 | 64 |
| 63 DISALLOW_COPY_AND_ASSIGN(DnsHostsReader); | 65 DISALLOW_COPY_AND_ASSIGN(DnsHostsReader); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 | 68 |
| 67 } // namespace net | 69 } // namespace net |
| 68 | 70 |
| 69 #endif // NET_DNS_DNS_HOSTS_H_ | 71 #endif // NET_DNS_DNS_HOSTS_H_ |
| 70 | 72 |
| OLD | NEW |