summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 01:33:50 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-06 01:33:50 +0000
commitb8032290c28370be60077d7e509e41951b04715c (patch)
tree13cb575caf8539a97c75de1eb353ce820fc58859 /media
parent6baff0b5ce43b24522f0af48e664d925088c7f3d (diff)
downloadchromium_src-b8032290c28370be60077d7e509e41951b04715c.zip
chromium_src-b8032290c28370be60077d7e509e41951b04715c.tar.gz
chromium_src-b8032290c28370be60077d7e509e41951b04715c.tar.bz2
Fold media::MessageLoopFactoryImpl into media::MessageLoopFactory.
We haven't had a second implementation of the interface since MessageLoopFactory was added in r71548. Review URL: https://chromiumcodereview.appspot.com/9597016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/message_loop_factory.cc43
-rw-r--r--media/base/message_loop_factory.h43
-rw-r--r--media/base/message_loop_factory_impl.cc76
-rw-r--r--media/base/message_loop_factory_impl.h40
-rw-r--r--media/filters/pipeline_integration_test_base.cc2
-rw-r--r--media/filters/pipeline_integration_test_base.h2
-rw-r--r--media/media.gyp2
-rw-r--r--media/tools/player_wtl/movie.cc4
-rw-r--r--media/tools/player_x11/player_x11.cc4
9 files changed, 78 insertions, 138 deletions
diff --git a/media/base/message_loop_factory.cc b/media/base/message_loop_factory.cc
index e5b1d33..a62abc5 100644
--- a/media/base/message_loop_factory.cc
+++ b/media/base/message_loop_factory.cc
@@ -1,11 +1,50 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.h"
+#include "base/threading/thread.h"
+
namespace media {
-MessageLoopFactory::~MessageLoopFactory() {}
+MessageLoopFactory::MessageLoopFactory() {}
+
+MessageLoopFactory::~MessageLoopFactory() {
+ 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();
+}
+
+MessageLoop* MessageLoopFactory::GetMessageLoop(const std::string& name) {
+ return GetThread(name)->message_loop();
+}
+
+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::AutoLock auto_lock(lock_);
+ ThreadMap::iterator it = thread_map_.find(name);
+ if (it != thread_map_.end())
+ return (*it).second;
+
+ base::Thread* thread = new base::Thread(name.c_str());
+ CHECK(thread->Start()) << "Failed to start thread: " << name;
+ thread_map_[name] = thread;
+ return thread;
+}
} // namespace media
diff --git a/media/base/message_loop_factory.h b/media/base/message_loop_factory.h
index 7227840..d8ecdb5 100644
--- a/media/base/message_loop_factory.h
+++ b/media/base/message_loop_factory.h
@@ -1,43 +1,62 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
+#include <map>
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop_proxy.h"
+#include "base/synchronization/lock.h"
#include "media/base/media_export.h"
class MessageLoop;
+namespace base {
+class Thread;
+}
+
namespace media {
// Factory object that manages named MessageLoops.
+//
+// TODO(scherkus): replace this with something simpler http://crbug.com/116873
class MEDIA_EXPORT MessageLoopFactory {
public:
+ MessageLoopFactory();
+
// Get the message loop associated with |name|. A new MessageLoop
// is created if the factory doesn't have one associated with |name|.
- // NULL is returned if |name| is an empty string, or a new
- // MessageLoop needs to be created and a failure occurs during the
- // creation process.
- virtual MessageLoop* GetMessageLoop(const std::string& name) = 0;
+ //
+ // |name| must not be an empty string.
+ MessageLoop* GetMessageLoop(const std::string& name);
// Get the message loop proxy associated with |name|. A new MessageLoopProxy
// is created if the factory doesn't have one associated with |name|.
- // NULL is returned if |name| is an empty string, or a new
- // MessageLoop needs to be created and a failure occurs during the
- // creation process.
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
- const std::string& name) = 0;
+ //
+ // |name| must not be an empty string.
+ scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
+ const std::string& name);
- protected:
+ private:
// Only allow scoped_ptr<> to delete factory.
friend class scoped_ptr<MessageLoopFactory>;
- virtual ~MessageLoopFactory();
+ ~MessageLoopFactory();
+
+ // Returns the thread associated with |name| creating a new thread if needed.
+ base::Thread* GetThread(const std::string& name);
+
+ // Lock used to serialize access for the following data members.
+ base::Lock lock_;
+
+ typedef std::map<std::string, base::Thread*> ThreadMap;
+ ThreadMap thread_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopFactory);
};
} // namespace media
diff --git a/media/base/message_loop_factory_impl.cc b/media/base/message_loop_factory_impl.cc
deleted file mode 100644
index 6cf12da..0000000
--- a/media/base/message_loop_factory_impl.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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() {
- base::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;
- }
-
- base::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;
-}
-
-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
diff --git a/media/base/message_loop_factory_impl.h b/media/base/message_loop_factory_impl.h
deleted file mode 100644
index e0e0710..0000000
--- a/media/base/message_loop_factory_impl.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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.
-
-#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_IMPL_H_
-#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_IMPL_H_
-
-#include <map>
-#include <string>
-
-#include "base/threading/thread.h"
-#include "media/base/message_loop_factory.h"
-
-namespace media {
-
-class MEDIA_EXPORT MessageLoopFactoryImpl : public MessageLoopFactory {
- public:
- MessageLoopFactoryImpl();
-
- // MessageLoopFactory methods.
- virtual MessageLoop* GetMessageLoop(const std::string& name) OVERRIDE;
- virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
- const std::string& name) OVERRIDE;
-
- protected:
- virtual ~MessageLoopFactoryImpl();
-
- private:
- // Lock used to serialize access for the following data members.
- base::Lock lock_;
-
- typedef std::map<std::string, base::Thread*> ThreadMap;
- ThreadMap thread_map_;
-
- DISALLOW_COPY_AND_ASSIGN(MessageLoopFactoryImpl);
-};
-
-} // namespace media
-
-#endif // MEDIA_BASE_MESSAGE_LOOP_FACTORY_IMPL_H_
diff --git a/media/filters/pipeline_integration_test_base.cc b/media/filters/pipeline_integration_test_base.cc
index ed8caf6..dd3cd5b 100644
--- a/media/filters/pipeline_integration_test_base.cc
+++ b/media/filters/pipeline_integration_test_base.cc
@@ -19,7 +19,7 @@ using ::testing::AnyNumber;
namespace media {
PipelineIntegrationTestBase::PipelineIntegrationTestBase()
- : message_loop_factory_(new MessageLoopFactoryImpl()),
+ : message_loop_factory_(new MessageLoopFactory()),
pipeline_(new Pipeline(&message_loop_, new MediaLog())),
ended_(false),
pipeline_status_(PIPELINE_OK) {
diff --git a/media/filters/pipeline_integration_test_base.h b/media/filters/pipeline_integration_test_base.h
index 818ef80..06e6bf1 100644
--- a/media/filters/pipeline_integration_test_base.h
+++ b/media/filters/pipeline_integration_test_base.h
@@ -7,7 +7,7 @@
#include "base/message_loop.h"
#include "media/base/filter_collection.h"
-#include "media/base/message_loop_factory_impl.h"
+#include "media/base/message_loop_factory.h"
#include "media/base/pipeline.h"
#include "media/filters/chunk_demuxer.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/media/media.gyp b/media/media.gyp
index db675e1..d229ed3 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -144,8 +144,6 @@
'base/media_win.cc',
'base/message_loop_factory.cc',
'base/message_loop_factory.h',
- 'base/message_loop_factory_impl.cc',
- 'base/message_loop_factory_impl.h',
'base/pipeline.cc',
'base/pipeline.h',
'base/pipeline_status.h',
diff --git a/media/tools/player_wtl/movie.cc b/media/tools/player_wtl/movie.cc
index 6531d84..b2e7acc4 100644
--- a/media/tools/player_wtl/movie.cc
+++ b/media/tools/player_wtl/movie.cc
@@ -10,7 +10,7 @@
#include "media/audio/audio_manager.h"
#include "media/base/filter_collection.h"
#include "media/base/media_log.h"
-#include "media/base/message_loop_factory_impl.h"
+#include "media/base/message_loop_factory.h"
#include "media/base/pipeline.h"
#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_demuxer_factory.h"
@@ -62,7 +62,7 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) {
Close();
}
- message_loop_factory_.reset(new media::MessageLoopFactoryImpl());
+ message_loop_factory_.reset(new media::MessageLoopFactory());
MessageLoop* pipeline_loop =
message_loop_factory_->GetMessageLoop("PipelineThread");
diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc
index f89f63a..8d9b4e0 100644
--- a/media/tools/player_x11/player_x11.cc
+++ b/media/tools/player_x11/player_x11.cc
@@ -20,7 +20,7 @@
#include "media/base/media.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
-#include "media/base/message_loop_factory_impl.h"
+#include "media/base/message_loop_factory.h"
#include "media/base/pipeline.h"
#include "media/base/video_frame.h"
#include "media/filters/ffmpeg_audio_decoder.h"
@@ -269,7 +269,7 @@ int main(int argc, char** argv) {
// Initialize the pipeline thread and the pipeline.
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
- new media::MessageLoopFactoryImpl());
+ new media::MessageLoopFactory());
scoped_ptr<base::Thread> thread;
scoped_refptr<media::Pipeline> pipeline;
MessageLoop message_loop;