summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/media/buffered_data_source.cc61
-rw-r--r--chrome/renderer/media/buffered_data_source.h46
-rw-r--r--chrome/renderer/render_view.cc19
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory.cc72
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory.h71
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory_unittest.cc44
-rw-r--r--webkit/glue/media/simple_data_source.cc26
-rw-r--r--webkit/glue/media/simple_data_source.h30
-rw-r--r--webkit/glue/webmediaplayer_impl.cc16
-rw-r--r--webkit/glue/webmediaplayer_impl.h3
-rw-r--r--webkit/tools/test_shell/test_shell.gyp1
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc22
-rw-r--r--webkit/webkit.gyp2
13 files changed, 308 insertions, 105 deletions
diff --git a/chrome/renderer/media/buffered_data_source.cc b/chrome/renderer/media/buffered_data_source.cc
index f0aa456..ef92ce1 100644
--- a/chrome/renderer/media/buffered_data_source.cc
+++ b/chrome/renderer/media/buffered_data_source.cc
@@ -62,11 +62,12 @@ bool IsSchemeSupported(const GURL& url) {
/////////////////////////////////////////////////////////////////////////////
// BufferedResourceLoader
-BufferedResourceLoader::BufferedResourceLoader(MessageLoop* message_loop,
- int32 routing_id,
- const GURL& url,
- int64 first_byte_position,
- int64 last_byte_position)
+BufferedResourceLoader::BufferedResourceLoader(
+ MessageLoop* message_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
+ const GURL& url,
+ int64 first_byte_position,
+ int64 last_byte_position)
: start_callback_(NULL),
bridge_(NULL),
offset_(0),
@@ -78,7 +79,7 @@ BufferedResourceLoader::BufferedResourceLoader(MessageLoop* message_loop,
completed_(false),
range_requested_(false),
async_start_(false),
- routing_id_(routing_id),
+ bridge_factory_(bridge_factory),
url_(url),
first_byte_position_(first_byte_position),
last_byte_position_(last_byte_position),
@@ -450,41 +451,19 @@ void BufferedResourceLoader::OnStart() {
if (stopped_)
return;
- // Construct the range header.
- std::string header;
- if (first_byte_position_ != kPositionNotSpecified &&
- last_byte_position_ != kPositionNotSpecified) {
- header = StringPrintf("Range: bytes=%lld-%lld",
- first_byte_position_,
- last_byte_position_);
+ if (first_byte_position_ != kPositionNotSpecified) {
range_requested_ = true;
+ // TODO(hclam): server may not support range request so |offset_| may not
+ // equal to |first_byte_position_|.
offset_ = first_byte_position_;
- } else if (first_byte_position_ != kPositionNotSpecified) {
- header = StringPrintf("Range: bytes=%lld-", first_byte_position_);
- range_requested_ = true;
- offset_ = first_byte_position_;
- } else if (last_byte_position_ != kPositionNotSpecified) {
- NOTIMPLEMENTED() << "Suffix length range request not implemented.";
}
// Creates the bridge on render thread since we can only access
// ResourceDispatcher on this thread.
- bridge_.reset(webkit_glue::ResourceLoaderBridge::Create(
- "GET",
- GURL(url_),
- GURL(url_),
- GURL(), // TODO(hclam): provide referer here.
- "null", // TODO(abarth): provide frame_origin
- "null", // TODO(abarth): provide main_frame_origin
- header,
- net::LOAD_BYPASS_CACHE,
- base::GetCurrentProcId(),
- ResourceType::MEDIA,
- // TODO(michaeln): delegate->mediaplayer->frame->
- // app_cache_context()->context_id()
- // For now don't service media resource requests from the appcache.
- WebAppCacheContext::kNoAppCacheContextId,
- routing_id_));
+ bridge_.reset(bridge_factory_->CreateBridge(url_,
+ net::LOAD_BYPASS_CACHE,
+ first_byte_position_,
+ last_byte_position_));
// And start the resource loading.
bridge_->Start(this);
@@ -523,11 +502,13 @@ void BufferedResourceLoader::InvokeAndResetStartCallback(int error) {
//////////////////////////////////////////////////////////////////////////////
// BufferedDataSource
-BufferedDataSource::BufferedDataSource(MessageLoop* render_loop, int routing_id)
- : routing_id_(routing_id),
- stopped_(false),
+BufferedDataSource::BufferedDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
+ : stopped_(false),
position_(0),
total_bytes_(kPositionNotSpecified),
+ bridge_factory_(bridge_factory),
buffered_resource_loader_(NULL),
render_loop_(render_loop),
pipeline_loop_(MessageLoop::current()) {
@@ -572,7 +553,7 @@ bool BufferedDataSource::Initialize(const std::string& url) {
if (!stopped_) {
buffered_resource_loader_ = new BufferedResourceLoader(
render_loop_,
- routing_id_,
+ bridge_factory_.get(),
url_,
kPositionNotSpecified,
kPositionNotSpecified);
@@ -636,7 +617,7 @@ size_t BufferedDataSource::Read(uint8* data, size_t size) {
// Create a new resource loader.
buffered_resource_loader_ =
new BufferedResourceLoader(render_loop_,
- routing_id_,
+ bridge_factory_.get(),
url_,
position_,
kPositionNotSpecified);
diff --git a/chrome/renderer/media/buffered_data_source.h b/chrome/renderer/media/buffered_data_source.h
index 0111629..d676142 100644
--- a/chrome/renderer/media/buffered_data_source.h
+++ b/chrome/renderer/media/buffered_data_source.h
@@ -10,6 +10,7 @@
#include "base/lock.h"
#include "base/scoped_ptr.h"
#include "base/condition_variable.h"
+#include "googleurl/src/gurl.h"
#include "media/base/factory.h"
#include "media/base/filters.h"
#include "media/base/media_format.h"
@@ -17,8 +18,7 @@
#include "media/base/seekable_buffer.h"
#include "net/base/completion_callback.h"
#include "net/base/file_stream.h"
-#include "webkit/glue/resource_loader_bridge.h"
-#include "googleurl/src/gurl.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
/////////////////////////////////////////////////////////////////////////////
// BufferedResourceLoader
@@ -31,16 +31,17 @@ class BufferedResourceLoader :
public webkit_glue::ResourceLoaderBridge::Peer {
public:
// |message_loop| - The message loop this resource loader should run on.
- // |routing_id| - Routing id to this view.
+ // |bridge_factory| - Factory to create a ResourceLoaderBridge.
// |url| - URL for the resource to be loaded.
// |first_byte_position| - First byte to start loading from, -1 for not
// specified.
// |last_byte_position| - Last byte to be loaded, -1 for not specified.
- BufferedResourceLoader(MessageLoop* message_loop,
- int32 routing_id,
- const GURL& url,
- int64 first_byte_position,
- int64 last_byte_position);
+ BufferedResourceLoader(
+ MessageLoop* message_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
+ const GURL& url,
+ int64 first_byte_position,
+ int64 last_byte_position);
virtual ~BufferedResourceLoader();
// Start the resource loading with the specified URL and range.
@@ -173,7 +174,7 @@ class BufferedResourceLoader :
bool range_requested_;
bool async_start_;
- int32 routing_id_;
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory_;
GURL url_;
int64 first_byte_position_;
int64 last_byte_position_;
@@ -194,11 +195,14 @@ class BufferedDataSource : public media::DataSource {
public:
// Methods called from pipeline thread
// Static methods for creating this class.
- static media::FilterFactory* CreateFactory(MessageLoop* message_loop,
- int32 routing_id) {
- return new media::FilterFactoryImpl2<BufferedDataSource,
- MessageLoop*,
- int32>(message_loop, routing_id);
+ static media::FilterFactory* CreateFactory(
+ MessageLoop* message_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) {
+ return new media::FilterFactoryImpl2<
+ BufferedDataSource,
+ MessageLoop*,
+ webkit_glue::MediaResourceLoaderBridgeFactory*>(
+ message_loop, bridge_factory);
}
virtual bool Initialize(const std::string& url);
@@ -216,9 +220,10 @@ class BufferedDataSource : public media::DataSource {
const media::MediaFormat& media_format();
private:
- friend class media::FilterFactoryImpl2<BufferedDataSource,
- MessageLoop*,
- int32>;
+ friend class media::FilterFactoryImpl2<
+ BufferedDataSource,
+ MessageLoop*,
+ webkit_glue::MediaResourceLoaderBridgeFactory*>;
// Call to filter host to trigger an error, be sure not to call this method
// while the lock is acquired.
void HandleError(media::PipelineError error);
@@ -229,14 +234,14 @@ class BufferedDataSource : public media::DataSource {
void InitialRequestStarted(int error);
void OnInitialRequestStarted(int error);
- explicit BufferedDataSource(MessageLoop* render_loop, int32 routing_id);
+ explicit BufferedDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
virtual ~BufferedDataSource();
media::MediaFormat media_format_;
GURL url_;
- int32 routing_id_;
-
// A common lock for protecting members accessed by multiple threads.
Lock lock_;
bool stopped_;
@@ -247,6 +252,7 @@ class BufferedDataSource : public media::DataSource {
int64 total_bytes_;
// Members related to resource loading with RenderView.
+ scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_;
scoped_refptr<BufferedResourceLoader> buffered_resource_loader_;
// The message loop of the render thread.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index e2db735..f6cc47c 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -18,6 +18,7 @@
#include "base/field_trial.h"
#include "base/gfx/png_encoder.h"
#include "base/gfx/native_widget_types.h"
+#include "base/process_util.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "build/build_config.h"
@@ -69,6 +70,7 @@
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dom_serializer.h"
#include "webkit/glue/image_decoder.h"
+#include "webkit/glue/media/simple_data_source.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/searchable_form_data.h"
@@ -1763,11 +1765,26 @@ WebKit::WebMediaPlayer* RenderView::CreateWebMediaPlayer(
factory->AddFactory(
AudioRendererImpl::CreateFactory(audio_message_filter()));
}
+
+ // TODO(hclam): obtain the following parameters from |client|.
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory =
+ new webkit_glue::MediaResourceLoaderBridgeFactory(
+ GURL::EmptyGURL(), // referrer
+ "null", // frame origin
+ "null", // main_frame_origin
+ base::GetCurrentProcId(),
+ WebAppCacheContext::kNoAppCacheContextId,
+ routing_id());
+
if (!cmd_line->HasSwitch(switches::kSimpleDataSource)) {
// Add the chrome specific media data source.
factory->AddFactory(
BufferedDataSource::CreateFactory(MessageLoop::current(),
- routing_id()));
+ bridge_factory));
+ } else {
+ factory->AddFactory(
+ webkit_glue::SimpleDataSource::CreateFactory(MessageLoop::current(),
+ bridge_factory));
}
return new webkit_glue::WebMediaPlayerImpl(client, factory);
}
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.cc b/webkit/glue/media/media_resource_loader_bridge_factory.cc
new file mode 100644
index 0000000..9f1485d
--- /dev/null
+++ b/webkit/glue/media/media_resource_loader_bridge_factory.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2009 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 "base/string_util.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+
+namespace {
+
+// A constant for an unknown position.
+const int64 kPositionNotSpecified = -1;
+
+} // namespace
+
+namespace webkit_glue {
+
+MediaResourceLoaderBridgeFactory::MediaResourceLoaderBridgeFactory(
+ const GURL& referrer,
+ const std::string& frame_origin,
+ const std::string& main_frame_origin,
+ int origin_pid,
+ int app_cache_context_id,
+ int32 routing_id)
+ : referrer_(referrer),
+ frame_origin_(frame_origin),
+ main_frame_origin_(main_frame_origin),
+ origin_pid_(origin_pid),
+ app_cache_context_id_(app_cache_context_id),
+ routing_id_(routing_id) {
+}
+
+ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge(
+ const GURL& url,
+ int load_flags,
+ int64 first_byte_position,
+ int64 last_byte_position) {
+ return webkit_glue::ResourceLoaderBridge::Create(
+ "GET",
+ url,
+ url,
+ referrer_,
+ frame_origin_,
+ main_frame_origin_,
+ GenerateHeaders(first_byte_position, last_byte_position),
+ load_flags,
+ origin_pid_,
+ ResourceType::MEDIA,
+ app_cache_context_id_,
+ routing_id_);
+}
+
+// static
+const std::string MediaResourceLoaderBridgeFactory::GenerateHeaders (
+ int64 first_byte_position, int64 last_byte_position) {
+ // Construct the range header.
+ std::string header;
+ if (first_byte_position > kPositionNotSpecified &&
+ last_byte_position > kPositionNotSpecified) {
+ if (first_byte_position <= last_byte_position) {
+ header = StringPrintf("Range: bytes=%lld-%lld",
+ first_byte_position,
+ last_byte_position);
+ }
+ } else if (first_byte_position > kPositionNotSpecified) {
+ header = StringPrintf("Range: bytes=%lld-", first_byte_position);
+ } else {
+ NOTIMPLEMENTED() << "Operation not supported.";
+ }
+ return header;
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.h b/webkit/glue/media/media_resource_loader_bridge_factory.h
new file mode 100644
index 0000000..80c0ed2
--- /dev/null
+++ b/webkit/glue/media/media_resource_loader_bridge_factory.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2009 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 WEBKIT_GLUE_MEDIA_MEDIA_RESOURCE_LOADER_BRIDGE_FACTORY_H_
+#define WEBKIT_GLUE_MEDIA_MEDIA_RESOURCE_LOADER_BRIDGE_FACTORY_H_
+
+#include "testing/gtest/include/gtest/gtest_prod.h"
+#include "webkit/glue/resource_loader_bridge.h"
+
+namespace webkit_glue {
+
+// A factory used to create a ResourceLoaderBridge for the media player.
+// This factory is used also for testing. Testing code can use this class and
+// override CreateBridge() to inject a mock ResourceLoaderBridge for code that
+// interacts with it, e.g. BufferedDataSource.
+class MediaResourceLoaderBridgeFactory {
+ public:
+ MediaResourceLoaderBridgeFactory(
+ const GURL& referrer,
+ const std::string& frame_origin,
+ const std::string& main_frame_origin,
+ int origin_pid,
+ int app_cache_context_id,
+ int32 routing_id);
+
+ virtual ~MediaResourceLoaderBridgeFactory() {}
+
+ // Factory method to create a ResourceLoaderBridge with the following
+ // parameters:
+ // |url| - URL of the resource to be loaded.
+ // |load_flags| - Load flags for this loading.
+ // |first_byte_position| - First byte position for a range request, -1 if not.
+ // |last_byte_position| - Last byte position for a range request, -1 if not.
+ virtual ResourceLoaderBridge* CreateBridge(
+ const GURL& url,
+ int load_flags,
+ int64 first_byte_position,
+ int64 last_byte_position);
+
+ private:
+ FRIEND_TEST(MediaResourceLoaderBridgeFactoryTest, GenerateHeaders);
+
+ // Returns a range request header using parameters |first_byte_position| and
+ // |last_byte_position|.
+ // Negative numbers other than -1 are not allowed for |first_byte_position|
+ // and |last_byte_position|. |first_byte_position| should always be less than
+ // or equal to |last_byte_position| if they are both not -1.
+ // Here's a list of valid parameters:
+ // |first_byte_position| |last_byte_position|
+ // 0 1000
+ // 4096 4096
+ // 0 -1
+ // -1 -1
+ // Empty string is returned on invalid parameters.
+ static const std::string GenerateHeaders(int64 first_byte_position,
+ int64 last_byte_position);
+
+ GURL first_party_for_cookies_;
+ GURL referrer_;
+ std::string frame_origin_;
+ std::string main_frame_origin_;
+ std::string headers_;
+ int origin_pid_;
+ int app_cache_context_id_;
+ int32 routing_id_;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_MEDIA_MEDIA_RESOURCE_LOADER_BRIDGE_FACTORY_H_
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory_unittest.cc b/webkit/glue/media/media_resource_loader_bridge_factory_unittest.cc
new file mode 100644
index 0000000..4c0126b
--- /dev/null
+++ b/webkit/glue/media/media_resource_loader_bridge_factory_unittest.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 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 "net/http/http_util.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace webkit_glue {
+
+TEST(MediaResourceLoaderBridgeFactoryTest, GenerateHeaders) {
+ static const struct {
+ const bool success;
+ const int64 first_byte_position;
+ const int64 last_byte_position;
+ } data[] = {
+ { false, -1, -1 },
+ { false, -5, 0 },
+ { false, 100, 0 },
+ { true, 0, -1 },
+ { true, 0, 0 },
+ { true, 100, 100 },
+ { true, 50, -1 },
+ { true, 10000, -1 },
+ { true, 50, 100 },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
+ std::string headers = MediaResourceLoaderBridgeFactory::GenerateHeaders(
+ data[i].first_byte_position, data[i].last_byte_position);
+ std::vector<net::HttpByteRange> ranges;
+ bool ret = net::HttpUtil::ParseRanges(headers, &ranges);
+ EXPECT_EQ(data[i].success, ret);
+ if (ret) {
+ EXPECT_EQ(1u, ranges.size());
+ EXPECT_EQ(data[i].first_byte_position,
+ ranges[0].first_byte_position());
+ EXPECT_EQ(data[i].last_byte_position,
+ ranges[0].last_byte_position());
+ }
+ }
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 6207ddd..d7ba9c1 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -30,9 +30,11 @@ bool IsSchemeSupported(const GURL& url) {
namespace webkit_glue {
-SimpleDataSource::SimpleDataSource(MessageLoop* render_loop, int32 routing_id)
- : routing_id_(routing_id),
- render_loop_(render_loop),
+SimpleDataSource::SimpleDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
+ : render_loop_(render_loop),
+ bridge_factory_(bridge_factory),
size_(-1),
position_(0),
state_(UNINITIALIZED) {
@@ -177,22 +179,8 @@ void SimpleDataSource::StartTask() {
DCHECK_EQ(state_, INITIALIZING);
// Create our bridge and start loading the resource.
- bridge_.reset(webkit_glue::ResourceLoaderBridge::Create(
- "GET",
- url_,
- url_,
- GURL::EmptyGURL(), // TODO(scherkus): provide referer here.
- "null", // TODO(abarth): provide frame_origin
- "null", // TODO(abarth): provide main_frame_origin
- "",
- net::LOAD_BYPASS_CACHE,
- base::GetCurrentProcId(),
- ResourceType::MEDIA,
- // TODO(michaeln): delegate->mediaplayer->frame->
- // app_cache_context()->context_id()
- // For now don't service media resource requests from the appcache.
- WebAppCacheContext::kNoAppCacheContextId,
- routing_id_));
+ bridge_.reset(bridge_factory_->CreateBridge(
+ url_, net::LOAD_BYPASS_CACHE, -1, -1));
bridge_->Start(this);
}
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index 55693ff..7918034 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -14,7 +14,7 @@
#include "base/scoped_ptr.h"
#include "media/base/factory.h"
#include "media/base/filters.h"
-#include "webkit/glue/resource_loader_bridge.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
class MessageLoop;
class WebMediaPlayerDelegateImpl;
@@ -24,11 +24,14 @@ namespace webkit_glue {
class SimpleDataSource : public media::DataSource,
public webkit_glue::ResourceLoaderBridge::Peer {
public:
- static media::FilterFactory* CreateFactory(MessageLoop* message_loop,
- int32 routing_id) {
- return new media::FilterFactoryImpl2<SimpleDataSource,
- MessageLoop*,
- int32>(message_loop, routing_id);
+ static media::FilterFactory* CreateFactory(
+ MessageLoop* message_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) {
+ return new media::FilterFactoryImpl2<
+ SimpleDataSource,
+ MessageLoop*,
+ webkit_glue::MediaResourceLoaderBridgeFactory*>(message_loop,
+ bridge_factory);
}
// MediaFilter implementation.
@@ -56,8 +59,13 @@ class SimpleDataSource : public media::DataSource,
virtual std::string GetURLForDebugging();
private:
- friend class media::FilterFactoryImpl2<SimpleDataSource, MessageLoop*, int32>;
- SimpleDataSource(MessageLoop* render_loop, int32 routing_id);
+ friend class media::FilterFactoryImpl2<
+ SimpleDataSource,
+ MessageLoop*,
+ webkit_glue::MediaResourceLoaderBridgeFactory*>;
+ SimpleDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
virtual ~SimpleDataSource();
// Updates |url_| and |media_format_| with the given URL.
@@ -69,12 +77,12 @@ class SimpleDataSource : public media::DataSource,
// Cancels and deletes the resource loading on the render thread.
void CancelTask();
- // Passed in during construction, used when creating the bridge.
- int32 routing_id_;
-
// Primarily used for asserting the bridge is loading on the render thread.
MessageLoop* render_loop_;
+ // Factory to create a bridge.
+ scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_;
+
// Bridge used to load the media resource.
scoped_ptr<webkit_glue::ResourceLoaderBridge> bridge_;
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index 836ef12..d538a72 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -11,7 +11,6 @@
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebSize.h"
#include "webkit/api/public/WebURL.h"
-#include "webkit/glue/media/simple_data_source.h"
#include "webkit/glue/media/video_renderer_impl.h"
#include "webkit/glue/webmediaplayer_impl.h"
@@ -22,12 +21,12 @@ using WebKit::WebSize;
namespace webkit_glue {
/////////////////////////////////////////////////////////////////////////////
-// Task to be posted on main thread that fire WebMediaPlayer methods.
+// Task to be posted on main thread that fire WebMediaPlayerClient methods.
-class NotifyWebMediaPlayerTask : public CancelableTask {
+class NotifyWebMediaPlayerClientTask : public CancelableTask {
public:
- NotifyWebMediaPlayerTask(WebMediaPlayerImpl* media_player,
- WebMediaPlayerClientMethod method)
+ NotifyWebMediaPlayerClientTask(WebMediaPlayerImpl* media_player,
+ WebMediaPlayerClientMethod method)
: media_player_(media_player),
method_(method) {}
@@ -46,7 +45,7 @@ class NotifyWebMediaPlayerTask : public CancelableTask {
WebMediaPlayerImpl* media_player_;
WebMediaPlayerClientMethod method_;
- DISALLOW_COPY_AND_ASSIGN(NotifyWebMediaPlayerTask);
+ DISALLOW_COPY_AND_ASSIGN(NotifyWebMediaPlayerClientTask);
};
/////////////////////////////////////////////////////////////////////////////
@@ -67,9 +66,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory());
filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory());
filter_factory_->AddFactory(VideoRendererImpl::CreateFactory(this));
- // TODO(hclam): Provide a valid routing id to simple data source.
- filter_factory_->AddFactory(
- SimpleDataSource::CreateFactory(MessageLoop::current(), 0));
DCHECK(client_);
@@ -349,7 +345,7 @@ void WebMediaPlayerImpl::PostTask(int index,
AutoLock auto_lock(task_lock_);
if (!tasks_[index]) {
- CancelableTask* task = new NotifyWebMediaPlayerTask(this, method);
+ CancelableTask* task = new NotifyWebMediaPlayerClientTask(this, method);
tasks_[index] = task;
main_loop_->PostTask(FROM_HERE, task);
}
diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h
index 0971125..d8a365c 100644
--- a/webkit/glue/webmediaplayer_impl.h
+++ b/webkit/glue/webmediaplayer_impl.h
@@ -85,8 +85,7 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer,
// 2. FFmpeg audio decoder
// 3. FFmpeg video decoder
// 4. Video renderer
- // 5. Simple data source
- // 6. Null audio renderer
+ // 5. Null audio renderer
// The video renderer provided by this class is using the graphics context
// provided by WebKit to perform renderering. The simple data source does
// resource loading by loading the whole resource object into memory. Null
diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp
index ec42d92..c57a376 100644
--- a/webkit/tools/test_shell/test_shell.gyp
+++ b/webkit/tools/test_shell/test_shell.gyp
@@ -460,6 +460,7 @@
'../../glue/dom_serializer_unittest.cc',
'../../glue/glue_serialize_unittest.cc',
'../../glue/iframe_redirect_unittest.cc',
+ '../../glue/media/media_resource_loader_bridge_factory_unittest.cc',
'../../glue/mimetype_unittest.cc',
'../../glue/multipart_response_delegate_unittest.cc',
'../../glue/password_autocomplete_listener_unittest.cc',
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index be1f75a..91aa19b 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -14,6 +14,7 @@
#include "base/gfx/point.h"
#include "base/gfx/native_widget_types.h"
#include "base/message_loop.h"
+#include "base/process_util.h"
#include "base/string_util.h"
#include "base/trace_event.h"
#include "net/base/net_errors.h"
@@ -25,6 +26,9 @@
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebURLError.h"
#include "webkit/api/public/WebURLRequest.h"
+#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
+#include "webkit/glue/media/simple_data_source.h"
+#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webframe.h"
#include "webkit/glue/webpreferences.h"
@@ -124,8 +128,22 @@ WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview,
WebKit::WebMediaPlayer* TestWebViewDelegate::CreateWebMediaPlayer(
WebKit::WebMediaPlayerClient* client) {
- return new webkit_glue::WebMediaPlayerImpl(
- client, new media::FilterFactoryCollection());
+ scoped_refptr<media::FilterFactoryCollection> factory =
+ new media::FilterFactoryCollection();
+
+ // TODO(hclam): this is the same piece of code as in RenderView, maybe they
+ // should be grouped together.
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory =
+ new webkit_glue::MediaResourceLoaderBridgeFactory(
+ GURL::EmptyGURL(), // referrer
+ "null", // frame origin
+ "null", // main_frame_origin
+ base::GetCurrentProcId(),
+ WebAppCacheContext::kNoAppCacheContextId,
+ 0);
+ factory->AddFactory(webkit_glue::SimpleDataSource::CreateFactory(
+ MessageLoop::current(), bridge_factory));
+ return new webkit_glue::WebMediaPlayerImpl(client, factory);
}
WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) {
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index e7b3dfe..9e97cad 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -4447,6 +4447,8 @@
'glue/devtools/dom_agent_impl.cc',
'glue/devtools/dom_agent_impl.h',
'glue/devtools/tools_agent.h',
+ 'glue/media/media_resource_loader_bridge_factory.cc',
+ 'glue/media/media_resource_loader_bridge_factory.h',
'glue/media/simple_data_source.cc',
'glue/media/simple_data_source.h',
'glue/media/video_renderer_impl.cc',