| 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 (content_range_str.find(kUpThroughBytesUnit) != 0) | 731 if (!base::StartsWith(content_range_str, kUpThroughBytesUnit, |
| 732 base::CompareCase::SENSITIVE)) { |
| 732 return false; | 733 return false; |
| 734 } |
| 733 std::string range_spec = | 735 std::string range_spec = |
| 734 content_range_str.substr(kUpThroughBytesUnit.length()); | 736 content_range_str.substr(kUpThroughBytesUnit.length()); |
| 735 size_t dash_offset = range_spec.find("-"); | 737 size_t dash_offset = range_spec.find("-"); |
| 736 size_t slash_offset = range_spec.find("/"); | 738 size_t slash_offset = range_spec.find("/"); |
| 737 | 739 |
| 738 if (dash_offset == std::string::npos || slash_offset == std::string::npos || | 740 if (dash_offset == std::string::npos || slash_offset == std::string::npos || |
| 739 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) { | 741 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) { |
| 740 return false; | 742 return false; |
| 741 } | 743 } |
| 742 if (!base::StringToInt64(range_spec.substr(0, dash_offset), | 744 if (!base::StringToInt64(range_spec.substr(0, dash_offset), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 | 825 |
| 824 void BufferedResourceLoader::Log() { | 826 void BufferedResourceLoader::Log() { |
| 825 media_log_->AddEvent( | 827 media_log_->AddEvent( |
| 826 media_log_->CreateBufferedExtentsChangedEvent( | 828 media_log_->CreateBufferedExtentsChangedEvent( |
| 827 offset_ - buffer_.backward_bytes(), | 829 offset_ - buffer_.backward_bytes(), |
| 828 offset_, | 830 offset_, |
| 829 offset_ + buffer_.forward_bytes())); | 831 offset_ + buffer_.forward_bytes())); |
| 830 } | 832 } |
| 831 | 833 |
| 832 } // namespace media | 834 } // namespace media |
| OLD | NEW |