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

Unified Diff: media/base/key_systems.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix presubmit comments. Created 3 years, 10 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
« no previous file with comments | « media/base/android/media_service_throttler.cc ('k') | media/base/media.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/key_systems.cc
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc
index 6e3d4072ea246073d7bc2fea20cc12e1c81efd2c..4dee18a97ee5413bf527431b7c93ba5c6bf90e31 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();
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));
« no previous file with comments | « media/base/android/media_service_throttler.cc ('k') | media/base/media.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698