OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_reload_timer.h" | 5 #include "net/base/dns_reload_timer.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 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/thread_local_storage.h" | 9 #include "base/threading/thread_local_storage.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 // On Linux/BSD, changes to /etc/resolv.conf can go unnoticed thus resulting | 14 // On Linux/BSD, changes to /etc/resolv.conf can go unnoticed thus resulting |
15 // in DNS queries failing either because nameservers are unknown on startup | 15 // in DNS queries failing either because nameservers are unknown on startup |
16 // or because nameserver info has changed as a result of e.g. connecting to | 16 // or because nameserver info has changed as a result of e.g. connecting to |
17 // a new network. Some distributions patch glibc to stat /etc/resolv.conf | 17 // a new network. Some distributions patch glibc to stat /etc/resolv.conf |
18 // to try to automatically detect such changes but these patches are not | 18 // to try to automatically detect such changes but these patches are not |
19 // universal and even patched systems such as Jaunty appear to need calls | 19 // universal and even patched systems such as Jaunty appear to need calls |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // multiple times. Initialize the ThreadLocalStorage slot only once. | 65 // multiple times. Initialize the ThreadLocalStorage slot only once. |
66 if (!tls_index_.initialized()) | 66 if (!tls_index_.initialized()) |
67 tls_index_.Initialize(SlotReturnFunction); | 67 tls_index_.Initialize(SlotReturnFunction); |
68 } | 68 } |
69 | 69 |
70 ~DnsReloadTimer() { | 70 ~DnsReloadTimer() { |
71 } | 71 } |
72 | 72 |
73 // We use thread local storage to identify which base::TimeTicks to | 73 // We use thread local storage to identify which base::TimeTicks to |
74 // interact with. | 74 // interact with. |
75 static ThreadLocalStorage::Slot tls_index_ ; | 75 static base::ThreadLocalStorage::Slot tls_index_ ; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(DnsReloadTimer); | 77 DISALLOW_COPY_AND_ASSIGN(DnsReloadTimer); |
78 }; | 78 }; |
79 | 79 |
80 // A TLS slot to the TimeTicks for the current thread. | 80 // A TLS slot to the TimeTicks for the current thread. |
81 // static | 81 // static |
82 ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED); | 82 base::ThreadLocalStorage::Slot DnsReloadTimer::tls_index_( |
| 83 base::LINKER_INITIALIZED); |
83 | 84 |
84 base::LazyInstance<DnsReloadTimer, | 85 base::LazyInstance<DnsReloadTimer, |
85 base::LeakyLazyInstanceTraits<DnsReloadTimer> > | 86 base::LeakyLazyInstanceTraits<DnsReloadTimer> > |
86 g_dns_reload_timer(base::LINKER_INITIALIZED); | 87 g_dns_reload_timer(base::LINKER_INITIALIZED); |
87 | 88 |
88 } // namespace | 89 } // namespace |
89 | 90 |
90 namespace net { | 91 namespace net { |
91 | 92 |
92 bool DnsReloadTimerHasExpired() { | 93 bool DnsReloadTimerHasExpired() { |
93 DnsReloadTimer* dns_timer = g_dns_reload_timer.Pointer(); | 94 DnsReloadTimer* dns_timer = g_dns_reload_timer.Pointer(); |
94 return dns_timer->Expired(); | 95 return dns_timer->Expired(); |
95 } | 96 } |
96 | 97 |
97 } // namespace net | 98 } // namespace net |
98 | 99 |
99 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | 100 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
OLD | NEW |