Commit d926e7ff authored by zmo@chromium.org's avatar zmo@chromium.org

Revert 169465 "Move deferred loading logic from WebMediaPlayerCl..."

Android builders fail compile

One exampel: http://chromegw.corp.google.com/i/chromium.webkit/builders/Android%20Builder/builds/36609

> Move deferred loading logic from WebMediaPlayerClientImpl to HTMLMediaElement.
> 
> BUG=350571
> TEST=All layout tests still pass.
> 
> Review URL: https://codereview.chromium.org/192013002

TBR=acolwell@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169470 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 45765bc8
......@@ -84,7 +84,6 @@
using namespace std;
using blink::WebInbandTextTrack;
using blink::WebMediaPlayer;
using blink::WebMimeRegistry;
namespace WebCore {
......@@ -274,7 +273,6 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
, m_closedCaptionsVisible(false)
, m_completelyLoaded(false)
, m_havePreparedToPlay(false)
, m_delayingLoadForPreloadNone(false)
, m_tracksAreReady(true)
, m_haveVisibleTextTrack(false)
, m_processingPreferenceChange(false)
......@@ -415,7 +413,7 @@ void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr
// The attribute must be ignored if the autoplay attribute is present
if (!autoplay() && m_player)
setPlayerPreload();
m_player->setPreload(m_preload);
} else if (name == mediagroupAttr)
setMediaGroup(value);
......@@ -831,13 +829,15 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
WTF_LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLoggingMedia(m_currentSrc).utf8().data());
blink::WebMediaPlayer::LoadType loadType = blink::WebMediaPlayer::LoadTypeURL;
startProgressEventTimer();
// Reset display mode to force a recalculation of what to show because we are resetting the player.
setDisplayMode(Unknown);
if (!autoplay())
setPlayerPreload();
m_player->setPreload(m_preload);
if (fastHasAttribute(mutedAttr))
m_muted = true;
......@@ -849,11 +849,14 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
if (url.protocolIs(mediaSourceBlobProtocol)) {
if (isMediaStreamURL(url.string())) {
loadType = blink::WebMediaPlayer::LoadTypeMediaStream;
m_userGestureRequiredForPlay = false;
} else {
m_mediaSource = HTMLMediaSource::lookup(url.string());
if (m_mediaSource) {
loadType = blink::WebMediaPlayer::LoadTypeMediaSource;
if (!m_mediaSource->attachToElement(this)) {
// Forget our reference to the MediaSource, so we leave it alone
// while processing remainder of load failure.
......@@ -865,13 +868,7 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
}
if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
ASSERT(!webMediaPlayer());
if (m_preload == MediaPlayer::None) {
m_delayingLoadForPreloadNone = true;
} else {
m_player->load(loadType(), m_currentSrc, corsMode());
}
m_player->load(loadType, url);
} else {
mediaLoadingFailed(MediaPlayer::FormatError);
}
......@@ -884,34 +881,6 @@ void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType, c
renderer()->updateFromElement();
}
void HTMLMediaElement::setPlayerPreload()
{
m_player->setPreload(m_preload);
if (m_delayingLoadForPreloadNone && m_preload != MediaPlayer::None)
startDelayedLoad();
}
void HTMLMediaElement::startDelayedLoad()
{
ASSERT(m_delayingLoadForPreloadNone);
m_delayingLoadForPreloadNone = false;
m_player->load(loadType(), m_currentSrc, corsMode());
}
WebMediaPlayer::LoadType HTMLMediaElement::loadType() const
{
if (m_mediaSource)
return WebMediaPlayer::LoadTypeMediaSource;
if (isMediaStreamURL(m_currentSrc.string()))
return WebMediaPlayer::LoadTypeMediaStream;
return WebMediaPlayer::LoadTypeURL;
}
static bool trackIndexCompare(TextTrack* a,
TextTrack* b)
{
......@@ -1698,9 +1667,7 @@ void HTMLMediaElement::prepareToPlay()
if (m_havePreparedToPlay)
return;
m_havePreparedToPlay = true;
if (m_delayingLoadForPreloadNone)
startDelayedLoad();
m_player->prepareToPlay();
}
void HTMLMediaElement::seek(double time, ExceptionState& exceptionState)
......@@ -3152,8 +3119,6 @@ void HTMLMediaElement::clearMediaPlayer(int flags)
closeMediaSource();
m_delayingLoadForPreloadNone = false;
clearMediaPlayerAndAudioSourceProviderClient();
stopPeriodicTimers();
......@@ -3614,14 +3579,14 @@ void HTMLMediaElement::applyMediaFragmentURI()
}
}
WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const
{
const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
if (crossOriginMode.isNull())
return WebMediaPlayer::CORSModeUnspecified;
return Unspecified;
if (equalIgnoringCase(crossOriginMode, "use-credentials"))
return WebMediaPlayer::CORSModeUseCredentials;
return WebMediaPlayer::CORSModeAnonymous;
return UseCredentials;
return Anonymous;
}
void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer)
......
......@@ -326,6 +326,9 @@ private:
virtual void mediaPlayerRequestSeek(double) OVERRIDE FINAL;
virtual void mediaPlayerRepaint() OVERRIDE FINAL;
virtual void mediaPlayerSizeChanged() OVERRIDE FINAL;
virtual CORSMode mediaPlayerCORSMode() const OVERRIDE FINAL;
virtual void mediaPlayerSetWebLayer(blink::WebLayer*) OVERRIDE FINAL;
virtual void mediaPlayerSetOpaque(bool) OVERRIDE FINAL;
virtual void mediaPlayerMediaSourceOpened(blink::WebMediaSource*) OVERRIDE FINAL;
......@@ -350,9 +353,6 @@ private:
void loadInternal();
void selectMediaResource();
void loadResource(const KURL&, ContentType&, const String& keySystem);
void setPlayerPreload();
void startDelayedLoad();
blink::WebMediaPlayer::LoadType loadType() const;
void scheduleNextSourceChild();
void loadNextSourceChild();
void userCancelledLoad();
......@@ -414,8 +414,6 @@ private:
bool isBlockedOnMediaController() const;
bool isAutoplaying() const { return m_autoplaying; }
blink::WebMediaPlayer::CORSMode corsMode() const;
Timer<HTMLMediaElement> m_loadTimer;
Timer<HTMLMediaElement> m_progressEventTimer;
Timer<HTMLMediaElement> m_playbackProgressTimer;
......@@ -494,7 +492,6 @@ private:
bool m_completelyLoaded : 1;
bool m_havePreparedToPlay : 1;
bool m_delayingLoadForPreloadNone : 1;
bool m_tracksAreReady : 1;
bool m_haveVisibleTextTrack : 1;
......
......@@ -58,6 +58,8 @@ typedef int GC3Dint;
class MediaPlayerClient {
public:
enum CORSMode { Unspecified, Anonymous, UseCredentials };
virtual ~MediaPlayerClient() { }
// the network state has changed
......@@ -90,6 +92,8 @@ public:
// the movie size has changed
virtual void mediaPlayerSizeChanged() = 0;
virtual CORSMode mediaPlayerCORSMode() const = 0;
virtual void mediaPlayerSetWebLayer(blink::WebLayer*) = 0;
virtual void mediaPlayerSetOpaque(bool) = 0;
......@@ -112,7 +116,9 @@ public:
MediaPlayer() { }
virtual ~MediaPlayer() { }
virtual void load(blink::WebMediaPlayer::LoadType, const String& url, blink::WebMediaPlayer::CORSMode) = 0;
virtual void load(blink::WebMediaPlayer::LoadType, const String& url) = 0;
virtual void prepareToPlay() = 0;
virtual void play() = 0;
virtual void pause() = 0;
......
......@@ -575,6 +575,10 @@ COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_0_9, ResourceResponse::HTTP_0_
COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_0, ResourceResponse::HTTP_1_0);
COMPILE_ASSERT_MATCHING_ENUM(WebURLResponse::HTTP_1_1, ResourceResponse::HTTP_1_1);
COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUnspecified, MediaPlayerClient::Unspecified);
COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeAnonymous, MediaPlayerClient::Anonymous);
COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayerClient::UseCredentials);
COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultSuccess, HTMLFormElement::AutocompleteResultSuccess);
COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorDisabled, HTMLFormElement::AutocompleteResultErrorDisabled);
COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultErrorCancel, HTMLFormElement::AutocompleteResultErrorCancel);
......
......@@ -178,9 +178,27 @@ void WebMediaPlayerClientImpl::requestSeek(double time)
}
// MediaPlayer -------------------------------------------------
void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF::String& url, WebMediaPlayer::CORSMode corsMode)
void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF::String& url)
{
ASSERT(!m_webMediaPlayer);
m_url = KURL(ParsedURLString, url);
m_loadType = loadType;
if (m_preload == MediaPlayer::None) {
#if ENABLE(WEB_AUDIO)
m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
#endif
m_webMediaPlayer.clear();
m_delayingLoad = true;
} else
loadInternal();
}
void WebMediaPlayerClientImpl::loadInternal()
{
#if ENABLE(WEB_AUDIO)
m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
#endif
// FIXME: Remove this cast
LocalFrame* frame = mediaElement().document().frame();
......@@ -193,23 +211,24 @@ void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF
// if necessary.
m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceleratedCompositing();
KURL kurl(ParsedURLString, url);
m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame);
if (!m_webMediaPlayer)
return;
m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
if (m_webMediaPlayer) {
#if ENABLE(WEB_AUDIO)
// Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
// Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
#endif
m_webMediaPlayer->setVolume(mediaElement().playerVolume());
m_webMediaPlayer->setVolume(mediaElement().playerVolume());
m_webMediaPlayer->setPoster(poster);
// Tell WebMediaPlayer about the poster image URL.
m_webMediaPlayer->setPoster(poster);
// Tell WebMediaPlayer about any connected CDM (may be null).
m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia::contentDecryptionModule(mediaElement()));
m_webMediaPlayer->load(loadType, kurl, corsMode);
// Tell WebMediaPlayer about any connected CDM (may be null).
m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia::contentDecryptionModule(mediaElement()));
WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode>(m_client->mediaPlayerCORSMode());
m_webMediaPlayer->load(m_loadType, m_url, corsMode);
}
}
void WebMediaPlayerClientImpl::play()
......@@ -241,6 +260,12 @@ bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const
return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen();
}
void WebMediaPlayerClientImpl::prepareToPlay()
{
if (m_delayingLoad)
startDelayedLoad();
}
IntSize WebMediaPlayerClientImpl::naturalSize() const
{
if (m_webMediaPlayer)
......@@ -389,6 +414,9 @@ void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload)
if (m_webMediaPlayer)
m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preload));
if (m_delayingLoad && m_preload != MediaPlayer::None)
startDelayedLoad();
}
bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const
......@@ -501,11 +529,23 @@ void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context,
}
#endif
void WebMediaPlayerClientImpl::startDelayedLoad()
{
ASSERT(m_delayingLoad);
ASSERT(!m_webMediaPlayer);
m_delayingLoad = false;
loadInternal();
}
WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client)
: m_client(client)
, m_delayingLoad(false)
, m_preload(MediaPlayer::Auto)
, m_needsWebLayerForVideo(false)
, m_rate(1.0)
, m_loadType(WebMediaPlayer::LoadTypeURL)
{
ASSERT(m_client);
}
......
......@@ -95,9 +95,10 @@ public:
// MediaPlayer methods:
virtual WebMediaPlayer* webMediaPlayer() const OVERRIDE;
virtual void load(WebMediaPlayer::LoadType, const WTF::String& url, WebMediaPlayer::CORSMode) OVERRIDE;
virtual void load(WebMediaPlayer::LoadType, const WTF::String& url) OVERRIDE;
virtual void play() OVERRIDE;
virtual void pause() OVERRIDE;
virtual void prepareToPlay() OVERRIDE;
virtual bool supportsSave() const OVERRIDE;
virtual WebCore::IntSize naturalSize() const OVERRIDE;
virtual bool hasVideo() const OVERRIDE;
......@@ -137,6 +138,9 @@ public:
private:
explicit WebMediaPlayerClientImpl(WebCore::MediaPlayerClient*);
void startDelayedLoad();
void loadInternal();
WebCore::HTMLMediaElement& mediaElement() const;
#if OS(ANDROID)
......@@ -149,6 +153,8 @@ private:
WebCore::MediaPlayerClient* m_client;
OwnPtr<WebMediaPlayer> m_webMediaPlayer;
WebCore::KURL m_url;
bool m_delayingLoad;
WebCore::MediaPlayer::Preload m_preload;
bool m_needsWebLayerForVideo;
double m_rate;
......@@ -200,6 +206,8 @@ private:
AudioSourceProviderImpl m_audioSourceProvider;
#endif
WebMediaPlayer::LoadType m_loadType;
};
} // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment