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

Side by Side Diff: media/base/message_loop_factory.cc

Issue 9597016: Fold media::MessageLoopFactoryImpl into media::MessageLoopFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 9 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
« no previous file with comments | « media/base/message_loop_factory.h ('k') | media/base/message_loop_factory_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/base/message_loop_factory.h" 5 #include "media/base/message_loop_factory.h"
6 6
7 #include "base/threading/thread.h"
8
7 namespace media { 9 namespace media {
8 10
9 MessageLoopFactory::~MessageLoopFactory() {} 11 MessageLoopFactory::MessageLoopFactory() {}
12
13 MessageLoopFactory::~MessageLoopFactory() {
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 MessageLoop* MessageLoopFactory::GetMessageLoop(const std::string& name) {
28 return GetThread(name)->message_loop();
29 }
30
31 scoped_refptr<base::MessageLoopProxy>
32 MessageLoopFactory::GetMessageLoopProxy(const std::string& name) {
33 return GetThread(name)->message_loop_proxy();
34 }
35
36 base::Thread* MessageLoopFactory::GetThread(const std::string& name) {
37 DCHECK(!name.empty());
38
39 base::AutoLock auto_lock(lock_);
40 ThreadMap::iterator it = thread_map_.find(name);
41 if (it != thread_map_.end())
42 return (*it).second;
43
44 base::Thread* thread = new base::Thread(name.c_str());
45 CHECK(thread->Start()) << "Failed to start thread: " << name;
46 thread_map_[name] = thread;
47 return thread;
48 }
10 49
11 } // namespace media 50 } // namespace media
OLDNEW
« no previous file with comments | « media/base/message_loop_factory.h ('k') | media/base/message_loop_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698