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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 9113023: Fire canplaythrough as soon as download defers to fix autoplay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 8 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « webkit/media/buffered_data_source_unittest.cc ('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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", 735 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive",
736 is_accelerated_compositing_active_); 736 is_accelerated_compositing_active_);
737 } else { 737 } else {
738 GetClient()->disableAcceleratedCompositing(); 738 GetClient()->disableAcceleratedCompositing();
739 } 739 }
740 740
741 if (pipeline_->IsLocalSource()) 741 if (pipeline_->IsLocalSource())
742 SetNetworkState(WebKit::WebMediaPlayer::Loaded); 742 SetNetworkState(WebKit::WebMediaPlayer::Loaded);
743 743
744 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 744 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
745 // Fire canplaythrough immediately after playback begins because of 745 SetReadyState(WebKit::WebMediaPlayer::HaveFutureData);
746 // crbug.com/106480.
747 // TODO(vrk): set ready state to HaveFutureData when bug above is fixed.
748 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
749 } else { 746 } else {
750 // TODO(hclam): should use |status| to determine the state 747 // TODO(hclam): should use |status| to determine the state
751 // properly and reports error using MediaError. 748 // properly and reports error using MediaError.
752 // WebKit uses FormatError to indicate an error for bogus URL or bad file. 749 // WebKit uses FormatError to indicate an error for bogus URL or bad file.
753 // Since we are at the initialization stage we can safely treat every error 750 // Since we are at the initialization stage we can safely treat every error
754 // as format error. Should post a task to call to |webmediaplayer_|. 751 // as format error. Should post a task to call to |webmediaplayer_|.
755 SetNetworkState(WebKit::WebMediaPlayer::FormatError); 752 SetNetworkState(WebKit::WebMediaPlayer::FormatError);
756 } 753 }
757 754
758 // Repaint to trigger UI update. 755 // Repaint to trigger UI update.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) { 824 void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) {
828 DCHECK_EQ(main_loop_, MessageLoop::current()); 825 DCHECK_EQ(main_loop_, MessageLoop::current());
829 switch(type) { 826 switch(type) {
830 case media::DOWNLOAD_CONTINUED: 827 case media::DOWNLOAD_CONTINUED:
831 SetNetworkState(WebKit::WebMediaPlayer::Loading); 828 SetNetworkState(WebKit::WebMediaPlayer::Loading);
832 break; 829 break;
833 case media::DOWNLOAD_PAUSED: 830 case media::DOWNLOAD_PAUSED:
834 SetNetworkState(WebKit::WebMediaPlayer::Idle); 831 SetNetworkState(WebKit::WebMediaPlayer::Idle);
835 break; 832 break;
836 case media::CAN_PLAY_THROUGH: 833 case media::CAN_PLAY_THROUGH:
837 // Temporarily disable delayed firing of CAN_PLAY_THROUGH due to 834 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
838 // crbug.com/106480.
839 // TODO(vrk): uncomment code below when bug above is fixed.
840 // SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
841 break; 835 break;
842 default: 836 default:
843 NOTREACHED(); 837 NOTREACHED();
844 } 838 }
845 } 839 }
846 840
847 void WebMediaPlayerImpl::OnDemuxerOpened() { 841 void WebMediaPlayerImpl::OnDemuxerOpened() {
848 DCHECK_EQ(main_loop_, MessageLoop::current()); 842 DCHECK_EQ(main_loop_, MessageLoop::current());
849 843
850 GetClient()->sourceOpened(); 844 GetClient()->sourceOpened();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 return audio_source_provider_; 910 return audio_source_provider_;
917 } 911 }
918 912
919 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 913 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
920 DCHECK_EQ(main_loop_, MessageLoop::current()); 914 DCHECK_EQ(main_loop_, MessageLoop::current());
921 incremented_externally_allocated_memory_ = true; 915 incremented_externally_allocated_memory_ = true;
922 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 916 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
923 } 917 }
924 918
925 } // namespace webkit_media 919 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/buffered_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698