OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/buffered_resource_loader.h" | 5 #include "media/blink/buffered_resource_loader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 return first_byte_position_; | 721 return first_byte_position_; |
722 } | 722 } |
723 | 723 |
724 // static | 724 // static |
725 bool BufferedResourceLoader::ParseContentRange( | 725 bool BufferedResourceLoader::ParseContentRange( |
726 const std::string& content_range_str, | 726 const std::string& content_range_str, |
727 int64_t* first_byte_position, | 727 int64_t* first_byte_position, |
728 int64_t* last_byte_position, | 728 int64_t* last_byte_position, |
729 int64_t* instance_size) { | 729 int64_t* instance_size) { |
730 const std::string kUpThroughBytesUnit = "bytes "; | 730 const std::string kUpThroughBytesUnit = "bytes "; |
731 if (!base::StartsWith(content_range_str, kUpThroughBytesUnit, | 731 if (content_range_str.find(kUpThroughBytesUnit) != 0) |
732 base::CompareCase::SENSITIVE)) { | |
733 return false; | 732 return false; |
734 } | |
735 std::string range_spec = | 733 std::string range_spec = |
736 content_range_str.substr(kUpThroughBytesUnit.length()); | 734 content_range_str.substr(kUpThroughBytesUnit.length()); |
737 size_t dash_offset = range_spec.find("-"); | 735 size_t dash_offset = range_spec.find("-"); |
738 size_t slash_offset = range_spec.find("/"); | 736 size_t slash_offset = range_spec.find("/"); |
739 | 737 |
740 if (dash_offset == std::string::npos || slash_offset == std::string::npos || | 738 if (dash_offset == std::string::npos || slash_offset == std::string::npos || |
741 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) { | 739 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) { |
742 return false; | 740 return false; |
743 } | 741 } |
744 if (!base::StringToInt64(range_spec.substr(0, dash_offset), | 742 if (!base::StringToInt64(range_spec.substr(0, dash_offset), |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 823 |
826 void BufferedResourceLoader::Log() { | 824 void BufferedResourceLoader::Log() { |
827 media_log_->AddEvent( | 825 media_log_->AddEvent( |
828 media_log_->CreateBufferedExtentsChangedEvent( | 826 media_log_->CreateBufferedExtentsChangedEvent( |
829 offset_ - buffer_.backward_bytes(), | 827 offset_ - buffer_.backward_bytes(), |
830 offset_, | 828 offset_, |
831 offset_ + buffer_.forward_bytes())); | 829 offset_ + buffer_.forward_bytes())); |
832 } | 830 } |
833 | 831 |
834 } // namespace media | 832 } // namespace media |
OLD | NEW |