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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/message_loop_factory_impl.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/message_loop_factory_impl.cc
diff --git a/media/base/message_loop_factory_impl.cc b/media/base/message_loop_factory_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bcf3bf867b847166e7f138a2d3d46e779f94cfa3
--- /dev/null
+++ b/media/base/message_loop_factory_impl.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/message_loop_factory_impl.h"
+
+namespace media {
+
+MessageLoopFactoryImpl::MessageLoopFactoryImpl() {}
+
+MessageLoopFactoryImpl::~MessageLoopFactoryImpl() {
+ AutoLock auto_lock(lock_);
+
+ for (ThreadMap::iterator iter = thread_map_.begin();
+ iter != thread_map_.end();
+ ++iter) {
+ base::Thread* thread = (*iter).second;
+
+ if (thread) {
+ thread->Stop();
+ delete thread;
+ }
+ }
+ thread_map_.clear();
+}
+
+// MessageLoopFactory methods.
+MessageLoop* MessageLoopFactoryImpl::GetMessageLoop(const std::string& name) {
+ if (name.empty()) {
+ return NULL;
+ }
+
+ AutoLock auto_lock(lock_);
+
+ ThreadMap::iterator it = thread_map_.find(name);
+ if (it != thread_map_.end())
+ return (*it).second->message_loop();
+
+ scoped_ptr<base::Thread> thread(new base::Thread(name.c_str()));
+
+ if (thread->Start()) {
+ MessageLoop* message_loop = thread->message_loop();
+ thread_map_[name] = thread.release();
+ return message_loop;
+ }
+
+ LOG(ERROR) << "Failed to start '" << name << "' thread!";
+ return NULL;
+}
+
+} // namespace media
« 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