Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: net/base/dns_reloader.cc

Issue 9297010: Make it possible to use ThreadLocalStorage::Slot as a static without (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/tracked_objects.cc ('k') | ppapi/proxy/ppb_message_loop_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 ~DnsReloader() { 87 ~DnsReloader() {
88 NOTREACHED(); // LeakyLazyInstance is not destructed. 88 NOTREACHED(); // LeakyLazyInstance is not destructed.
89 } 89 }
90 90
91 base::Lock lock_; // Protects resolver_generation_. 91 base::Lock lock_; // Protects resolver_generation_.
92 int resolver_generation_; 92 int resolver_generation_;
93 friend struct base::DefaultLazyInstanceTraits<DnsReloader>; 93 friend struct base::DefaultLazyInstanceTraits<DnsReloader>;
94 94
95 // We use thread local storage to identify which ReloadState to interact with. 95 // We use thread local storage to identify which ReloadState to interact with.
96 static base::ThreadLocalStorage::Slot tls_index_ ; 96 static base::ThreadLocalStorage::StaticSlot tls_index_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(DnsReloader); 98 DISALLOW_COPY_AND_ASSIGN(DnsReloader);
99 }; 99 };
100 100
101 // A TLS slot to the ReloadState for the current thread. 101 // A TLS slot to the ReloadState for the current thread.
102 // static 102 // static
103 base::ThreadLocalStorage::Slot DnsReloader::tls_index_( 103 base::ThreadLocalStorage::StaticSlot DnsReloader::tls_index_ = TLS_INITIALIZER;
104 base::LINKER_INITIALIZED);
105 104
106 base::LazyInstance<DnsReloader>::Leaky 105 base::LazyInstance<DnsReloader>::Leaky
107 g_dns_reloader = LAZY_INSTANCE_INITIALIZER; 106 g_dns_reloader = LAZY_INSTANCE_INITIALIZER;
108 107
109 } // namespace 108 } // namespace
110 109
111 namespace net { 110 namespace net {
112 111
113 void EnsureDnsReloaderInit() { 112 void EnsureDnsReloaderInit() {
114 DnsReloader* t ALLOW_UNUSED = g_dns_reloader.Pointer(); 113 DnsReloader* t ALLOW_UNUSED = g_dns_reloader.Pointer();
115 } 114 }
116 115
117 void DnsReloaderMaybeReload() { 116 void DnsReloaderMaybeReload() {
118 // 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.
119 DnsReloader* dns_reloader = g_dns_reloader.Pointer(); 118 DnsReloader* dns_reloader = g_dns_reloader.Pointer();
120 dns_reloader->MaybeReload(); 119 dns_reloader->MaybeReload();
121 } 120 }
122 121
123 } // namespace net 122 } // namespace net
124 123
125 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && 124 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) &&
126 // !defined(OS_ANDROID) 125 // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « base/tracked_objects.cc ('k') | ppapi/proxy/ppb_message_loop_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698