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
This commit is contained in:
content/renderer
media
base
message_loop_factory.ccmessage_loop_factory.hmessage_loop_factory_impl.ccmessage_loop_factory_impl.h
filters
media.gyptools
webkit
@ -86,7 +86,7 @@
|
|||||||
#include "content/renderer/websharedworker_proxy.h"
|
#include "content/renderer/websharedworker_proxy.h"
|
||||||
#include "media/base/filter_collection.h"
|
#include "media/base/filter_collection.h"
|
||||||
#include "media/base/media_switches.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 "media/filters/gpu_video_decoder.h"
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
@ -2118,7 +2118,7 @@ WebMediaPlayer* RenderViewImpl::createMediaPlayer(
|
|||||||
RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client));
|
RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client));
|
||||||
|
|
||||||
media::MessageLoopFactory* message_loop_factory =
|
media::MessageLoopFactory* message_loop_factory =
|
||||||
new media::MessageLoopFactoryImpl();
|
new media::MessageLoopFactory();
|
||||||
media::FilterCollection* collection = new media::FilterCollection();
|
media::FilterCollection* collection = new media::FilterCollection();
|
||||||
RenderMediaLog* render_media_log = new RenderMediaLog();
|
RenderMediaLog* render_media_log = new RenderMediaLog();
|
||||||
|
|
||||||
|
@ -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
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "media/base/message_loop_factory.h"
|
#include "media/base/message_loop_factory.h"
|
||||||
|
|
||||||
|
#include "base/threading/thread.h"
|
||||||
|
|
||||||
namespace media {
|
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
|
} // namespace media
|
||||||
|
@ -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
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
|
#ifndef MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
|
||||||
#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
|
#define MEDIA_BASE_MESSAGE_LOOP_FACTORY_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "base/message_loop_proxy.h"
|
#include "base/message_loop_proxy.h"
|
||||||
|
#include "base/synchronization/lock.h"
|
||||||
#include "media/base/media_export.h"
|
#include "media/base/media_export.h"
|
||||||
|
|
||||||
class MessageLoop;
|
class MessageLoop;
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
class Thread;
|
||||||
|
}
|
||||||
|
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
// Factory object that manages named MessageLoops.
|
// Factory object that manages named MessageLoops.
|
||||||
|
//
|
||||||
|
// TODO(scherkus): replace this with something simpler http://crbug.com/116873
|
||||||
class MEDIA_EXPORT MessageLoopFactory {
|
class MEDIA_EXPORT MessageLoopFactory {
|
||||||
public:
|
public:
|
||||||
|
MessageLoopFactory();
|
||||||
|
|
||||||
// Get the message loop associated with |name|. A new MessageLoop
|
// Get the message loop associated with |name|. A new MessageLoop
|
||||||
// is created if the factory doesn't have one associated with |name|.
|
// 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
|
// |name| must not be an empty string.
|
||||||
// creation process.
|
MessageLoop* GetMessageLoop(const std::string& name);
|
||||||
virtual MessageLoop* GetMessageLoop(const std::string& name) = 0;
|
|
||||||
|
|
||||||
// Get the message loop proxy associated with |name|. A new MessageLoopProxy
|
// Get the message loop proxy associated with |name|. A new MessageLoopProxy
|
||||||
// is created if the factory doesn't have one associated with |name|.
|
// 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
|
// |name| must not be an empty string.
|
||||||
// creation process.
|
scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
|
||||||
virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxy(
|
const std::string& name);
|
||||||
const std::string& name) = 0;
|
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
// Only allow scoped_ptr<> to delete factory.
|
// Only allow scoped_ptr<> to delete factory.
|
||||||
friend class scoped_ptr<MessageLoopFactory>;
|
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
|
} // namespace media
|
||||||
|
@ -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
|
|
@ -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_
|
|
@ -19,7 +19,7 @@ using ::testing::AnyNumber;
|
|||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
PipelineIntegrationTestBase::PipelineIntegrationTestBase()
|
PipelineIntegrationTestBase::PipelineIntegrationTestBase()
|
||||||
: message_loop_factory_(new MessageLoopFactoryImpl()),
|
: message_loop_factory_(new MessageLoopFactory()),
|
||||||
pipeline_(new Pipeline(&message_loop_, new MediaLog())),
|
pipeline_(new Pipeline(&message_loop_, new MediaLog())),
|
||||||
ended_(false),
|
ended_(false),
|
||||||
pipeline_status_(PIPELINE_OK) {
|
pipeline_status_(PIPELINE_OK) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
#include "media/base/filter_collection.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/base/pipeline.h"
|
||||||
#include "media/filters/chunk_demuxer.h"
|
#include "media/filters/chunk_demuxer.h"
|
||||||
#include "testing/gmock/include/gmock/gmock.h"
|
#include "testing/gmock/include/gmock/gmock.h"
|
||||||
|
@ -144,8 +144,6 @@
|
|||||||
'base/media_win.cc',
|
'base/media_win.cc',
|
||||||
'base/message_loop_factory.cc',
|
'base/message_loop_factory.cc',
|
||||||
'base/message_loop_factory.h',
|
'base/message_loop_factory.h',
|
||||||
'base/message_loop_factory_impl.cc',
|
|
||||||
'base/message_loop_factory_impl.h',
|
|
||||||
'base/pipeline.cc',
|
'base/pipeline.cc',
|
||||||
'base/pipeline.h',
|
'base/pipeline.h',
|
||||||
'base/pipeline_status.h',
|
'base/pipeline_status.h',
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "media/audio/audio_manager.h"
|
#include "media/audio/audio_manager.h"
|
||||||
#include "media/base/filter_collection.h"
|
#include "media/base/filter_collection.h"
|
||||||
#include "media/base/media_log.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/base/pipeline.h"
|
||||||
#include "media/filters/ffmpeg_audio_decoder.h"
|
#include "media/filters/ffmpeg_audio_decoder.h"
|
||||||
#include "media/filters/ffmpeg_demuxer_factory.h"
|
#include "media/filters/ffmpeg_demuxer_factory.h"
|
||||||
@ -62,7 +62,7 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) {
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
message_loop_factory_.reset(new media::MessageLoopFactoryImpl());
|
message_loop_factory_.reset(new media::MessageLoopFactory());
|
||||||
|
|
||||||
MessageLoop* pipeline_loop =
|
MessageLoop* pipeline_loop =
|
||||||
message_loop_factory_->GetMessageLoop("PipelineThread");
|
message_loop_factory_->GetMessageLoop("PipelineThread");
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "media/base/media.h"
|
#include "media/base/media.h"
|
||||||
#include "media/base/media_log.h"
|
#include "media/base/media_log.h"
|
||||||
#include "media/base/media_switches.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/pipeline.h"
|
||||||
#include "media/base/video_frame.h"
|
#include "media/base/video_frame.h"
|
||||||
#include "media/filters/ffmpeg_audio_decoder.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.
|
// Initialize the pipeline thread and the pipeline.
|
||||||
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
||||||
new media::MessageLoopFactoryImpl());
|
new media::MessageLoopFactory());
|
||||||
scoped_ptr<base::Thread> thread;
|
scoped_ptr<base::Thread> thread;
|
||||||
scoped_refptr<media::Pipeline> pipeline;
|
scoped_refptr<media::Pipeline> pipeline;
|
||||||
MessageLoop message_loop;
|
MessageLoop message_loop;
|
||||||
|
@ -127,7 +127,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
|
|||||||
|
|
||||||
MessageLoop* pipeline_message_loop =
|
MessageLoop* pipeline_message_loop =
|
||||||
message_loop_factory_->GetMessageLoop("PipelineThread");
|
message_loop_factory_->GetMessageLoop("PipelineThread");
|
||||||
CHECK(pipeline_message_loop) << "Failed to create a new thread";
|
|
||||||
pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_);
|
pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_);
|
||||||
|
|
||||||
// Let V8 know we started new thread if we did not did it yet.
|
// Let V8 know we started new thread if we did not did it yet.
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "grit/webkit_chromium_resources.h"
|
#include "grit/webkit_chromium_resources.h"
|
||||||
#include "media/base/filter_collection.h"
|
#include "media/base/filter_collection.h"
|
||||||
#include "media/base/media_log.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/escape.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "net/base/net_util.h"
|
#include "net/base/net_util.h"
|
||||||
@ -325,7 +325,7 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(
|
|||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
||||||
new media::MessageLoopFactoryImpl());
|
new media::MessageLoopFactory());
|
||||||
|
|
||||||
scoped_ptr<media::FilterCollection> collection(
|
scoped_ptr<media::FilterCollection> collection(
|
||||||
new media::FilterCollection());
|
new media::FilterCollection());
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "base/utf_string_conversions.h"
|
#include "base/utf_string_conversions.h"
|
||||||
#include "media/base/filter_collection.h"
|
#include "media/base/filter_collection.h"
|
||||||
#include "media/base/media_log.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 "net/base/net_errors.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
|
||||||
@ -651,7 +651,7 @@ WebPlugin* TestWebViewDelegate::createPlugin(WebFrame* frame,
|
|||||||
WebMediaPlayer* TestWebViewDelegate::createMediaPlayer(
|
WebMediaPlayer* TestWebViewDelegate::createMediaPlayer(
|
||||||
WebFrame* frame, WebMediaPlayerClient* client) {
|
WebFrame* frame, WebMediaPlayerClient* client) {
|
||||||
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
scoped_ptr<media::MessageLoopFactory> message_loop_factory(
|
||||||
new media::MessageLoopFactoryImpl());
|
new media::MessageLoopFactory());
|
||||||
|
|
||||||
scoped_ptr<media::FilterCollection> collection(
|
scoped_ptr<media::FilterCollection> collection(
|
||||||
new media::FilterCollection());
|
new media::FilterCollection());
|
||||||
|
Reference in New Issue
Block a user