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.
[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

Review URL: http://codereview.chromium.org/8491043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110076 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/base/bandwidth_metrics.cc b/net/base/bandwidth_metrics.cc
index fa23a77d..0644122d 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 7b1c3e20..1038e764 100644
--- a/net/base/cert_database_nss_unittest.cc
+++ b/net/base/cert_database_nss_unittest.cc
@@ -133,8 +133,8 @@
 };
 
 // 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 d45c1456..276d1a0 100644
--- a/net/base/dns_reloader.cc
+++ b/net/base/dns_reloader.cc
@@ -101,7 +101,7 @@
 
 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 @@
 
 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 @@
   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 53206dc06..204e768 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -493,7 +493,7 @@
 
 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 @@
 
 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_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..6eaf0e7b 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 @@
 
 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 @@
 
 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 @@
   }
 };
 
-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 @@
 
 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 @@
 
 static base::LazyInstance<GlobalCertStore,
                           base::LeakyLazyInstanceTraits<GlobalCertStore> >
-    g_cert_store(base::LINKER_INITIALIZED);
+    g_cert_store = LAZY_INSTANCE_INITIALIZER;
 
 // static
 HCERTSTORE X509Certificate::cert_store() {