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
3 // found in the LICENSE file.
5 #include "media/base/message_loop_factory.h"
7 #include "base/threading/thread.h"
11 MessageLoopFactory::MessageLoopFactory() {}
13 MessageLoopFactory::~MessageLoopFactory() {
14 for (ThreadList::reverse_iterator it
= threads_
.rbegin();
15 it
!= threads_
.rend(); ++it
) {
16 base::Thread
* thread
= it
->second
;
23 scoped_refptr
<base::MessageLoopProxy
> MessageLoopFactory::GetMessageLoop(
25 return GetThread(type
)->message_loop_proxy();
28 base::Thread
* MessageLoopFactory::GetThread(Type type
) {
29 base::AutoLock
auto_lock(lock_
);
30 for (ThreadList::iterator it
= threads_
.begin(); it
!= threads_
.end(); ++it
) {
31 if (it
->first
== type
)
35 const char* name
= NULL
;
38 name
= "MediaDecoder";
41 name
= "MediaPipeline";
45 base::Thread
* thread
= new base::Thread(name
);
46 CHECK(thread
->Start()) << "Failed to start thread: " << name
;
47 threads_
.push_back(std::make_pair(type
, thread
));