Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: Source/WebCore/html/HTMLMediaElement.cpp

Issue 11275156: Merge 133252 - HTMLMediaPlayer should free m_player when src is set/changed (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 bool HTMLMediaElement::isMouseFocusable() const 357 bool HTMLMediaElement::isMouseFocusable() const
358 { 358 {
359 return false; 359 return false;
360 } 360 }
361 361
362 void HTMLMediaElement::parseAttribute(const Attribute& attribute) 362 void HTMLMediaElement::parseAttribute(const Attribute& attribute)
363 { 363 {
364 if (attribute.name() == srcAttr) { 364 if (attribute.name() == srcAttr) {
365 // Trigger a reload, as long as the 'src' attribute is present. 365 // Trigger a reload, as long as the 'src' attribute is present.
366 if (fastHasAttribute(srcAttr)) 366 if (fastHasAttribute(srcAttr)) {
367 clearMediaPlayer(MediaResource);
367 scheduleLoad(MediaResource); 368 scheduleLoad(MediaResource);
369 }
368 } else if (attribute.name() == controlsAttr) 370 } else if (attribute.name() == controlsAttr)
369 configureMediaControls(); 371 configureMediaControls();
370 #if PLATFORM(MAC) 372 #if PLATFORM(MAC)
371 else if (attribute.name() == loopAttr) 373 else if (attribute.name() == loopAttr)
372 updateDisableSleep(); 374 updateDisableSleep();
373 #endif 375 #endif
374 else if (attribute.name() == preloadAttr) { 376 else if (attribute.name() == preloadAttr) {
375 if (equalIgnoringCase(attribute.value(), "none")) 377 if (equalIgnoringCase(attribute.value(), "none"))
376 m_preload = MediaPlayer::None; 378 m_preload = MediaPlayer::None;
377 else if (equalIgnoringCase(attribute.value(), "metadata")) 379 else if (equalIgnoringCase(attribute.value(), "metadata"))
(...skipping 3285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3663 void HTMLMediaElement::userCancelledLoad() 3665 void HTMLMediaElement::userCancelledLoad()
3664 { 3666 {
3665 LOG(Media, "HTMLMediaElement::userCancelledLoad"); 3667 LOG(Media, "HTMLMediaElement::userCancelledLoad");
3666 3668
3667 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded) 3669 if (m_networkState == NETWORK_EMPTY || m_completelyLoaded)
3668 return; 3670 return;
3669 3671
3670 // If the media data fetching process is aborted by the user: 3672 // If the media data fetching process is aborted by the user:
3671 3673
3672 // 1 - The user agent should cancel the fetching process. 3674 // 1 - The user agent should cancel the fetching process.
3673 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO) 3675 clearMediaPlayer(-1);
3674 m_player.clear();
3675 #endif
3676 stopPeriodicTimers();
3677 m_loadTimer.stop();
3678 m_loadState = WaitingForSource;
3679 m_pendingLoadFlags = 0;
3680 3676
3681 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED. 3677 // 2 - Set the error attribute to a new MediaError object whose code attribu te is set to MEDIA_ERR_ABORTED.
3682 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED); 3678 m_error = MediaError::create(MediaError::MEDIA_ERR_ABORTED);
3683 3679
3684 // 3 - Queue a task to fire a simple event named error at the media element. 3680 // 3 - Queue a task to fire a simple event named error at the media element.
3685 scheduleEvent(eventNames().abortEvent); 3681 scheduleEvent(eventNames().abortEvent);
3686 3682
3687 #if ENABLE(MEDIA_SOURCE) 3683 #if ENABLE(MEDIA_SOURCE)
3688 setSourceState(MediaSource::closedKeyword()); 3684 setSourceState(MediaSource::closedKeyword());
3689 #endif 3685 #endif
(...skipping 17 matching lines...) Expand all
3707 3703
3708 // Reset m_readyState since m_player is gone. 3704 // Reset m_readyState since m_player is gone.
3709 m_readyState = HAVE_NOTHING; 3705 m_readyState = HAVE_NOTHING;
3710 updateMediaController(); 3706 updateMediaController();
3711 #if ENABLE(VIDEO_TRACK) 3707 #if ENABLE(VIDEO_TRACK)
3712 if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) 3708 if (RuntimeEnabledFeatures::webkitVideoTrackEnabled())
3713 updateActiveTextTrackCues(0); 3709 updateActiveTextTrackCues(0);
3714 #endif 3710 #endif
3715 } 3711 }
3716 3712
3713 void HTMLMediaElement::clearMediaPlayer(unsigned flags)
3714 {
3715 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
3716 m_player.clear();
3717 #endif
3718 stopPeriodicTimers();
3719 m_loadTimer.stop();
3720
3721 m_pendingLoadFlags &= ~flags;
3722 m_loadState = WaitingForSource;
3723 }
3724
3717 bool HTMLMediaElement::canSuspend() const 3725 bool HTMLMediaElement::canSuspend() const
3718 { 3726 {
3719 return true; 3727 return true;
3720 } 3728 }
3721 3729
3722 void HTMLMediaElement::stop() 3730 void HTMLMediaElement::stop()
3723 { 3731 {
3724 LOG(Media, "HTMLMediaElement::stop"); 3732 LOG(Media, "HTMLMediaElement::stop");
3725 if (m_isFullscreen) 3733 if (m_isFullscreen)
3726 exitFullscreen(); 3734 exitFullscreen();
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 4262
4255 return 0; 4263 return 0;
4256 } 4264 }
4257 4265
4258 void HTMLMediaElement::createMediaPlayer() 4266 void HTMLMediaElement::createMediaPlayer()
4259 { 4267 {
4260 #if ENABLE(WEB_AUDIO) 4268 #if ENABLE(WEB_AUDIO)
4261 if (m_audioSourceNode) 4269 if (m_audioSourceNode)
4262 m_audioSourceNode->lock(); 4270 m_audioSourceNode->lock();
4263 #endif 4271 #endif
4264 4272
4265 m_player = MediaPlayer::create(this); 4273 m_player = MediaPlayer::create(this);
4266 4274
4267 #if ENABLE(MEDIA_SOURCE) 4275 #if ENABLE(MEDIA_SOURCE)
4268 if (m_mediaSource) 4276 if (m_mediaSource)
4269 m_mediaSource->setMediaPlayer(m_player.get()); 4277 m_mediaSource->setMediaPlayer(m_player.get());
4270 #endif 4278 #endif
4271 4279
4272 #if ENABLE(WEB_AUDIO) 4280 #if ENABLE(WEB_AUDIO)
4273 if (m_audioSourceNode) { 4281 if (m_audioSourceNode) {
4274 // When creating the player, make sure its AudioSourceProvider knows abo ut the MediaElementAudioSourceNode. 4282 // When creating the player, make sure its AudioSourceProvider knows abo ut the MediaElementAudioSourceNode.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
4566 return mediaPlayerOwningDocument()->view()->windowClipRect(); 4574 return mediaPlayerOwningDocument()->view()->windowClipRect();
4567 } 4575 }
4568 4576
4569 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture() 4577 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
4570 { 4578 {
4571 m_restrictions = NoRestrictions; 4579 m_restrictions = NoRestrictions;
4572 } 4580 }
4573 4581
4574 } 4582 }
4575 #endif 4583 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/html/HTMLMediaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698