Skip to content

Commit

Permalink
Non-const impls. for WebMediaPlayer::didLoadingProgress().
Browse files Browse the repository at this point in the history
This provides non-const didLoadingProgress() implementations for WebMediaPlayer subclasses in Chromium so that the interface can switch to being non-const. It also removes the const specifier from DidLoadingProgress() implementations (Pipeline and DemuxerHost) and the mutable specifier for their associated properties.

This is the first of three changes; the second is
https://codereview.chromium.org/272223004.

BUG=360251

Review URL: https://codereview.chromium.org/275303002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269910 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sandersd@chromium.org committed May 12, 2014
1 parent fd99cdd commit 5d2b3e4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 10 deletions.
4 changes: 4 additions & 0 deletions content/renderer/media/android/webmediaplayer_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ double WebMediaPlayerAndroid::maxTimeSeekable() const {
}

bool WebMediaPlayerAndroid::didLoadingProgress() const {
return const_cast<WebMediaPlayerAndroid*>(this)->didLoadingProgress();
}

bool WebMediaPlayerAndroid::didLoadingProgress() {
bool ret = did_loading_progress_;
did_loading_progress_ = false;
return ret;
Expand Down
5 changes: 4 additions & 1 deletion content/renderer/media/android/webmediaplayer_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ class WebMediaPlayerAndroid : public blink::WebMediaPlayer,
virtual double timelineOffset() const;
virtual double currentTime() const;

// TODO(sandersd): Remove const version.
// http://crbug.com/360251
virtual bool didLoadingProgress() const;
virtual bool didLoadingProgress();

// Internal states of loading and network.
virtual blink::WebMediaPlayer::NetworkState networkState() const;
Expand Down Expand Up @@ -331,7 +334,7 @@ class WebMediaPlayerAndroid : public blink::WebMediaPlayer,
base::TimeDelta seek_time_;

// Whether loading has progressed since the last call to didLoadingProgress.
mutable bool did_loading_progress_;
bool did_loading_progress_;

// Manager for managing this object and for delegating method calls on
// Render Thread.
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/media/buffered_data_source_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void BufferedDataSourceHostImpl::AddBufferedTimeRanges(
}
}

bool BufferedDataSourceHostImpl::DidLoadingProgress() const {
bool BufferedDataSourceHostImpl::DidLoadingProgress() {
bool ret = did_loading_progress_;
did_loading_progress_ = false;
return ret;
Expand Down
6 changes: 2 additions & 4 deletions content/renderer/media/buffered_data_source_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class CONTENT_EXPORT BufferedDataSourceHostImpl
media::Ranges<base::TimeDelta>* buffered_time_ranges,
base::TimeDelta media_duration);

// TODO(sandersd): Change this to non-const along with Pipeline's version.
// http://crbug.com/360251
bool DidLoadingProgress() const;
bool DidLoadingProgress();

private:
// Total size of the data source.
Expand All @@ -42,7 +40,7 @@ class CONTENT_EXPORT BufferedDataSourceHostImpl

// True when AddBufferedByteRange() has been called more recently than
// DidLoadingProgress().
mutable bool did_loading_progress_;
bool did_loading_progress_;

DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImpl);
};
Expand Down
4 changes: 4 additions & 0 deletions content/renderer/media/webmediaplayer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ double WebMediaPlayerImpl::maxTimeSeekable() const {
}

bool WebMediaPlayerImpl::didLoadingProgress() const {
return const_cast<WebMediaPlayerImpl*>(this)->didLoadingProgress();
}

bool WebMediaPlayerImpl::didLoadingProgress() {
DCHECK(main_loop_->BelongsToCurrentThread());
bool pipeline_progress = pipeline_.DidLoadingProgress();
bool data_progress = buffered_data_source_host_.DidLoadingProgress();
Expand Down
3 changes: 2 additions & 1 deletion content/renderer/media/webmediaplayer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ class WebMediaPlayerImpl
virtual blink::WebMediaPlayer::NetworkState networkState() const;
virtual blink::WebMediaPlayer::ReadyState readyState() const;

// TODO(sandersd): Change this to non-const in blink::WebMediaPlayer.
// TODO(sandersd): Remove const version.
// http://crbug.com/360251
virtual bool didLoadingProgress() const;
virtual bool didLoadingProgress();

virtual bool hasSingleSecurityOrigin() const;
virtual bool didPassCORSAccessCheck() const;
Expand Down
5 changes: 5 additions & 0 deletions content/renderer/media/webmediaplayer_ms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ bool WebMediaPlayerMS::didLoadingProgress() const {
return true;
}

bool WebMediaPlayerMS::didLoadingProgress() {
DCHECK(thread_checker_.CalledOnValidThread());
return true;
}

void WebMediaPlayerMS::paint(WebCanvas* canvas,
const WebRect& rect,
unsigned char alpha) {
Expand Down
3 changes: 3 additions & 0 deletions content/renderer/media/webmediaplayer_ms.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class WebMediaPlayerMS
virtual blink::WebMediaPlayer::NetworkState networkState() const;
virtual blink::WebMediaPlayer::ReadyState readyState() const;

// TODO(sandersd): Remove const version.
// http://crbug.com/360251
virtual bool didLoadingProgress() const;
virtual bool didLoadingProgress();

virtual bool hasSingleSecurityOrigin() const;
virtual bool didPassCORSAccessCheck() const;
Expand Down
2 changes: 1 addition & 1 deletion media/base/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TimeDelta Pipeline::GetMediaDuration() const {
return clock_->Duration();
}

bool Pipeline::DidLoadingProgress() const {
bool Pipeline::DidLoadingProgress() {
base::AutoLock auto_lock(lock_);
bool ret = did_loading_progress_;
did_loading_progress_ = false;
Expand Down
4 changes: 2 additions & 2 deletions media/base/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class MEDIA_EXPORT Pipeline : public DemuxerHost {

// Return true if loading progress has been made since the last time this
// method was called.
bool DidLoadingProgress() const;
bool DidLoadingProgress();

// Gets the current pipeline statistics.
PipelineStatistics GetStatistics() const;
Expand Down Expand Up @@ -345,7 +345,7 @@ class MEDIA_EXPORT Pipeline : public DemuxerHost {

// True when AddBufferedTimeRange() has been called more recently than
// DidLoadingProgress().
mutable bool did_loading_progress_;
bool did_loading_progress_;

// Current volume level (from 0.0f to 1.0f). This value is set immediately
// via SetVolume() and a task is dispatched on the task runner to notify the
Expand Down

0 comments on commit 5d2b3e4

Please sign in to comment.