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

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: fix win and audio tests Created 6 years, 11 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 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(SoundKey key, 31 virtual bool Initialize(SoundKey key,
32 const base::StringPiece& data) OVERRIDE; 32 const base::StringPiece& data) OVERRIDE;
33 virtual bool Play(SoundKey key) OVERRIDE; 33 virtual bool Play(SoundKey key) OVERRIDE;
34 virtual base::TimeDelta GetDuration(SoundKey key) OVERRIDE; 34 virtual base::TimeDelta GetDuration(SoundKey key) OVERRIDE;
35 35
36 private: 36 private:
37 base::hash_map<SoundKey, linked_ptr<AudioStreamHandler> > handlers_; 37 base::hash_map<SoundKey, 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 : message_loop_(AudioManager::Get()->GetMessageLoop()) {} 44 : task_runner_(AudioManager::Get()->GetTaskRunner()) {
45 }
45 46
46 SoundsManagerImpl::~SoundsManagerImpl() { DCHECK(CalledOnValidThread()); } 47 SoundsManagerImpl::~SoundsManagerImpl() { DCHECK(CalledOnValidThread()); }
47 48
48 bool SoundsManagerImpl::Initialize(SoundKey key, 49 bool SoundsManagerImpl::Initialize(SoundKey key,
49 const base::StringPiece& data) { 50 const base::StringPiece& data) {
50 if (handlers_.find(key) != handlers_.end() && handlers_[key]->IsInitialized()) 51 if (handlers_.find(key) != handlers_.end() && handlers_[key]->IsInitialized())
51 return true; 52 return true;
52 linked_ptr<AudioStreamHandler> handler(new AudioStreamHandler(data)); 53 linked_ptr<AudioStreamHandler> handler(new AudioStreamHandler(data));
53 if (!handler->IsInitialized()) { 54 if (!handler->IsInitialized()) {
54 LOG(WARNING) << "Can't initialize AudioStreamHandler for key=" << key; 55 LOG(WARNING) << "Can't initialize AudioStreamHandler for key=" << key;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 g_instance = NULL; 142 g_instance = NULL;
142 } 143 }
143 144
144 // static 145 // static
145 SoundsManager* SoundsManager::Get() { 146 SoundsManager* SoundsManager::Get() {
146 CHECK(g_instance) << "SoundsManager::Get() is called before Create()"; 147 CHECK(g_instance) << "SoundsManager::Get() is called before Create()";
147 return g_instance; 148 return g_instance;
148 } 149 }
149 150
150 } // namespace media 151 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/sounds/audio_stream_handler.cc ('k') | media/audio/test_audio_input_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698