OLD | NEW |
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_resource_loader.h" | 5 #include "webkit/media/buffered_resource_loader.h" |
6 | 6 |
7 #include "base/bits.h" | 7 #include "base/bits.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 502 } |
503 | 503 |
504 // If there is a start callback, run it. | 504 // If there is a start callback, run it. |
505 if (!start_cb_.is_null()) { | 505 if (!start_cb_.is_null()) { |
506 DCHECK(read_cb_.is_null()) | 506 DCHECK(read_cb_.is_null()) |
507 << "Shouldn't have a read callback during start"; | 507 << "Shouldn't have a read callback during start"; |
508 DoneStart(kOk); | 508 DoneStart(kOk); |
509 return; | 509 return; |
510 } | 510 } |
511 | 511 |
512 // If there is a pending read but the request has ended, return with what | 512 // Don't leave read callbacks hanging around. |
513 // we have. | |
514 if (HasPendingRead()) { | 513 if (HasPendingRead()) { |
515 // Try to fulfill with what is in the buffer. | 514 // Try to fulfill with what is in the buffer. |
516 if (CanFulfillRead()) | 515 if (CanFulfillRead()) |
517 ReadInternal(); | 516 ReadInternal(); |
518 else | 517 else |
519 DoneRead(kCacheMiss, 0); | 518 DoneRead(kCacheMiss, 0); |
520 } | 519 } |
521 | |
522 // There must not be any outstanding read request. | |
523 DCHECK(!HasPendingRead()); | |
524 } | 520 } |
525 | 521 |
526 void BufferedResourceLoader::didFail( | 522 void BufferedResourceLoader::didFail( |
527 WebURLLoader* loader, | 523 WebURLLoader* loader, |
528 const WebURLError& error) { | 524 const WebURLError& error) { |
529 DVLOG(1) << "didFail: reason=" << error.reason | 525 DVLOG(1) << "didFail: reason=" << error.reason |
530 << ", isCancellation=" << error.isCancellation | 526 << ", isCancellation=" << error.isCancellation |
531 << ", domain=" << error.domain.utf8().data() | 527 << ", domain=" << error.domain.utf8().data() |
532 << ", localizedDescription=" | 528 << ", localizedDescription=" |
533 << error.localizedDescription.utf8().data(); | 529 << error.localizedDescription.utf8().data(); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 831 |
836 void BufferedResourceLoader::Log() { | 832 void BufferedResourceLoader::Log() { |
837 media_log_->AddEvent( | 833 media_log_->AddEvent( |
838 media_log_->CreateBufferedExtentsChangedEvent( | 834 media_log_->CreateBufferedExtentsChangedEvent( |
839 offset_ - buffer_.backward_bytes(), | 835 offset_ - buffer_.backward_bytes(), |
840 offset_, | 836 offset_, |
841 offset_ + buffer_.forward_bytes())); | 837 offset_ + buffer_.forward_bytes())); |
842 } | 838 } |
843 | 839 |
844 } // namespace webkit_media | 840 } // namespace webkit_media |
OLD | NEW |