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

Side by Side Diff: media/audio/sounds/sounds_manager.cc

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/single_thread_task_runner.h"
13 #include "media/audio/audio_manager.h" 13 #include "media/audio/audio_manager.h"
14 #include "media/audio/sounds/audio_stream_handler.h" 14 #include "media/audio/sounds/audio_stream_handler.h"
15 #include "media/base/media_switches.h" 15 #include "media/base/media_switches.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 namespace { 19 namespace {
20 20
21 SoundsManager* g_instance = NULL; 21 SoundsManager* g_instance = NULL;
22 22
23 // SoundsManagerImpl --------------------------------------------------- 23 // SoundsManagerImpl ---------------------------------------------------
24 24
25 class SoundsManagerImpl : public SoundsManager { 25 class SoundsManagerImpl : public SoundsManager {
26 public: 26 public:
27 SoundsManagerImpl(); 27 SoundsManagerImpl();
28 virtual ~SoundsManagerImpl(); 28 virtual ~SoundsManagerImpl();
29 29
30 // SoundsManager implementation: 30 // SoundsManager implementation:
31 virtual bool Initialize( 31 virtual bool Initialize(
32 const std::vector<base::StringPiece>& resources) OVERRIDE; 32 const std::vector<base::StringPiece>& resources) OVERRIDE;
33 virtual bool Play(Sound sound) OVERRIDE; 33 virtual bool Play(Sound sound) OVERRIDE;
34 virtual base::TimeDelta GetDuration(Sound sound) OVERRIDE; 34 virtual base::TimeDelta GetDuration(Sound sound) OVERRIDE;
35 35
36 private: 36 private:
37 std::vector<linked_ptr<AudioStreamHandler> > handlers_; 37 std::vector<linked_ptr<AudioStreamHandler> > handlers_;
38 scoped_refptr<base::MessageLoopProxy> message_loop_; 38 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(SoundsManagerImpl); 40 DISALLOW_COPY_AND_ASSIGN(SoundsManagerImpl);
41 }; 41 };
42 42
43 SoundsManagerImpl::SoundsManagerImpl() 43 SoundsManagerImpl::SoundsManagerImpl()
44 : handlers_(SOUND_COUNT), 44 : handlers_(SOUND_COUNT),
45 message_loop_(AudioManager::Get()->GetMessageLoop()) { 45 task_runner_(AudioManager::Get()->GetTaskRunner()) {
46 } 46 }
47 47
48 SoundsManagerImpl::~SoundsManagerImpl() { 48 SoundsManagerImpl::~SoundsManagerImpl() {
49 DCHECK(CalledOnValidThread()); 49 DCHECK(CalledOnValidThread());
50 } 50 }
51 51
52 bool SoundsManagerImpl::Initialize( 52 bool SoundsManagerImpl::Initialize(
53 const std::vector<base::StringPiece>& resources) { 53 const std::vector<base::StringPiece>& resources) {
54 if (resources.size() != static_cast<size_t>(SOUND_COUNT)) { 54 if (resources.size() != static_cast<size_t>(SOUND_COUNT)) {
55 LOG(ERROR) << "Incorrect num of sounds."; 55 LOG(ERROR) << "Incorrect num of sounds.";
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 g_instance = NULL; 155 g_instance = NULL;
156 } 156 }
157 157
158 // static 158 // static
159 SoundsManager* SoundsManager::Get() { 159 SoundsManager* SoundsManager::Get() {
160 CHECK(g_instance) << "SoundsManager::Get() is called before Create()"; 160 CHECK(g_instance) << "SoundsManager::Get() is called before Create()";
161 return g_instance; 161 return g_instance;
162 } 162 }
163 163
164 } // namespace media 164 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698