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

Side by Side Diff: media/audio/audio_manager.cc

Issue 684983004: Move LazyInstance initializers out of function scope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_video
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/mojo/services/renderer_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« no previous file with comments | « no previous file | media/mojo/services/renderer_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698