OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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. | |
4 | |
5 #include "media/base/message_loop_factory_impl.h" | |
6 | |
7 namespace media { | |
8 | |
9 MessageLoopFactoryImpl::MessageLoopFactoryImpl() {} | |
10 | |
11 MessageLoopFactoryImpl::~MessageLoopFactoryImpl() { | |
12 AutoLock auto_lock(lock_); | |
13 | |
14 for (ThreadMap::iterator iter = thread_map_.begin(); | |
15 iter != thread_map_.end(); | |
16 ++iter) { | |
17 base::Thread* thread = (*iter).second; | |
18 | |
19 if (thread) { | |
20 thread->Stop(); | |
21 delete thread; | |
22 } | |
23 } | |
24 thread_map_.clear(); | |
25 } | |
26 | |
27 // MessageLoopFactory methods. | |
28 MessageLoop* MessageLoopFactoryImpl::GetMessageLoop(const std::string& name) { | |
29 if (name.empty()) { | |
30 return NULL; | |
31 } | |
32 | |
33 MessageLoop* message_loop = NULL; | |
34 AutoLock auto_lock(lock_); | |
35 | |
36 base::Thread* thread = thread_map_[std::string(name)]; | |
scherkus (not reviewing)
2011/01/13 23:52:50
no need for std::string ctor here
also do we want
acolwell GONE FROM CHROMIUM
2011/01/14 01:14:12
Done. Changed code to use find.
On 2011/01/13 23:
| |
37 | |
38 if (!thread) { | |
39 thread = new base::Thread(name.c_str()); | |
40 | |
41 if (thread->Start()) { | |
42 thread_map_[name] = thread; | |
43 message_loop = thread->message_loop(); | |
scherkus (not reviewing)
2011/01/13 23:52:50
wondering if we can clean up these nested ifs by j
acolwell GONE FROM CHROMIUM
2011/01/14 01:14:12
Done.
| |
44 } else { | |
45 delete thread; | |
scherkus (not reviewing)
2011/01/13 23:52:50
maybe LOG(ERROR)?
acolwell GONE FROM CHROMIUM
2011/01/14 01:14:12
Done.
| |
46 } | |
47 } else { | |
48 message_loop = thread->message_loop(); | |
49 } | |
50 | |
51 return message_loop; | |
52 } | |
53 | |
54 } // namespace media | |
OLD | NEW |