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

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

Issue 6951013: add MessageLoopProxy in MessageLoopFactory (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: use full name Created 9 years, 7 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') | no next file » | 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) 2011 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_impl.h" 5 #include "media/base/message_loop_factory_impl.h"
6 6
7 namespace media { 7 namespace media {
8 8
9 MessageLoopFactoryImpl::MessageLoopFactoryImpl() {} 9 MessageLoopFactoryImpl::MessageLoopFactoryImpl() {}
10 10
(...skipping 30 matching lines...) Expand all
41 if (thread->Start()) { 41 if (thread->Start()) {
42 MessageLoop* message_loop = thread->message_loop(); 42 MessageLoop* message_loop = thread->message_loop();
43 thread_map_[name] = thread.release(); 43 thread_map_[name] = thread.release();
44 return message_loop; 44 return message_loop;
45 } 45 }
46 46
47 LOG(ERROR) << "Failed to start '" << name << "' thread!"; 47 LOG(ERROR) << "Failed to start '" << name << "' thread!";
48 return NULL; 48 return NULL;
49 } 49 }
50 50
51 scoped_refptr<base::MessageLoopProxy>
52 MessageLoopFactoryImpl::GetMessageLoopProxy(const std::string& name) {
53 if (name.empty()) {
54 return NULL;
55 }
56
57 base::AutoLock auto_lock(lock_);
58
59 ThreadMap::iterator it = thread_map_.find(name);
60 if (it != thread_map_.end())
61 return (*it).second->message_loop_proxy();
62
63 scoped_ptr<base::Thread> thread(new base::Thread(name.c_str()));
64
65 if (thread->Start()) {
66 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
67 thread->message_loop_proxy();
68 thread_map_[name] = thread.release();
69 return message_loop_proxy;
70 }
71
72 LOG(ERROR) << "Failed to start '" << name << "' thread!";
73 return NULL;
74 }
75
51 } // namespace media 76 } // namespace media
OLDNEW
« no previous file with comments | « media/base/message_loop_factory_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698