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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 | « net/base/mime_util.cc ('k') | net/base/ssl_config_service.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 10
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 } 486 }
487 487
488 void SetExemplarSetForLang(const std::string& lang, 488 void SetExemplarSetForLang(const std::string& lang,
489 icu::UnicodeSet* lang_set) { 489 icu::UnicodeSet* lang_set) {
490 LangToExemplarSetMap& map = LangToExemplarSet::GetInstance()->map; 490 LangToExemplarSetMap& map = LangToExemplarSet::GetInstance()->map;
491 map.insert(std::make_pair(lang, lang_set)); 491 map.insert(std::make_pair(lang, lang_set));
492 } 492 }
493 493
494 static base::LazyInstance<base::Lock, 494 static base::LazyInstance<base::Lock,
495 base::LeakyLazyInstanceTraits<base::Lock> > 495 base::LeakyLazyInstanceTraits<base::Lock> >
496 g_lang_set_lock(base::LINKER_INITIALIZED); 496 g_lang_set_lock = LAZY_INSTANCE_INITIALIZER;
497 497
498 // Returns true if all the characters in component_characters are used by 498 // Returns true if all the characters in component_characters are used by
499 // the language |lang|. 499 // the language |lang|.
500 bool IsComponentCoveredByLang(const icu::UnicodeSet& component_characters, 500 bool IsComponentCoveredByLang(const icu::UnicodeSet& component_characters,
501 const std::string& lang) { 501 const std::string& lang) {
502 CR_DEFINE_STATIC_LOCAL( 502 CR_DEFINE_STATIC_LOCAL(
503 const icu::UnicodeSet, kASCIILetters, ('a', 'z')); 503 const icu::UnicodeSet, kASCIILetters, ('a', 'z'));
504 icu::UnicodeSet* lang_set; 504 icu::UnicodeSet* lang_set;
505 // We're called from both the UI thread and the history thread. 505 // We're called from both the UI thread and the history thread.
506 { 506 {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1112
1113 const FormatUrlType kFormatUrlOmitNothing = 0; 1113 const FormatUrlType kFormatUrlOmitNothing = 0;
1114 const FormatUrlType kFormatUrlOmitUsernamePassword = 1 << 0; 1114 const FormatUrlType kFormatUrlOmitUsernamePassword = 1 << 0;
1115 const FormatUrlType kFormatUrlOmitHTTP = 1 << 1; 1115 const FormatUrlType kFormatUrlOmitHTTP = 1 << 1;
1116 const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname = 1 << 2; 1116 const FormatUrlType kFormatUrlOmitTrailingSlashOnBareHostname = 1 << 2;
1117 const FormatUrlType kFormatUrlOmitAll = kFormatUrlOmitUsernamePassword | 1117 const FormatUrlType kFormatUrlOmitAll = kFormatUrlOmitUsernamePassword |
1118 kFormatUrlOmitHTTP | kFormatUrlOmitTrailingSlashOnBareHostname; 1118 kFormatUrlOmitHTTP | kFormatUrlOmitTrailingSlashOnBareHostname;
1119 1119
1120 static base::LazyInstance<std::multiset<int>, 1120 static base::LazyInstance<std::multiset<int>,
1121 base::LeakyLazyInstanceTraits<std::multiset<int> > > 1121 base::LeakyLazyInstanceTraits<std::multiset<int> > >
1122 g_explicitly_allowed_ports(base::LINKER_INITIALIZED); 1122 g_explicitly_allowed_ports = LAZY_INSTANCE_INITIALIZER;
1123 1123
1124 size_t GetCountOfExplicitlyAllowedPorts() { 1124 size_t GetCountOfExplicitlyAllowedPorts() {
1125 return g_explicitly_allowed_ports.Get().size(); 1125 return g_explicitly_allowed_ports.Get().size();
1126 } 1126 }
1127 1127
1128 GURL FilePathToFileURL(const FilePath& path) { 1128 GURL FilePathToFileURL(const FilePath& path) {
1129 // Produce a URL like "file:///C:/foo" for a regular file, or 1129 // Produce a URL like "file:///C:/foo" for a regular file, or
1130 // "file://///server/path" for UNC. The URL canonicalizer will fix up the 1130 // "file://///server/path" for UNC. The URL canonicalizer will fix up the
1131 // latter case to be the canonical UNC form: "file://server/path" 1131 // latter case to be the canonical UNC form: "file://server/path"
1132 FilePath::StringType url_string(kFileURLPrefix); 1132 FilePath::StringType url_string(kFileURLPrefix);
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 2461
2462 NetworkInterface::NetworkInterface(const std::string& name, 2462 NetworkInterface::NetworkInterface(const std::string& name,
2463 const IPAddressNumber& address) 2463 const IPAddressNumber& address)
2464 : name(name), address(address) { 2464 : name(name), address(address) {
2465 } 2465 }
2466 2466
2467 NetworkInterface::~NetworkInterface() { 2467 NetworkInterface::~NetworkInterface() {
2468 } 2468 }
2469 2469
2470 } // namespace net 2470 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mime_util.cc ('k') | net/base/ssl_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698