diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 07:48:49 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 07:48:49 +0000 |
commit | 625332e06437018bf696dce93a4b2bd2c5e0b118 (patch) | |
tree | 56e128ddf94a81b6de1f29a9eabe59f0d79346c9 /net/base/mime_util.cc | |
parent | dc7cdcb970254f223262a66c812f240a8269ae87 (diff) | |
download | chromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.zip chromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.tar.gz chromium_src-625332e06437018bf696dce93a4b2bd2c5e0b118.tar.bz2 |
Make members of Singleton<T> private and only visible to the singleton type. This enforces that the Singleton<T> pattern can only be used within classes which want singleton-ness.
As part of this CL I have also fixed up files which got missed in my previous CLs to use a GetInstance() method and use Singleton<T> from the source file.
There are a small number of places where I have also switched to LazyInstance as that was more appropriate for types used in a single source file.
BUG=65298
TEST=all existing tests should continue to pass.
Review URL: http://codereview.chromium.org/5682008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/mime_util.cc')
-rw-r--r-- | net/base/mime_util.cc | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index ddcfc4b..d95c029 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -9,8 +9,8 @@ #include "net/base/platform_mime_util.h" #include "base/hash_tables.h" +#include "base/lazy_instance.h" #include "base/logging.h" -#include "base/singleton.h" #include "base/string_split.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -51,7 +51,7 @@ class MimeUtil : public PlatformMimeUtil { const std::vector<std::string>& codecs) const; private: - friend struct DefaultSingletonTraits<MimeUtil>; + friend struct base::DefaultLazyInstanceTraits<MimeUtil>; MimeUtil() { InitializeMimeTypeMaps(); } @@ -71,6 +71,8 @@ class MimeUtil : public PlatformMimeUtil { StrictMappings strict_format_map_; }; // class MimeUtil +static base::LazyInstance<MimeUtil> g_mime_util(base::LINKER_INITIALIZED); + struct MimeInfo { const char* mime_type; const char* extensions; // comma separated list @@ -473,70 +475,67 @@ bool MimeUtil::IsSupportedStrictMediaMimeType(const std::string& mime_type, // Wrappers for the singleton //---------------------------------------------------------------------------- -static MimeUtil* GetMimeUtil() { - return Singleton<MimeUtil>::get(); -} - bool GetMimeTypeFromExtension(const FilePath::StringType& ext, std::string* mime_type) { - return GetMimeUtil()->GetMimeTypeFromExtension(ext, mime_type); + return g_mime_util.Get().GetMimeTypeFromExtension(ext, mime_type); } bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type) { - return GetMimeUtil()->GetMimeTypeFromFile(file_path, mime_type); + return g_mime_util.Get().GetMimeTypeFromFile(file_path, mime_type); } bool GetPreferredExtensionForMimeType(const std::string& mime_type, FilePath::StringType* extension) { - return GetMimeUtil()->GetPreferredExtensionForMimeType(mime_type, extension); + return g_mime_util.Get().GetPreferredExtensionForMimeType(mime_type, + extension); } bool IsSupportedImageMimeType(const char* mime_type) { - return GetMimeUtil()->IsSupportedImageMimeType(mime_type); + return g_mime_util.Get().IsSupportedImageMimeType(mime_type); } bool IsSupportedMediaMimeType(const char* mime_type) { - return GetMimeUtil()->IsSupportedMediaMimeType(mime_type); + return g_mime_util.Get().IsSupportedMediaMimeType(mime_type); } bool IsSupportedNonImageMimeType(const char* mime_type) { - return GetMimeUtil()->IsSupportedNonImageMimeType(mime_type); + return g_mime_util.Get().IsSupportedNonImageMimeType(mime_type); } bool IsSupportedJavascriptMimeType(const char* mime_type) { - return GetMimeUtil()->IsSupportedJavascriptMimeType(mime_type); + return g_mime_util.Get().IsSupportedJavascriptMimeType(mime_type); } bool IsViewSourceMimeType(const char* mime_type) { - return GetMimeUtil()->IsViewSourceMimeType(mime_type); + return g_mime_util.Get().IsViewSourceMimeType(mime_type); } bool IsSupportedMimeType(const std::string& mime_type) { - return GetMimeUtil()->IsSupportedMimeType(mime_type); + return g_mime_util.Get().IsSupportedMimeType(mime_type); } bool MatchesMimeType(const std::string &mime_type_pattern, const std::string &mime_type) { - return GetMimeUtil()->MatchesMimeType(mime_type_pattern, mime_type); + return g_mime_util.Get().MatchesMimeType(mime_type_pattern, mime_type); } bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs) { - return GetMimeUtil()->AreSupportedMediaCodecs(codecs); + return g_mime_util.Get().AreSupportedMediaCodecs(codecs); } bool IsStrictMediaMimeType(const std::string& mime_type) { - return GetMimeUtil()->IsStrictMediaMimeType(mime_type); + return g_mime_util.Get().IsStrictMediaMimeType(mime_type); } bool IsSupportedStrictMediaMimeType(const std::string& mime_type, const std::vector<std::string>& codecs) { - return GetMimeUtil()->IsSupportedStrictMediaMimeType(mime_type, codecs); + return g_mime_util.Get().IsSupportedStrictMediaMimeType(mime_type, codecs); } void ParseCodecString(const std::string& codecs, std::vector<std::string>* codecs_out, const bool strip) { - GetMimeUtil()->ParseCodecString(codecs, codecs_out, strip); + g_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); } namespace { |