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/base/dns_reloader.h" | 5 #include "net/base/dns_reloader.h" |
6 | 6 |
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \ | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \ |
8 !defined(OS_ANDROID) | 8 !defined(OS_ANDROID) |
9 | 9 |
10 #include <resolv.h> | 10 #include <resolv.h> |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Android does not have /etc/resolv.conf. The system takes care of nameserver | 39 // Android does not have /etc/resolv.conf. The system takes care of nameserver |
40 // changes, so none of this is needed. | 40 // changes, so none of this is needed. |
41 | 41 |
42 class DnsReloader : public net::NetworkChangeNotifier::DNSObserver { | 42 class DnsReloader : public net::NetworkChangeNotifier::DNSObserver { |
43 public: | 43 public: |
44 struct ReloadState { | 44 struct ReloadState { |
45 int resolver_generation; | 45 int resolver_generation; |
46 }; | 46 }; |
47 | 47 |
48 // NetworkChangeNotifier::DNSObserver: | 48 // NetworkChangeNotifier::DNSObserver: |
49 virtual void OnDNSChanged() OVERRIDE { | 49 virtual void OnDNSChanged() override { |
50 DCHECK(base::MessageLoopForIO::IsCurrent()); | 50 DCHECK(base::MessageLoopForIO::IsCurrent()); |
51 base::AutoLock l(lock_); | 51 base::AutoLock l(lock_); |
52 resolver_generation_++; | 52 resolver_generation_++; |
53 } | 53 } |
54 | 54 |
55 void MaybeReload() { | 55 void MaybeReload() { |
56 ReloadState* reload_state = static_cast<ReloadState*>(tls_index_.Get()); | 56 ReloadState* reload_state = static_cast<ReloadState*>(tls_index_.Get()); |
57 base::AutoLock l(lock_); | 57 base::AutoLock l(lock_); |
58 | 58 |
59 if (!reload_state) { | 59 if (!reload_state) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 void DnsReloaderMaybeReload() { | 116 void DnsReloaderMaybeReload() { |
117 // This routine can be called by any of the DNS worker threads. | 117 // This routine can be called by any of the DNS worker threads. |
118 DnsReloader* dns_reloader = g_dns_reloader.Pointer(); | 118 DnsReloader* dns_reloader = g_dns_reloader.Pointer(); |
119 dns_reloader->MaybeReload(); | 119 dns_reloader->MaybeReload(); |
120 } | 120 } |
121 | 121 |
122 } // namespace net | 122 } // namespace net |
123 | 123 |
124 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && | 124 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && |
125 // !defined(OS_ANDROID) | 125 // !defined(OS_ANDROID) |
OLD | NEW |