diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 13:31:49 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 13:31:49 +0000 |
commit | 6de0fd1d935e8c6c9257f1082dbd227acb1a06b1 (patch) | |
tree | 0ed5bc4ef9c2da0b498c30e562218f4528eaac9e /net/base | |
parent | 0f86c358fdb5e47aa9cd4a99b12da5e66507d080 (diff) | |
download | chromium_src-6de0fd1d935e8c6c9257f1082dbd227acb1a06b1.zip chromium_src-6de0fd1d935e8c6c9257f1082dbd227acb1a06b1.tar.gz chromium_src-6de0fd1d935e8c6c9257f1082dbd227acb1a06b1.tar.bz2 |
Allow linker initialization of lazy instance
Using the initializer list construct = {0} allows the object to be linker initialized.
Modify the LazyInstance class design to make it a pod aggregate type that can be linker initialized this way. Also combines the instance and state members, in line with the Singleton<> class design.
Introduces a new LAZY_INSTANCE_INITIALIZER macro specifically for using to init all lazy instances + modify all existing callsites to use it. (Old code would no longer compile)
BUG=94925
TEST=existing tests pass. http://build.chromium.org/f/chromium/perf/linux-release/sizes/report.html?history=150&header=chrome-si&graph=chrome-si&rev=-1 should step downward.
TBR=jam@chromium.org,rvargas@chromium.org,darin@chromium.org,ben@chromium.org,apatrick@chromium.org,akalin@chromium.org
Review URL: http://codereview.chromium.org/8491043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/bandwidth_metrics.cc | 6 | ||||
-rw-r--r-- | net/base/cert_database_nss_unittest.cc | 4 | ||||
-rw-r--r-- | net/base/dns_reloader.cc | 2 | ||||
-rw-r--r-- | net/base/ev_root_ca_metadata.cc | 2 | ||||
-rw-r--r-- | net/base/mime_util.cc | 2 | ||||
-rw-r--r-- | net/base/net_util.cc | 4 | ||||
-rw-r--r-- | net/base/ssl_config_service.cc | 2 | ||||
-rw-r--r-- | net/base/test_root_certs.cc | 4 | ||||
-rw-r--r-- | net/base/test_root_certs_win.cc | 4 | ||||
-rw-r--r-- | net/base/winsock_init.cc | 6 | ||||
-rw-r--r-- | net/base/x509_certificate.cc | 2 | ||||
-rw-r--r-- | net/base/x509_certificate_win.cc | 2 |
12 files changed, 20 insertions, 20 deletions
diff --git a/net/base/bandwidth_metrics.cc b/net/base/bandwidth_metrics.cc index fa23a77..0644122 100644 --- a/net/base/bandwidth_metrics.cc +++ b/net/base/bandwidth_metrics.cc @@ -1,12 +1,12 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/lazy_instance.h" #include "net/base/bandwidth_metrics.h" -static base::LazyInstance<net::BandwidthMetrics> g_bandwidth_metrics( - base::LINKER_INITIALIZED); +static base::LazyInstance<net::BandwidthMetrics> g_bandwidth_metrics = + LAZY_INSTANCE_INITIALIZER; namespace net { diff --git a/net/base/cert_database_nss_unittest.cc b/net/base/cert_database_nss_unittest.cc index 7b1c3e2..1038e76 100644 --- a/net/base/cert_database_nss_unittest.cc +++ b/net/base/cert_database_nss_unittest.cc @@ -133,8 +133,8 @@ class CertDatabaseNSSTest : public testing::Test { }; // static -base::LazyInstance<ScopedTempDir> CertDatabaseNSSTest::temp_db_dir_( - base::LINKER_INITIALIZED); +base::LazyInstance<ScopedTempDir> CertDatabaseNSSTest::temp_db_dir_ = + LAZY_INSTANCE_INITIALIZER; TEST_F(CertDatabaseNSSTest, ListCerts) { // This test isn't terribly useful, though it will at least let valgrind test diff --git a/net/base/dns_reloader.cc b/net/base/dns_reloader.cc index d45c145..276d1a0 100644 --- a/net/base/dns_reloader.cc +++ b/net/base/dns_reloader.cc @@ -101,7 +101,7 @@ base::ThreadLocalStorage::Slot DnsReloader::tls_index_( base::LazyInstance<DnsReloader, base::LeakyLazyInstanceTraits<DnsReloader> > - g_dns_reloader(base::LINKER_INITIALIZED); + g_dns_reloader = LAZY_INSTANCE_INITIALIZER; } // namespace diff --git a/net/base/ev_root_ca_metadata.cc b/net/base/ev_root_ca_metadata.cc index 6314b77..660a088 100644 --- a/net/base/ev_root_ca_metadata.cc +++ b/net/base/ev_root_ca_metadata.cc @@ -316,7 +316,7 @@ const EVRootCAMetadata::PolicyOID EVRootCAMetadata::policy_oids_[] = { static base::LazyInstance<EVRootCAMetadata, base::LeakyLazyInstanceTraits<EVRootCAMetadata> > - g_ev_root_ca_metadata(base::LINKER_INITIALIZED); + g_ev_root_ca_metadata = LAZY_INSTANCE_INITIALIZER; // static EVRootCAMetadata* EVRootCAMetadata::GetInstance() { diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index 60dd125..3ba095d 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -78,7 +78,7 @@ class MimeUtil : public PlatformMimeUtil { StrictMappings strict_format_map_; }; // class MimeUtil -static base::LazyInstance<MimeUtil> g_mime_util(base::LINKER_INITIALIZED); +static base::LazyInstance<MimeUtil> g_mime_util = LAZY_INSTANCE_INITIALIZER; struct MimeInfo { const char* mime_type; diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 53206dc..204e768 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -493,7 +493,7 @@ void SetExemplarSetForLang(const std::string& lang, static base::LazyInstance<base::Lock, base::LeakyLazyInstanceTraits<base::Lock> > - g_lang_set_lock(base::LINKER_INITIALIZED); + g_lang_set_lock = LAZY_INSTANCE_INITIALIZER; // Returns true if all the characters in component_characters are used by // the language |lang|. @@ -1119,7 +1119,7 @@ const FormatUrlType kFormatUrlOmitAll = kFormatUrlOmitUsernamePassword | static base::LazyInstance<std::multiset<int>, base::LeakyLazyInstanceTraits<std::multiset<int> > > - g_explicitly_allowed_ports(base::LINKER_INITIALIZED); + g_explicitly_allowed_ports = LAZY_INSTANCE_INITIALIZER; size_t GetCountOfExplicitlyAllowedPorts() { return g_explicitly_allowed_ports.Get().size(); diff --git a/net/base/ssl_config_service.cc b/net/base/ssl_config_service.cc index 40f75c8..7f9de16 100644 --- a/net/base/ssl_config_service.cc +++ b/net/base/ssl_config_service.cc @@ -64,7 +64,7 @@ static bool g_false_start_enabled = true; static bool g_dns_cert_provenance_checking = false; base::LazyInstance<scoped_refptr<CRLSet>, base::LeakyLazyInstanceTraits<scoped_refptr<CRLSet> > > - g_crl_set(base::LINKER_INITIALIZED); + g_crl_set = LAZY_INSTANCE_INITIALIZER; // static void SSLConfigService::DisableFalseStart() { diff --git a/net/base/test_root_certs.cc b/net/base/test_root_certs.cc index 6d4bc18..6eaf0e7 100644 --- a/net/base/test_root_certs.cc +++ b/net/base/test_root_certs.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,7 @@ bool g_has_instance = false; base::LazyInstance<TestRootCerts, base::LeakyLazyInstanceTraits<TestRootCerts> > - g_test_root_certs(base::LINKER_INITIALIZED); + g_test_root_certs = LAZY_INSTANCE_INITIALIZER; CertificateList LoadCertificates(const FilePath& filename) { std::string raw_cert; diff --git a/net/base/test_root_certs_win.cc b/net/base/test_root_certs_win.cc index 961c7d3..65be843 100644 --- a/net/base/test_root_certs_win.cc +++ b/net/base/test_root_certs_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,7 +91,7 @@ struct CryptoAPIInjector { base::LazyInstance<CryptoAPIInjector, base::LeakyLazyInstanceTraits<CryptoAPIInjector> > - g_capi_injector(base::LINKER_INITIALIZED); + g_capi_injector = LAZY_INSTANCE_INITIALIZER; BOOL WINAPI InterceptedOpenStoreW(LPCSTR store_provider, DWORD encoding, diff --git a/net/base/winsock_init.cc b/net/base/winsock_init.cc index 41810ef..e760185 100644 --- a/net/base/winsock_init.cc +++ b/net/base/winsock_init.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -37,8 +37,8 @@ class WinsockInitSingleton { } }; -static base::LazyInstance<WinsockInitSingleton> g_winsock_init_singleton( - base::LINKER_INITIALIZED); +static base::LazyInstance<WinsockInitSingleton> g_winsock_init_singleton = + LAZY_INSTANCE_INITIALIZER; } // namespace diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc index 10e7f0a..efb19ee 100644 --- a/net/base/x509_certificate.cc +++ b/net/base/x509_certificate.cc @@ -112,7 +112,7 @@ class X509CertificateCache { base::LazyInstance<X509CertificateCache, base::LeakyLazyInstanceTraits<X509CertificateCache> > - g_x509_certificate_cache(base::LINKER_INITIALIZED); + g_x509_certificate_cache = LAZY_INSTANCE_INITIALIZER; void X509CertificateCache::InsertOrUpdate( X509Certificate::OSCertHandle* cert_handle) { diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc index 1c89abb..7309021 100644 --- a/net/base/x509_certificate_win.cc +++ b/net/base/x509_certificate_win.cc @@ -720,7 +720,7 @@ class GlobalCertStore { static base::LazyInstance<GlobalCertStore, base::LeakyLazyInstanceTraits<GlobalCertStore> > - g_cert_store(base::LINKER_INITIALIZED); + g_cert_store = LAZY_INSTANCE_INITIALIZER; // static HCERTSTORE X509Certificate::cert_store() { |