diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/media/buffered_data_source.cc | 12 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source.h | 7 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source_unittest.cc | 14 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source.cc | 21 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source.h | 8 | ||||
-rw-r--r-- | webkit/glue/media/web_data_source.h | 5 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 23 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.h | 8 |
8 files changed, 79 insertions, 19 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 43d21f7..f97e7b5 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -529,6 +529,7 @@ BufferedDataSource::BufferedDataSource( : total_bytes_(kPositionNotSpecified), loaded_(false), streaming_(false), + single_origin_(true), bridge_factory_(bridge_factory), loader_(NULL), network_activity_(false), @@ -646,6 +647,11 @@ bool BufferedDataSource::IsStreaming() { return streaming_; } +bool BufferedDataSource::HasSingleOrigin() { + DCHECK(MessageLoop::current() == render_loop_); + return single_origin_; +} + void BufferedDataSource::Abort() { DCHECK(MessageLoop::current() == render_loop_); @@ -873,6 +879,9 @@ void BufferedDataSource::HttpInitialStartCallback(int error) { DCHECK(MessageLoop::current() == render_loop_); DCHECK(loader_.get()); + // Check if the request ended up at a different origin via redirect. + single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin(); + int64 instance_size = loader_->instance_size(); bool partial_response = loader_->partial_response(); bool success = error == net::OK; @@ -937,6 +946,9 @@ void BufferedDataSource::NonHttpInitialStartCallback(int error) { DCHECK(MessageLoop::current() == render_loop_); DCHECK(loader_.get()); + // Check if the request ended up at a different origin via redirect. + single_origin_ = url_.GetOrigin() == loader_->url().GetOrigin(); + int64 instance_size = loader_->instance_size(); bool success = error == net::OK && instance_size != kPositionNotSpecified; diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index dfb78d5..2af9e84 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -106,6 +106,9 @@ class BufferedResourceLoader : // Returns true if network is currently active. virtual bool network_activity() { return !completed_ && !deferred_; } + // Returns resulting URL. + virtual const GURL& url() { return url_; } + ///////////////////////////////////////////////////////////////////////////// // webkit_glue::ResourceLoaderBridge::Peer implementations. virtual void OnUploadProgress(uint64 position, uint64 size) {} @@ -240,6 +243,7 @@ class BufferedDataSource : public WebDataSource { } // webkit_glue::WebDataSource implementation. + virtual bool HasSingleOrigin(); virtual void Abort(); protected: @@ -334,6 +338,9 @@ class BufferedDataSource : public WebDataSource { // i.e. range request is not supported. bool streaming_; + // True if the media resource has a single origin. + bool single_origin_; + // A factory object to produce ResourceLoaderBridge. scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_; diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc index d41bbe2..929d8d9 100644 --- a/webkit/glue/media/buffered_data_source_unittest.cc +++ b/webkit/glue/media/buffered_data_source_unittest.cc @@ -27,6 +27,7 @@ using ::testing::Invoke; using ::testing::InvokeWithoutArgs; using ::testing::NotNull; using ::testing::Return; +using ::testing::ReturnRef; using ::testing::SetArgumentPointee; using ::testing::StrictMock; using ::testing::NiceMock; @@ -525,6 +526,7 @@ class MockBufferedResourceLoader : public BufferedResourceLoader { MOCK_METHOD0(instance_size, int64()); MOCK_METHOD0(partial_response, bool()); MOCK_METHOD0(network_activity, bool()); + MOCK_METHOD0(url, const GURL&()); MOCK_METHOD0(GetBufferedFirstBytePosition, int64()); MOCK_METHOD0(GetBufferedLastBytePosition, int64()); @@ -622,6 +624,8 @@ class BufferedDataSourceTest : public testing::Test { // to be created. if (partial_response && (error == net::ERR_INVALID_RESPONSE)) { // Verify that the initial loader is stopped. + EXPECT_CALL(*loader_, url()) + .WillRepeatedly(ReturnRef(gurl_)); EXPECT_CALL(*loader_, Stop()); // Replace loader_ with a new instance. @@ -642,10 +646,12 @@ class BufferedDataSourceTest : public testing::Test { .WillByDefault(DeleteArg<3>()); StrictMock<media::MockFilterCallback> callback; - EXPECT_CALL(*loader_, instance_size()) - .WillRepeatedly(Return(instance_size)); - EXPECT_CALL(*loader_, partial_response()) - .WillRepeatedly(Return(partial_response)); + ON_CALL(*loader_, instance_size()) + .WillByDefault(Return(instance_size)); + ON_CALL(*loader_, partial_response()) + .WillByDefault(Return(partial_response)); + ON_CALL(*loader_, url()) + .WillByDefault(ReturnRef(gurl_)); if (initialized_ok) { // Expected loaded or not. EXPECT_CALL(host_, SetLoaded(loaded)); diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc index d5a4c3b..291928e 100644 --- a/webkit/glue/media/simple_data_source.cc +++ b/webkit/glue/media/simple_data_source.cc @@ -34,6 +34,7 @@ SimpleDataSource::SimpleDataSource( : render_loop_(render_loop), bridge_factory_(bridge_factory), size_(-1), + single_origin_(true), state_(UNINITIALIZED) { DCHECK(render_loop); } @@ -112,7 +113,9 @@ bool SimpleDataSource::OnReceivedRedirect( const webkit_glue::ResourceResponseInfo& info, bool* has_new_first_party_for_cookies, GURL* new_first_party_for_cookies) { - SetURL(new_url); + DCHECK(MessageLoop::current() == render_loop_); + single_origin_ = url_.GetOrigin() == new_url.GetOrigin(); + // TODO(wtc): should we return a new first party for cookies URL? *has_new_first_party_for_cookies = false; return true; @@ -121,16 +124,19 @@ bool SimpleDataSource::OnReceivedRedirect( void SimpleDataSource::OnReceivedResponse( const webkit_glue::ResourceResponseInfo& info, bool content_filtered) { + DCHECK(MessageLoop::current() == render_loop_); size_ = info.content_length; } void SimpleDataSource::OnReceivedData(const char* data, int len) { + DCHECK(MessageLoop::current() == render_loop_); data_.append(data, len); } void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status, const std::string& security_info, const base::Time& completion_time) { + DCHECK(MessageLoop::current() == render_loop_); AutoLock auto_lock(lock_); // It's possible this gets called after Stop(), in which case |host_| is no // longer valid. @@ -151,6 +157,16 @@ void SimpleDataSource::OnCompletedRequest(const URLRequestStatus& status, DoneInitialization_Locked(status.is_success()); } +bool SimpleDataSource::HasSingleOrigin() { + DCHECK(MessageLoop::current() == render_loop_); + return single_origin_; +} + +void SimpleDataSource::Abort() { + DCHECK(MessageLoop::current() == render_loop_); + NOTIMPLEMENTED(); +} + void SimpleDataSource::SetURL(const GURL& url) { url_ = url; media_format_.Clear(); @@ -160,8 +176,8 @@ void SimpleDataSource::SetURL(const GURL& url) { } void SimpleDataSource::StartTask() { - AutoLock auto_lock(lock_); DCHECK(MessageLoop::current() == render_loop_); + AutoLock auto_lock(lock_); // We may have stopped. if (state_ == STOPPED) @@ -186,6 +202,7 @@ void SimpleDataSource::StartTask() { } void SimpleDataSource::CancelTask() { + DCHECK(MessageLoop::current() == render_loop_); AutoLock auto_lock(lock_); DCHECK_EQ(state_, STOPPED); diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h index f264b8c..ff1e247 100644 --- a/webkit/glue/media/simple_data_source.h +++ b/webkit/glue/media/simple_data_source.h @@ -14,13 +14,14 @@ #include "base/scoped_ptr.h" #include "media/base/filters.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" +#include "webkit/glue/media/web_data_source.h" class MessageLoop; class WebMediaPlayerDelegateImpl; namespace webkit_glue { -class SimpleDataSource : public media::DataSource, +class SimpleDataSource : public WebDataSource, public webkit_glue::ResourceLoaderBridge::Peer { public: SimpleDataSource( @@ -56,6 +57,10 @@ class SimpleDataSource : public media::DataSource, const std::string& security_info, const base::Time& completion_time); + // webkit_glue::WebDataSource implementation. + virtual bool HasSingleOrigin(); + virtual void Abort(); + private: // Updates |url_| and |media_format_| with the given URL. void SetURL(const GURL& url); @@ -82,6 +87,7 @@ class SimpleDataSource : public media::DataSource, GURL url_; std::string data_; int64 size_; + bool single_origin_; // Simple state tracking variable. enum State { diff --git a/webkit/glue/media/web_data_source.h b/webkit/glue/media/web_data_source.h index 2bbfd1c..956ac9e 100644 --- a/webkit/glue/media/web_data_source.h +++ b/webkit/glue/media/web_data_source.h @@ -16,6 +16,11 @@ class WebDataSource : public media::DataSource { WebDataSource(); virtual ~WebDataSource(); + // Returns true if the media resource has a single origin, false otherwise. + // + // Method called on the render thread. + virtual bool HasSingleOrigin() = 0; + // This method is used to unblock any read calls that would cause the // media pipeline to stall. // diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index 3337c5d..d49e732 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -88,16 +88,16 @@ void WebMediaPlayerImpl::Proxy::Repaint() { } } -void WebMediaPlayerImpl::Proxy::SetDataSource( - scoped_refptr<WebDataSource> data_source) { - data_source_ = data_source; -} - void WebMediaPlayerImpl::Proxy::SetVideoRenderer( scoped_refptr<WebVideoRenderer> video_renderer) { video_renderer_ = video_renderer; } +void WebMediaPlayerImpl::Proxy::SetDataSource( + scoped_refptr<WebDataSource> data_source) { + data_source_ = data_source; +} + void WebMediaPlayerImpl::Proxy::Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect) { DCHECK(MessageLoop::current() == render_loop_); @@ -113,6 +113,14 @@ void WebMediaPlayerImpl::Proxy::SetSize(const gfx::Rect& rect) { } } +bool WebMediaPlayerImpl::Proxy::HasSingleOrigin() { + DCHECK(MessageLoop::current() == render_loop_); + if (data_source_) { + return data_source_->HasSingleOrigin(); + } + return true; +} + void WebMediaPlayerImpl::Proxy::AbortDataSource() { DCHECK(MessageLoop::current() == render_loop_); if (data_source_) { @@ -597,9 +605,8 @@ void WebMediaPlayerImpl::paint(WebCanvas* canvas, } bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { - // TODO(scherkus): we'll need to do something smarter here if/when we start to - // support formats that contain references to external resources (i.e., MP4s - // containing links to other MP4s). See http://crbug.com/25432 + if (proxy_) + return proxy_->HasSingleOrigin(); return true; } diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h index 003d0b9..f1860f4 100644 --- a/webkit/glue/webmediaplayer_impl.h +++ b/webkit/glue/webmediaplayer_impl.h @@ -90,21 +90,21 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, Proxy(MessageLoop* render_loop, WebMediaPlayerImpl* webmediaplayer); - // Public methods called from the video renderer. + // Methods for MediaFilter -> WebMediaPlayerImpl communication. void Repaint(); void SetVideoRenderer(scoped_refptr<WebVideoRenderer> video_renderer); void SetDataSource(scoped_refptr<WebDataSource> data_source); - // Public methods called from WebMediaPlayerImpl. + // Methods for WebMediaPlayerImpl -> MediaFilter communication. void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); void SetSize(const gfx::Rect& rect); void Detach(); void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out); void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame); + bool HasSingleOrigin(); void AbortDataSource(); - // Public methods called from the pipeline via callback issued by - // WebMediaPlayerImpl. + // Methods for PipelineImpl -> WebMediaPlayerImpl communication. void PipelineInitializationCallback(); void PipelineSeekCallback(); void PipelineEndedCallback(); |