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

Unified Diff: media/base/key_systems.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: media/base/key_systems.cc
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc
index ef16ad65fbdc6bab3830ea998e7f9c7f5ec402ee..1bf65fa24adb4420659a0d3b5a97c475204c60a9 100644
--- a/media/base/key_systems.cc
+++ b/media/base/key_systems.cc
@@ -9,7 +9,6 @@
#include <memory>
#include "base/containers/hash_tables.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_util.h"
@@ -230,8 +229,6 @@ class KeySystemsImpl : public KeySystems {
bool IsValidMimeTypeCodecsCombination(const std::string& mime_type,
SupportedCodecs codecs_mask) const;
- friend struct base::DefaultLazyInstanceTraits<KeySystemsImpl>;
-
typedef base::hash_map<std::string, std::unique_ptr<KeySystemProperties>>
KeySystemPropertiesMap;
typedef base::hash_map<std::string, SupportedCodecs> MimeTypeCodecsMap;
@@ -263,20 +260,17 @@ class KeySystemsImpl : public KeySystems {
DISALLOW_COPY_AND_ASSIGN(KeySystemsImpl);
};
-static base::LazyInstance<KeySystemsImpl>::Leaky g_key_systems =
- LAZY_INSTANCE_INITIALIZER;
-
KeySystemsImpl* KeySystemsImpl::GetInstance() {
- KeySystemsImpl* key_systems = g_key_systems.Pointer();
+ static KeySystemsImpl* key_systems = new KeySystemsImpl();
key_systems->UpdateIfNeeded();
scottmg 2017/01/31 21:10:34 Are multiple calls to UpdateIfNeeded() a problem?
DaleCurtis 2017/01/31 22:04:33 No, or it'd have been a problem before too. The If
return key_systems;
}
-// Because we use a LazyInstance, the key systems info must be populated when
-// the instance is lazily initiated.
-KeySystemsImpl::KeySystemsImpl() :
- audio_codec_mask_(EME_CODEC_AUDIO_ALL),
- video_codec_mask_(EME_CODEC_VIDEO_ALL) {
+// Because we use a thread-safe static, the key systems info must be populated
+// when the instance is constructed.
+KeySystemsImpl::KeySystemsImpl()
+ : audio_codec_mask_(EME_CODEC_AUDIO_ALL),
+ video_codec_mask_(EME_CODEC_VIDEO_ALL) {
for (size_t i = 0; i < arraysize(kCodecStrings); ++i) {
const std::string& name = kCodecStrings[i].name;
DCHECK(!codec_string_map_.count(name));

Powered by Google App Engine
This is Rietveld 408576698