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

Side by Side Diff: webkit/media/buffered_data_source.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: 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/buffered_data_source.h" 5 #include "webkit/media/buffered_data_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/media_log.h" 8 #include "media/base/media_log.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "webkit/media/web_data_source_factory.h" 10 #include "webkit/media/web_data_source_factory.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (error > 0) { 591 if (error > 0) {
592 // If a position error code is received, read was successful. So copy 592 // If a position error code is received, read was successful. So copy
593 // from intermediate read buffer to the target read buffer. 593 // from intermediate read buffer to the target read buffer.
594 memcpy(read_buffer_, intermediate_read_buffer_.get(), error); 594 memcpy(read_buffer_, intermediate_read_buffer_.get(), error);
595 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) { 595 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) {
596 // We've reached the end of the file and we didn't know the total size 596 // We've reached the end of the file and we didn't know the total size
597 // before. Update the total size so Read()s past the end of the file will 597 // before. Update the total size so Read()s past the end of the file will
598 // fail like they would if we had known the file size at the beginning. 598 // fail like they would if we had known the file size at the beginning.
599 total_bytes_ = loader_->instance_size(); 599 total_bytes_ = loader_->instance_size();
600 600
601 if (host() && total_bytes_ != kPositionNotSpecified) { 601 if (host() && total_bytes_ != kPositionNotSpecified) {
acolwell GONE FROM CHROMIUM 2012/01/05 22:33:56 Consider updating this code to call UpdateHostStat
vrk (LEFT CHROMIUM) 2012/01/09 19:01:18 Done.
602 host()->SetTotalBytes(total_bytes_); 602 host()->SetTotalBytes(total_bytes_);
603 host()->SetBufferedBytes(total_bytes_); 603 host()->SetBufferedBytes(total_bytes_);
604 } 604 }
605 } 605 }
606 DoneRead_Locked(error); 606 DoneRead_Locked(error);
607 } 607 }
608 608
609 void BufferedDataSource::NetworkEventCallback() { 609 void BufferedDataSource::NetworkEventCallback() {
610 DCHECK(MessageLoop::current() == render_loop_); 610 DCHECK(MessageLoop::current() == render_loop_);
611 DCHECK(loader_.get()); 611 DCHECK(loader_.get());
(...skipping 15 matching lines...) Expand all
627 // method to prevent bad things from happening. The reason behind this is 627 // method to prevent bad things from happening. The reason behind this is
628 // that we cannot guarantee tasks on render thread have completely stopped 628 // that we cannot guarantee tasks on render thread have completely stopped
629 // when we receive the Stop() method call. So only way to solve this is to 629 // when we receive the Stop() method call. So only way to solve this is to
630 // let tasks on render thread to run but make sure they don't call outside 630 // let tasks on render thread to run but make sure they don't call outside
631 // this object when Stop() method is ever called. Locking this method is safe 631 // this object when Stop() method is ever called. Locking this method is safe
632 // because |lock_| is only acquired in tasks on render thread. 632 // because |lock_| is only acquired in tasks on render thread.
633 base::AutoLock auto_lock(lock_); 633 base::AutoLock auto_lock(lock_);
634 if (stop_signal_received_) 634 if (stop_signal_received_)
635 return; 635 return;
636 636
637 if (is_downloading_data != is_downloading_data_) { 637 if (is_downloading_data != is_downloading_data_) {
acolwell GONE FROM CHROMIUM 2012/01/05 22:33:56 Consider updating this code to call UpdateHostStat
vrk (LEFT CHROMIUM) 2012/01/09 19:01:18 Done; I also had to change the unit tests to becom
638 is_downloading_data_ = is_downloading_data; 638 is_downloading_data_ = is_downloading_data;
639 if (host()) 639 if (host())
640 host()->SetNetworkActivity(is_downloading_data); 640 host()->SetNetworkActivity(is_downloading_data);
641 } 641 }
642 642
643 buffered_bytes_ = buffered_position + 1; 643 buffered_bytes_ = buffered_position + 1;
644 if (host()) 644 if (host())
645 host()->SetBufferedBytes(buffered_bytes_); 645 host()->SetBufferedBytes(buffered_bytes_);
646 } 646 }
647 647
648 void BufferedDataSource::UpdateHostState_Locked() { 648 void BufferedDataSource::UpdateHostState_Locked() {
649 // Called from various threads, under lock. 649 // Called from various threads, under lock.
650 lock_.AssertAcquired(); 650 lock_.AssertAcquired();
651 651
652 if (!host()) 652 if (!host())
653 return; 653 return;
654 654
655 if (total_bytes_ != kPositionNotSpecified) 655 if (total_bytes_ != kPositionNotSpecified)
656 host()->SetTotalBytes(total_bytes_); 656 host()->SetTotalBytes(total_bytes_);
acolwell GONE FROM CHROMIUM 2012/01/05 22:33:56 Please make sure that download_rate_monitor unit t
vrk (LEFT CHROMIUM) 2012/01/09 19:01:18 Done.
657 host()->SetBufferedBytes(buffered_bytes_); 657 host()->SetBufferedBytes(buffered_bytes_);
658 host()->SetNetworkActivity(is_downloading_data_);
acolwell GONE FROM CHROMIUM 2012/01/05 22:33:56 Please update the BufferedDataSource unit test to
vrk (LEFT CHROMIUM) 2012/01/09 19:01:18 Done.
658 } 659 }
659 660
660 } // namespace webkit_media 661 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698