OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/audio_manager.h" | 5 #include "media/audio/audio_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "media/audio/fake_audio_log_factory.h" | 12 #include "media/audio/fake_audio_log_factory.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 namespace { | 15 namespace { |
16 AudioManager* g_last_created = NULL; | 16 AudioManager* g_last_created = NULL; |
| 17 static base::LazyInstance<FakeAudioLogFactory>::Leaky g_fake_log_factory = |
| 18 LAZY_INSTANCE_INITIALIZER; |
17 } | 19 } |
18 | 20 |
19 // Forward declaration of the platform specific AudioManager factory function. | 21 // Forward declaration of the platform specific AudioManager factory function. |
20 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory); | 22 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory); |
21 | 23 |
22 AudioManager::AudioManager() {} | 24 AudioManager::AudioManager() {} |
23 | 25 |
24 AudioManager::~AudioManager() { | 26 AudioManager::~AudioManager() { |
25 CHECK(!g_last_created || g_last_created == this); | 27 CHECK(!g_last_created || g_last_created == this); |
26 g_last_created = NULL; | 28 g_last_created = NULL; |
27 } | 29 } |
28 | 30 |
29 // static | 31 // static |
30 AudioManager* AudioManager::Create(AudioLogFactory* audio_log_factory) { | 32 AudioManager* AudioManager::Create(AudioLogFactory* audio_log_factory) { |
31 CHECK(!g_last_created); | 33 CHECK(!g_last_created); |
32 g_last_created = CreateAudioManager(audio_log_factory); | 34 g_last_created = CreateAudioManager(audio_log_factory); |
33 return g_last_created; | 35 return g_last_created; |
34 } | 36 } |
35 | 37 |
36 // static | 38 // static |
37 AudioManager* AudioManager::CreateForTesting() { | 39 AudioManager* AudioManager::CreateForTesting() { |
38 static base::LazyInstance<FakeAudioLogFactory>::Leaky fake_log_factory = | 40 return Create(g_fake_log_factory.Pointer()); |
39 LAZY_INSTANCE_INITIALIZER; | |
40 return Create(fake_log_factory.Pointer()); | |
41 } | 41 } |
42 | 42 |
43 // static | 43 // static |
44 AudioManager* AudioManager::Get() { | 44 AudioManager* AudioManager::Get() { |
45 return g_last_created; | 45 return g_last_created; |
46 } | 46 } |
47 | 47 |
48 } // namespace media | 48 } // namespace media |
OLD | NEW |