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

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

Issue 9269027: Revert 118546 because it caused PrerenderHTML5VideoNetwork to timeout on windows and linux (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
« no previous file with comments | « media/base/pipeline.cc ('k') | webkit/media/buffered_data_source_unittest.cc » ('j') | 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/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 10
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 if (error > 0) { 546 if (error > 0) {
547 // If a position error code is received, read was successful. So copy 547 // If a position error code is received, read was successful. So copy
548 // from intermediate read buffer to the target read buffer. 548 // from intermediate read buffer to the target read buffer.
549 memcpy(read_buffer_, intermediate_read_buffer_.get(), error); 549 memcpy(read_buffer_, intermediate_read_buffer_.get(), error);
550 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) { 550 } else if (error == 0 && total_bytes_ == kPositionNotSpecified) {
551 // We've reached the end of the file and we didn't know the total size 551 // We've reached the end of the file and we didn't know the total size
552 // before. Update the total size so Read()s past the end of the file will 552 // before. Update the total size so Read()s past the end of the file will
553 // fail like they would if we had known the file size at the beginning. 553 // fail like they would if we had known the file size at the beginning.
554 total_bytes_ = loader_->instance_size(); 554 total_bytes_ = loader_->instance_size();
555 if (total_bytes_ != kPositionNotSpecified)
556 buffered_bytes_ = total_bytes_;
557 555
558 UpdateHostState_Locked(); 556 if (host() && total_bytes_ != kPositionNotSpecified) {
557 host()->SetTotalBytes(total_bytes_);
558 host()->SetBufferedBytes(total_bytes_);
559 }
559 } 560 }
560 DoneRead_Locked(error); 561 DoneRead_Locked(error);
561 } 562 }
562 563
563 void BufferedDataSource::NetworkEventCallback() { 564 void BufferedDataSource::NetworkEventCallback() {
564 DCHECK(MessageLoop::current() == render_loop_); 565 DCHECK(MessageLoop::current() == render_loop_);
565 DCHECK(loader_.get()); 566 DCHECK(loader_.get());
566 567
567 // In case of non-HTTP request we don't need to report network events, 568 // In case of non-HTTP request we don't need to report network events,
568 // so return immediately. 569 // so return immediately.
(...skipping 12 matching lines...) Expand all
581 // method to prevent bad things from happening. The reason behind this is 582 // method to prevent bad things from happening. The reason behind this is
582 // that we cannot guarantee tasks on render thread have completely stopped 583 // that we cannot guarantee tasks on render thread have completely stopped
583 // when we receive the Stop() method call. So only way to solve this is to 584 // when we receive the Stop() method call. So only way to solve this is to
584 // let tasks on render thread to run but make sure they don't call outside 585 // let tasks on render thread to run but make sure they don't call outside
585 // this object when Stop() method is ever called. Locking this method is safe 586 // this object when Stop() method is ever called. Locking this method is safe
586 // because |lock_| is only acquired in tasks on render thread. 587 // because |lock_| is only acquired in tasks on render thread.
587 base::AutoLock auto_lock(lock_); 588 base::AutoLock auto_lock(lock_);
588 if (stop_signal_received_) 589 if (stop_signal_received_)
589 return; 590 return;
590 591
591 is_downloading_data_ = is_downloading_data; 592 if (is_downloading_data != is_downloading_data_) {
593 is_downloading_data_ = is_downloading_data;
594 if (host())
595 host()->SetNetworkActivity(is_downloading_data);
596 }
597
592 buffered_bytes_ = buffered_position + 1; 598 buffered_bytes_ = buffered_position + 1;
593 599 if (host())
594 UpdateHostState_Locked(); 600 host()->SetBufferedBytes(buffered_bytes_);
595 } 601 }
596 602
597 void BufferedDataSource::UpdateHostState_Locked() { 603 void BufferedDataSource::UpdateHostState_Locked() {
598 // Called from various threads, under lock. 604 // Called from various threads, under lock.
599 lock_.AssertAcquired(); 605 lock_.AssertAcquired();
600 606
601 if (!host()) 607 if (!host())
602 return; 608 return;
603 609
604 if (total_bytes_ != kPositionNotSpecified) 610 if (total_bytes_ != kPositionNotSpecified)
605 host()->SetTotalBytes(total_bytes_); 611 host()->SetTotalBytes(total_bytes_);
606 host()->SetNetworkActivity(is_downloading_data_);
607 host()->SetBufferedBytes(buffered_bytes_); 612 host()->SetBufferedBytes(buffered_bytes_);
608 } 613 }
609 614
610 } // namespace webkit_media 615 } // namespace webkit_media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | webkit/media/buffered_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698