summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-01 12:19:54 +0000
committerIain Merrick <husky@google.com>2010-11-03 10:21:10 +0000
commit731df977c0511bca2206b5f333555b1205ff1f43 (patch)
tree0e750b949b3f00a1ac11fda25d3c2de512f2b465 /webkit/glue/media
parent5add15e10e7bb80512f2c597ca57221314abe577 (diff)
downloadexternal_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'webkit/glue/media')
-rw-r--r--webkit/glue/media/buffered_data_source.cc20
-rw-r--r--webkit/glue/media/buffered_data_source.h10
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc76
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory.cc4
-rw-r--r--webkit/glue/media/media_resource_loader_bridge_factory.h5
-rw-r--r--webkit/glue/media/simple_data_source.cc4
-rw-r--r--webkit/glue/media/simple_data_source.h4
-rw-r--r--webkit/glue/media/simple_data_source_unittest.cc2
-rw-r--r--webkit/glue/media/video_renderer_impl.cc8
-rw-r--r--webkit/glue/media/video_renderer_impl.h2
10 files changed, 93 insertions, 42 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc
index f4aad57..3456e3a 100644
--- a/webkit/glue/media/buffered_data_source.cc
+++ b/webkit/glue/media/buffered_data_source.cc
@@ -235,7 +235,7 @@ void BufferedResourceLoader::SetAllowDefer(bool is_allowed) {
// webkit_glue::ResourceLoaderBridge::Peer implementations
bool BufferedResourceLoader::OnReceivedRedirect(
const GURL& new_url,
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies) {
DCHECK(bridge_.get());
@@ -259,7 +259,7 @@ bool BufferedResourceLoader::OnReceivedRedirect(
}
void BufferedResourceLoader::OnReceivedResponse(
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool content_filtered) {
DCHECK(bridge_.get());
@@ -479,7 +479,7 @@ void BufferedResourceLoader::ReadInternal() {
}
bool BufferedResourceLoader::VerifyPartialResponse(
- const ResourceLoaderBridge::ResponseInfo& info) {
+ const ResourceResponseInfo& info) {
int64 first_byte_position, last_byte_position, instance_size;
if (!info.headers->GetContentRange(&first_byte_position,
&last_byte_position,
@@ -560,7 +560,8 @@ BufferedDataSource::BufferedDataSource(
render_loop_(render_loop),
stop_signal_received_(false),
stopped_on_render_loop_(false),
- media_is_paused_(true) {
+ media_is_paused_(true),
+ using_range_request_(true) {
}
BufferedDataSource::~BufferedDataSource() {
@@ -879,6 +880,17 @@ void BufferedDataSource::HttpInitialStartCallback(int error) {
loader_->Stop();
}
+ if (error == net::ERR_INVALID_RESPONSE && using_range_request_) {
+ // Assuming that the Range header was causing the problem. Retry without
+ // the Range header.
+ using_range_request_ = false;
+ loader_ = CreateResourceLoader(-1, -1);
+ loader_->Start(
+ NewCallback(this, &BufferedDataSource::HttpInitialStartCallback),
+ NewCallback(this, &BufferedDataSource::NetworkEventCallback));
+ return;
+ }
+
// We need to prevent calling to filter host and running the callback if
// we have received the stop signal. We need to lock down the whole callback
// method to prevent bad things from happening. The reason behind this is
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h
index b520418..e7b2e47 100644
--- a/webkit/glue/media/buffered_data_source.h
+++ b/webkit/glue/media/buffered_data_source.h
@@ -110,11 +110,11 @@ class BufferedResourceLoader :
virtual void OnUploadProgress(uint64 position, uint64 size) {}
virtual bool OnReceivedRedirect(
const GURL& new_url,
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies);
virtual void OnReceivedResponse(
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool content_filtered);
virtual void OnDownloadedData(int len) {}
virtual void OnReceivedData(const char* data, int len);
@@ -150,7 +150,7 @@ class BufferedResourceLoader :
void ReadInternal();
// If we have made a range request, verify the response from the server.
- bool VerifyPartialResponse(const ResourceLoaderBridge::ResponseInfo& info);
+ bool VerifyPartialResponse(const ResourceResponseInfo& info);
// Done with read. Invokes the read callback and reset parameters for the
// read request.
@@ -406,6 +406,10 @@ class BufferedDataSource : public media::DataSource {
// the message loop doesn't hold a reference for the watch dog task.
base::RepeatingTimer<BufferedDataSource> watch_dog_timer_;
+ // Keeps track of whether we used a Range header in the initialization
+ // request.
+ bool using_range_request_;
+
DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
};
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index 7254c92..f032595 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -29,6 +29,7 @@ using ::testing::NotNull;
using ::testing::Return;
using ::testing::SetArgumentPointee;
using ::testing::StrictMock;
+using ::testing::NiceMock;
using ::testing::WithArgs;
namespace {
@@ -99,7 +100,7 @@ class BufferedResourceLoaderTest : public testing::Test {
void FullResponse(int64 instance_size) {
EXPECT_CALL(*this, StartCallback(net::OK));
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
std::string header = base::StringPrintf("HTTP/1.1 200 OK\n"
"Content-Length: %" PRId64,
instance_size);
@@ -116,7 +117,7 @@ class BufferedResourceLoaderTest : public testing::Test {
int64 instance_size) {
EXPECT_CALL(*this, StartCallback(net::OK));
int64 content_length = last_position - first_position + 1;
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
std::string header = base::StringPrintf("HTTP/1.1 206 Partial Content\n"
"Content-Range: bytes "
"%" PRId64 "-%" PRId64 "/%" PRId64,
@@ -213,7 +214,7 @@ TEST_F(BufferedResourceLoaderTest, MissingHttpHeader) {
EXPECT_CALL(*bridge_, OnDestroy())
.WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
loader_->OnReceivedResponse(info, false);
}
@@ -228,7 +229,7 @@ TEST_F(BufferedResourceLoaderTest, BadHttpResponse) {
EXPECT_CALL(*bridge_, OnDestroy())
.WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
info.headers = new net::HttpResponseHeaders("HTTP/1.1 404 Not Found\n");
loader_->OnReceivedResponse(info, false);
}
@@ -268,7 +269,7 @@ TEST_F(BufferedResourceLoaderTest, InvalidPartialResponse) {
EXPECT_CALL(*bridge_, OnDestroy())
.WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
std::string header = base::StringPrintf("HTTP/1.1 206 Partial Content\n"
"Content-Range: bytes %d-%d/%d",
1, 10, 1024);
@@ -597,6 +598,17 @@ class BufferedDataSourceTest : public testing::Test {
}
}
+ void ExpectCreateAndStartResourceLoader(int start_error) {
+ EXPECT_CALL(*data_source_, CreateResourceLoader(_, _))
+ .WillOnce(Return(loader_.get()));
+
+ EXPECT_CALL(*loader_, Start(NotNull(), NotNull()))
+ .WillOnce(
+ DoAll(Assign(&error_, start_error),
+ Invoke(this,
+ &BufferedDataSourceTest::InvokeStartCallback)));
+ }
+
void InitializeDataSource(const char* url, int error,
bool partial_response, int64 instance_size,
NetworkState networkState) {
@@ -613,21 +625,34 @@ class BufferedDataSourceTest : public testing::Test {
// There is no need to provide a message loop to data source.
data_source_->set_host(&host_);
+ scoped_refptr<NiceMock<MockBufferedResourceLoader> > first_loader =
+ new NiceMock<MockBufferedResourceLoader>();
+
// Creates the mock loader to be injected.
- loader_ = new StrictMock<MockBufferedResourceLoader>();
+ loader_ = first_loader;
+ bool initialized_ok = (error == net::OK);
bool loaded = networkState == LOADED;
{
InSequence s;
- EXPECT_CALL(*data_source_, CreateResourceLoader(_, _))
- .WillOnce(Return(loader_.get()));
-
- // The initial response loader will be started.
- EXPECT_CALL(*loader_, Start(NotNull(), NotNull()))
- .WillOnce(
- DoAll(Assign(&error_, error),
- Invoke(this,
- &BufferedDataSourceTest::InvokeStartCallback)));
+ ExpectCreateAndStartResourceLoader(error);
+
+ // In the case of an invalid partial response we expect a second loader
+ // to be created.
+ if (partial_response && (error == net::ERR_INVALID_RESPONSE)) {
+ // Verify that the initial loader is stopped.
+ EXPECT_CALL(*loader_, Stop());
+
+ // Replace loader_ with a new instance.
+ loader_ = new NiceMock<MockBufferedResourceLoader>();
+
+ // Create and start Make sure Start() is called the new loader.
+ ExpectCreateAndStartResourceLoader(net::OK);
+
+ // Update initialization variable since we know the second loader will
+ // return OK.
+ initialized_ok = true;
+ }
}
StrictMock<media::MockFilterCallback> callback;
@@ -635,7 +660,7 @@ class BufferedDataSourceTest : public testing::Test {
.WillRepeatedly(Return(instance_size));
EXPECT_CALL(*loader_, partial_response())
.WillRepeatedly(Return(partial_response));
- if (error == net::OK) {
+ if (initialized_ok) {
// Expected loaded or not.
EXPECT_CALL(host_, SetLoaded(loaded));
@@ -663,7 +688,7 @@ class BufferedDataSourceTest : public testing::Test {
data_source_->Initialize(url, callback.NewCallback());
message_loop_->RunAllPending();
- if (error == net::OK) {
+ if (initialized_ok) {
// Verify the size of the data source.
int64 size;
if (instance_size != -1 && (loaded || partial_response)) {
@@ -746,8 +771,8 @@ class BufferedDataSourceTest : public testing::Test {
}
// 2. Then the current loader will be stop and destroyed.
- StrictMock<MockBufferedResourceLoader> *new_loader =
- new StrictMock<MockBufferedResourceLoader>();
+ NiceMock<MockBufferedResourceLoader> *new_loader =
+ new NiceMock<MockBufferedResourceLoader>();
EXPECT_CALL(*data_source_, CreateResourceLoader(position, -1))
.WillOnce(Return(new_loader));
@@ -810,8 +835,8 @@ class BufferedDataSourceTest : public testing::Test {
}
// 2. Then the current loader will be stop and destroyed.
- StrictMock<MockBufferedResourceLoader> *new_loader =
- new StrictMock<MockBufferedResourceLoader>();
+ NiceMock<MockBufferedResourceLoader> *new_loader =
+ new NiceMock<MockBufferedResourceLoader>();
EXPECT_CALL(*data_source_, CreateResourceLoader(position, -1))
.WillOnce(Return(new_loader));
@@ -853,7 +878,7 @@ class BufferedDataSourceTest : public testing::Test {
scoped_ptr<StrictMock<MockMediaResourceLoaderBridgeFactory> >
bridge_factory_;
- scoped_refptr<StrictMock<MockBufferedResourceLoader> > loader_;
+ scoped_refptr<NiceMock<MockBufferedResourceLoader> > loader_;
scoped_refptr<MockBufferedDataSource> data_source_;
scoped_refptr<media::FilterFactory> factory_;
@@ -889,6 +914,13 @@ TEST_F(BufferedDataSourceTest, RangeRequestNotSupported) {
StopDataSource();
}
+// Test the case where we get a 206 response, but no Content-Range header.
+TEST_F(BufferedDataSourceTest, MissingContentRange) {
+ InitializeDataSource(kHttpUrl, net::ERR_INVALID_RESPONSE, true, 1024,
+ LOADING);
+ StopDataSource();
+}
+
TEST_F(BufferedDataSourceTest,
MissingContentLengthAndRangeRequestNotSupported) {
InitializeDataSource(kHttpUrl, net::OK, false, -1, LOADING);
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.cc b/webkit/glue/media/media_resource_loader_bridge_factory.cc
index 9d8d547..3fb9d65 100644
--- a/webkit/glue/media/media_resource_loader_bridge_factory.cc
+++ b/webkit/glue/media/media_resource_loader_bridge_factory.cc
@@ -32,6 +32,8 @@ MediaResourceLoaderBridgeFactory::MediaResourceLoaderBridgeFactory(
routing_id_(routing_id) {
}
+MediaResourceLoaderBridgeFactory::~MediaResourceLoaderBridgeFactory() {}
+
ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge(
const GURL& url,
int load_flags,
@@ -54,6 +56,8 @@ ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge(
return webkit_glue::ResourceLoaderBridge::Create(request_info);
}
+MediaResourceLoaderBridgeFactory::MediaResourceLoaderBridgeFactory() {}
+
// static
const std::string MediaResourceLoaderBridgeFactory::GenerateHeaders (
int64 first_byte_position, int64 last_byte_position) {
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.h b/webkit/glue/media/media_resource_loader_bridge_factory.h
index 5f09235..ccacdc6 100644
--- a/webkit/glue/media/media_resource_loader_bridge_factory.h
+++ b/webkit/glue/media/media_resource_loader_bridge_factory.h
@@ -24,7 +24,7 @@ class MediaResourceLoaderBridgeFactory {
int appcache_host_id,
int32 routing_id);
- virtual ~MediaResourceLoaderBridgeFactory() {}
+ virtual ~MediaResourceLoaderBridgeFactory();
// Factory method to create a ResourceLoaderBridge with the following
// parameters:
@@ -40,8 +40,7 @@ class MediaResourceLoaderBridgeFactory {
protected:
// An empty constructor only used by inherited classes.
- MediaResourceLoaderBridgeFactory() {
- }
+ MediaResourceLoaderBridgeFactory();
private:
FRIEND_TEST_ALL_PREFIXES(MediaResourceLoaderBridgeFactoryTest,
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 56deaeb..0b09edf 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -122,7 +122,7 @@ bool SimpleDataSource::IsStreaming() {
bool SimpleDataSource::OnReceivedRedirect(
const GURL& new_url,
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies) {
SetURL(new_url);
@@ -132,7 +132,7 @@ bool SimpleDataSource::OnReceivedRedirect(
}
void SimpleDataSource::OnReceivedResponse(
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool content_filtered) {
size_ = info.content_length;
}
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index d238f61..d649c0d 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -54,11 +54,11 @@ class SimpleDataSource : public media::DataSource,
virtual void OnUploadProgress(uint64 position, uint64 size) {}
virtual bool OnReceivedRedirect(
const GURL& new_url,
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool* has_new_first_party_for_cookies,
GURL* new_first_party_for_cookies);
virtual void OnReceivedResponse(
- const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
+ const webkit_glue::ResourceResponseInfo& info,
bool content_filtered);
virtual void OnDownloadedData(int len) {}
virtual void OnReceivedData(const char* data, int len);
diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc
index d05bb72..50c8910 100644
--- a/webkit/glue/media/simple_data_source_unittest.cc
+++ b/webkit/glue/media/simple_data_source_unittest.cc
@@ -81,7 +81,7 @@ class SimpleDataSourceTest : public testing::Test {
}
void RequestSucceeded(bool is_loaded) {
- ResourceLoaderBridge::ResponseInfo info;
+ ResourceResponseInfo info;
info.content_length = kDataSize;
data_source_->OnReceivedResponse(info, false);
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc
index 6d7323d..16c9ef6 100644
--- a/webkit/glue/media/video_renderer_impl.cc
+++ b/webkit/glue/media/video_renderer_impl.cc
@@ -20,6 +20,8 @@ VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy,
proxy_->SetVideoRenderer(this);
}
+VideoRendererImpl::~VideoRendererImpl() {}
+
// static
media::FilterFactory* VideoRendererImpl::CreateFactory(
WebMediaPlayerImpl::Proxy* proxy,
@@ -86,10 +88,8 @@ void VideoRendererImpl::Paint(skia::PlatformCanvas* canvas,
// on low-end devices. When profiled on an Intel Atom N280 @ 1.66GHz this
// code had a ~63 microsecond perf hit when logging to a file (not stdout),
// which is neglible enough for measuring playback performance.
- if (pts_logging_) {
- LOG(INFO) << "pts="
- << video_frame->GetTimestamp().InMicroseconds();
- }
+ if (pts_logging_)
+ VLOG(1) << "pts=" << video_frame->GetTimestamp().InMicroseconds();
}
PutCurrentFrame(video_frame);
diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h
index 39ce1b2..38e8851 100644
--- a/webkit/glue/media/video_renderer_impl.h
+++ b/webkit/glue/media/video_renderer_impl.h
@@ -73,7 +73,7 @@ class VideoRendererImpl : public WebVideoRenderer {
WebMediaPlayerImpl::Proxy*,
bool>;
VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy, bool pts_logging);
- virtual ~VideoRendererImpl() {}
+ virtual ~VideoRendererImpl();
// Determine the conditions to perform fast paint. Returns true if we can do
// fast paint otherwise false.