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

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

Issue 6171009: Remove MessageLoop methods from Filter interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied more CR suggestions & removed message_loop() methods where possible. Created 9 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
« no previous file with comments | « media/base/message_loop_factory_impl.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 AutoLock auto_lock(lock_);
34
35 ThreadMap::iterator it = thread_map_.find(name);
36 if (it != thread_map_.end())
37 return (*it).second->message_loop();
38
39 scoped_ptr<base::Thread> thread(new base::Thread(name.c_str()));
40
41 if (thread->Start()) {
42 MessageLoop* message_loop = thread->message_loop();
43 thread_map_[name] = thread.release();
44 return message_loop;
45 }
46
47 LOG(ERROR) << "Failed to start '" << name << "' thread!";
48 return NULL;
49 }
50
51 } // namespace media
OLDNEW
« no previous file with comments | « media/base/message_loop_factory_impl.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698