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

Side by Side Diff: media/blink/buffered_resource_loader.cc

Issue 2136453004: Reland of place string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/browser/webui/shared_resources_data_source.cc ('k') | media/blink/resource_multibuffer_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698