| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sounds/sounds_manager.h" | 5 #include "media/audio/sounds/sounds_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 SoundsManager::SoundsManager() {} | 95 SoundsManager::SoundsManager() {} |
| 96 | 96 |
| 97 SoundsManager::~SoundsManager() { DCHECK(CalledOnValidThread()); } | 97 SoundsManager::~SoundsManager() { DCHECK(CalledOnValidThread()); } |
| 98 | 98 |
| 99 // static | 99 // static |
| 100 void SoundsManager::Create() { | 100 void SoundsManager::Create() { |
| 101 CHECK(!g_instance || g_initialized_for_testing) | 101 // SoundsManager::Create() is called twice |
| 102 << "SoundsManager::Create() is called twice"; | 102 CHECK(!g_instance || g_initialized_for_testing); |
| 103 if (g_initialized_for_testing) | 103 if (g_initialized_for_testing) |
| 104 return; | 104 return; |
| 105 g_instance = new SoundsManagerImpl(); | 105 g_instance = new SoundsManagerImpl(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // static | 108 // static |
| 109 void SoundsManager::Shutdown() { | 109 void SoundsManager::Shutdown() { |
| 110 CHECK(g_instance) << "SoundsManager::Shutdown() is called " | 110 // SoundsManager::Shutdown() is called without previous call to Create() |
| 111 << "without previous call to Create()"; | 111 CHECK(g_instance); |
| 112 delete g_instance; | 112 delete g_instance; |
| 113 g_instance = NULL; | 113 g_instance = NULL; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 SoundsManager* SoundsManager::Get() { | 117 SoundsManager* SoundsManager::Get() { |
| 118 CHECK(g_instance) << "SoundsManager::Get() is called before Create()"; | 118 // SoundsManager::Get() is called before Create() |
| 119 CHECK(g_instance); |
| 119 return g_instance; | 120 return g_instance; |
| 120 } | 121 } |
| 121 | 122 |
| 122 // static | 123 // static |
| 123 void SoundsManager::InitializeForTesting(SoundsManager* manager) { | 124 void SoundsManager::InitializeForTesting(SoundsManager* manager) { |
| 124 CHECK(!g_instance) << "SoundsManager is already initialized."; | 125 // SoundsManager is already initialized. |
| 126 CHECK(!g_instance); |
| 125 CHECK(manager); | 127 CHECK(manager); |
| 126 g_instance = manager; | 128 g_instance = manager; |
| 127 g_initialized_for_testing = true; | 129 g_initialized_for_testing = true; |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace media | 132 } // namespace media |
| OLD | NEW |