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

Unified Diff: media/audio/audio_system.cc

Issue 2687853002: Switching VirtualKeyboardPrivate keyboard config call stack to receive HasInputDevices() responce a… (Closed)
Patch Set: Fix for compilation error on linux_chromium_chromeos 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
Index: media/audio/audio_system.cc
diff --git a/media/audio/audio_system.cc b/media/audio/audio_system.cc
new file mode 100644
index 0000000000000000000000000000000000000000..953be40caa007d0ede558a8faef95d2e2babc6ab
--- /dev/null
+++ b/media/audio/audio_system.cc
@@ -0,0 +1,38 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/audio/audio_system.h"
+
+namespace media {
+
+static AudioSystem* g_last_created = nullptr;
+
+AudioSystem::~AudioSystem() {}
+
+AudioSystem* AudioSystem::Get() {
+ return g_last_created;
+}
+
+void AudioSystem::SetInstance(AudioSystem* audio_system) {
+ DCHECK(audio_system);
+ if (g_last_created && audio_system) {
+ // We create multiple instances of AudioSystem only when testing.
+ // We should not encounter this case in production.
+ LOG(WARNING) << "Multiple instances of AudioSystem detected";
+ }
+ g_last_created = audio_system;
+}
+
+void AudioSystem::ClearInstance(const AudioSystem* audio_system) {
+ DCHECK(audio_system);
+ if (g_last_created != audio_system) {
+ // We create multiple instances of AudioSystem only when testing.
+ // We should not encounter this case in production.
+ LOG(WARNING) << "Multiple instances of AudioSystem detected";
+ } else {
+ g_last_created = nullptr;
+ }
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698