OLD | NEW |
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/filter_host.h" | 8 #include "media/base/filter_host.h" |
9 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 if (error > 0) { | 599 if (error > 0) { |
600 // If a position error code is received, read was successful. So copy | 600 // If a position error code is received, read was successful. So copy |
601 // from intermediate read buffer to the target read buffer. | 601 // from intermediate read buffer to the target read buffer. |
602 memcpy(read_buffer_, intermediate_read_buffer_.get(), error); | 602 memcpy(read_buffer_, intermediate_read_buffer_.get(), error); |
603 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) { | 603 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) { |
604 // We've reached the end of the file and we didn't know the total size | 604 // We've reached the end of the file and we didn't know the total size |
605 // before. Update the total size so Read()s past the end of the file will | 605 // before. Update the total size so Read()s past the end of the file will |
606 // fail like they would if we had known the file size at the beginning. | 606 // fail like they would if we had known the file size at the beginning. |
607 total_bytes_ = loader_->instance_size(); | 607 total_bytes_ = loader_->instance_size(); |
608 | 608 |
609 if (host() && total_bytes_ != kPositionNotSpecified) | 609 if (host() && total_bytes_ != kPositionNotSpecified) { |
610 host()->SetTotalBytes(total_bytes_); | 610 host()->SetTotalBytes(total_bytes_); |
| 611 host()->SetBufferedBytes(total_bytes_); |
| 612 } |
611 } | 613 } |
612 DoneRead_Locked(error); | 614 DoneRead_Locked(error); |
613 } | 615 } |
614 | 616 |
615 void BufferedDataSource::NetworkEventCallback() { | 617 void BufferedDataSource::NetworkEventCallback() { |
616 DCHECK(MessageLoop::current() == render_loop_); | 618 DCHECK(MessageLoop::current() == render_loop_); |
617 DCHECK(loader_.get()); | 619 DCHECK(loader_.get()); |
618 | 620 |
619 // In case of non-HTTP request we don't need to report network events, | 621 // In case of non-HTTP request we don't need to report network events, |
620 // so return immediately. | 622 // so return immediately. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 void BufferedDataSource::UpdateHostState_Locked() { | 656 void BufferedDataSource::UpdateHostState_Locked() { |
655 // Called from various threads, under lock. | 657 // Called from various threads, under lock. |
656 lock_.AssertAcquired(); | 658 lock_.AssertAcquired(); |
657 | 659 |
658 media::FilterHost* filter_host = host(); | 660 media::FilterHost* filter_host = host(); |
659 if (!filter_host) | 661 if (!filter_host) |
660 return; | 662 return; |
661 | 663 |
662 filter_host->SetLoaded(loaded_); | 664 filter_host->SetLoaded(loaded_); |
663 | 665 |
664 if (streaming_) { | 666 if (streaming_) |
665 filter_host->SetStreaming(true); | 667 filter_host->SetStreaming(true); |
666 } else { | 668 |
| 669 if (total_bytes_ != kPositionNotSpecified) |
667 filter_host->SetTotalBytes(total_bytes_); | 670 filter_host->SetTotalBytes(total_bytes_); |
668 filter_host->SetBufferedBytes(buffered_bytes_); | 671 filter_host->SetBufferedBytes(buffered_bytes_); |
669 } | |
670 } | 672 } |
671 | 673 |
672 } // namespace webkit_media | 674 } // namespace webkit_media |
OLD | NEW |