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

Unified Diff: media/base/message_loop_factory.cc

Issue 10855051: Use enum instead of string in MessageLoopFactory::GetMessageLoop* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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.h ('k') | media/base/pipeline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/message_loop_factory.cc
diff --git a/media/base/message_loop_factory.cc b/media/base/message_loop_factory.cc
index 22ec96c9a21cc166adf2a405d7c39201a18fea3f..04a904a57a86089e531c4b1ef7bb2d9156c87962 100644
--- a/media/base/message_loop_factory.cc
+++ b/media/base/message_loop_factory.cc
@@ -20,27 +20,34 @@ MessageLoopFactory::~MessageLoopFactory() {
threads_.clear();
}
-MessageLoop* MessageLoopFactory::GetMessageLoop(const std::string& name) {
- return GetThread(name)->message_loop();
+scoped_refptr<base::MessageLoopProxy> MessageLoopFactory::GetMessageLoop(
+ Type type) {
+ return GetThread(type)->message_loop_proxy();
}
-scoped_refptr<base::MessageLoopProxy>
-MessageLoopFactory::GetMessageLoopProxy(const std::string& name) {
- return GetThread(name)->message_loop_proxy();
-}
-
-base::Thread* MessageLoopFactory::GetThread(const std::string& name) {
- DCHECK(!name.empty());
-
+base::Thread* MessageLoopFactory::GetThread(Type type) {
base::AutoLock auto_lock(lock_);
for (ThreadList::iterator it = threads_.begin(); it != threads_.end(); ++it) {
- if (it->first == name)
+ if (it->first == type)
return it->second;
}
- base::Thread* thread = new base::Thread(name.c_str());
+ const char* name = NULL;
+ switch (type) {
+ case kAudioDecoder:
+ name = "AudioDecoderThread";
+ break;
+ case kVideoDecoder:
+ name = "VideoDecoderThread";
+ break;
+ case kPipeline:
+ name = "PipelineThread";
+ break;
+ }
+
+ base::Thread* thread = new base::Thread(name);
CHECK(thread->Start()) << "Failed to start thread: " << name;
- threads_.push_back(std::make_pair(name, thread));
+ threads_.push_back(std::make_pair(type, thread));
return thread;
}
« no previous file with comments | « media/base/message_loop_factory.h ('k') | media/base/pipeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698