summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/renderer/render_view_impl.cc4
-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
-rw-r--r--webkit/media/webmediaplayer_impl.cc1
-rw-r--r--webkit/support/webkit_support.cc4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc4
13 files changed, 84 insertions, 145 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 3da74dc..8e729f3 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -86,7 +86,7 @@
#include "content/renderer/websharedworker_proxy.h"
#include "media/base/filter_collection.h"
#include "media/base/media_switches.h"
-#include "media/base/message_loop_factory_impl.h"
+#include "media/base/message_loop_factory.h"
#include "media/filters/gpu_video_decoder.h"
#include "net/base/escape.h"
#include "net/base/net_errors.h"
@@ -2118,7 +2118,7 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer(
RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client));
media::MessageLoopFactory* message_loop_factory =
- new media::MessageLoopFactoryImpl();
+ new media::MessageLoopFactory();
media::FilterCollection* collection = new media::FilterCollection();
RenderMediaLog* render_media_log = new RenderMediaLog();
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;
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 652c66e..42e6041 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -127,7 +127,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
MessageLoop* pipeline_message_loop =
message_loop_factory_->GetMessageLoop("PipelineThread");
- CHECK(pipeline_message_loop) << "Failed to create a new thread";
pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_);
// Let V8 know we started new thread if we did not did it yet.
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 0968753..0bb942a 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -30,7 +30,7 @@
#include "grit/webkit_chromium_resources.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 "net/base/escape.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
@@ -325,7 +325,7 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(
return NULL;
#else
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
- new media::MessageLoopFactoryImpl());
+ new media::MessageLoopFactory());
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index dc62a70f..a62e624 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -18,7 +18,7 @@
#include "base/utf_string_conversions.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 "net/base/net_errors.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
@@ -651,7 +651,7 @@ WebPlugin* TestWebViewDelegate::createPlugin(WebFrame* frame,
WebMediaPlayer* TestWebViewDelegate::createMediaPlayer(
WebFrame* frame, WebMediaPlayerClient* client) {
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
- new media::MessageLoopFactoryImpl());
+ new media::MessageLoopFactory());
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());