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

Side by Side Diff: components/url_formatter/url_formatter.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/url_formatter/url_formatter.h" 5 #include "components/url_formatter/url_formatter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Cyrillic letters), but it can be more dangerous. 300 // Cyrillic letters), but it can be more dangerous.
301 return !lang.substr(0, 2).compare("zh") || !lang.substr(0, 2).compare("ja") || 301 return !lang.substr(0, 2).compare("zh") || !lang.substr(0, 2).compare("ja") ||
302 !lang.substr(0, 2).compare("ko"); 302 !lang.substr(0, 2).compare("ko");
303 } 303 }
304 304
305 typedef std::map<std::string, icu::UnicodeSet*> LangToExemplarSetMap; 305 typedef std::map<std::string, icu::UnicodeSet*> LangToExemplarSetMap;
306 306
307 class LangToExemplarSet { 307 class LangToExemplarSet {
308 public: 308 public:
309 static LangToExemplarSet* GetInstance() { 309 static LangToExemplarSet* GetInstance() {
310 return Singleton<LangToExemplarSet>::get(); 310 return base::Singleton<LangToExemplarSet>::get();
311 } 311 }
312 312
313 private: 313 private:
314 LangToExemplarSetMap map; 314 LangToExemplarSetMap map;
315 LangToExemplarSet() {} 315 LangToExemplarSet() {}
316 ~LangToExemplarSet() { 316 ~LangToExemplarSet() {
317 STLDeleteContainerPairSecondPointers(map.begin(), map.end()); 317 STLDeleteContainerPairSecondPointers(map.begin(), map.end());
318 } 318 }
319 319
320 friend class Singleton<LangToExemplarSet>; 320 friend class base::Singleton<LangToExemplarSet>;
321 friend struct DefaultSingletonTraits<LangToExemplarSet>; 321 friend struct base::DefaultSingletonTraits<LangToExemplarSet>;
322 friend bool GetExemplarSetForLang(const std::string&, icu::UnicodeSet**); 322 friend bool GetExemplarSetForLang(const std::string&, icu::UnicodeSet**);
323 friend void SetExemplarSetForLang(const std::string&, icu::UnicodeSet*); 323 friend void SetExemplarSetForLang(const std::string&, icu::UnicodeSet*);
324 324
325 DISALLOW_COPY_AND_ASSIGN(LangToExemplarSet); 325 DISALLOW_COPY_AND_ASSIGN(LangToExemplarSet);
326 }; 326 };
327 327
328 bool GetExemplarSetForLang(const std::string& lang, 328 bool GetExemplarSetForLang(const std::string& lang,
329 icu::UnicodeSet** lang_set) { 329 icu::UnicodeSet** lang_set) {
330 const LangToExemplarSetMap& map = LangToExemplarSet::GetInstance()->map; 330 const LangToExemplarSetMap& map = LangToExemplarSet::GetInstance()->map;
331 LangToExemplarSetMap::const_iterator pos = map.find(lang); 331 LangToExemplarSetMap::const_iterator pos = map.find(lang);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 url.possibly_invalid_spec(), url.parsed_for_possibly_invalid_spec().host, 798 url.possibly_invalid_spec(), url.parsed_for_possibly_invalid_spec().host,
799 HostComponentTransform(languages), output, NULL, NULL); 799 HostComponentTransform(languages), output, NULL, NULL);
800 } 800 }
801 801
802 base::string16 IDNToUnicode(const std::string& host, 802 base::string16 IDNToUnicode(const std::string& host,
803 const std::string& languages) { 803 const std::string& languages) {
804 return IDNToUnicodeWithAdjustments(host, languages, NULL); 804 return IDNToUnicodeWithAdjustments(host, languages, NULL);
805 } 805 }
806 806
807 } // url_formatter 807 } // url_formatter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698