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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/message_loop_factory_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/message_loop_factory_impl.cc
===================================================================
--- media/base/message_loop_factory_impl.cc (revision 83707)
+++ media/base/message_loop_factory_impl.cc (working copy)
@@ -48,4 +48,29 @@
return NULL;
}
+scoped_refptr<base::MessageLoopProxy>
+MessageLoopFactoryImpl::GetMessageLoopProxy(const std::string& name) {
+ if (name.empty()) {
+ return NULL;
+ }
+
+ base::AutoLock auto_lock(lock_);
+
+ ThreadMap::iterator it = thread_map_.find(name);
+ if (it != thread_map_.end())
+ return (*it).second->message_loop_proxy();
+
+ scoped_ptr<base::Thread> thread(new base::Thread(name.c_str()));
+
+ if (thread->Start()) {
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
+ thread->message_loop_proxy();
+ thread_map_[name] = thread.release();
+ return message_loop_proxy;
+ }
+
+ LOG(ERROR) << "Failed to start '" << name << "' thread!";
+ return NULL;
+}
+
} // namespace media
« 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