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

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

Issue 2131933002: Revert of Replace 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
« no previous file with comments | « media/blink/buffered_resource_loader.cc ('k') | net/base/filename_util.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/resource_multibuffer_data_provider.h" 5 #include "media/blink/resource_multibuffer_data_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bits.h" 11 #include "base/bits.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h"
18 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
19 #include "media/blink/active_loader.h" 18 #include "media/blink/active_loader.h"
20 #include "media/blink/cache_util.h" 19 #include "media/blink/cache_util.h"
21 #include "media/blink/media_blink_export.h" 20 #include "media/blink/media_blink_export.h"
22 #include "media/blink/url_index.h" 21 #include "media/blink/url_index.h"
23 #include "net/http/http_byte_range.h" 22 #include "net/http/http_byte_range.h"
24 #include "net/http/http_request_headers.h" 23 #include "net/http/http_request_headers.h"
25 #include "third_party/WebKit/public/platform/WebURLError.h" 24 #include "third_party/WebKit/public/platform/WebURLError.h"
26 #include "third_party/WebKit/public/platform/WebURLResponse.h" 25 #include "third_party/WebKit/public/platform/WebURLResponse.h"
27 26
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Note that calling Fail() will most likely delete this object. 454 // Note that calling Fail() will most likely delete this object.
456 url_data_->Fail(); 455 url_data_->Fail();
457 } 456 }
458 } 457 }
459 458
460 bool ResourceMultiBufferDataProvider::ParseContentRange( 459 bool ResourceMultiBufferDataProvider::ParseContentRange(
461 const std::string& content_range_str, 460 const std::string& content_range_str,
462 int64_t* first_byte_position, 461 int64_t* first_byte_position,
463 int64_t* last_byte_position, 462 int64_t* last_byte_position,
464 int64_t* instance_size) { 463 int64_t* instance_size) {
465 const char kUpThroughBytesUnit[] = "bytes "; 464 const std::string kUpThroughBytesUnit = "bytes ";
466 if (!base::StartsWith(content_range_str, kUpThroughBytesUnit, 465 if (content_range_str.find(kUpThroughBytesUnit) != 0)
467 base::CompareCase::SENSITIVE)) {
468 return false; 466 return false;
469 }
470 std::string range_spec = 467 std::string range_spec =
471 content_range_str.substr(sizeof(kUpThroughBytesUnit) - 1); 468 content_range_str.substr(kUpThroughBytesUnit.length());
472 size_t dash_offset = range_spec.find("-"); 469 size_t dash_offset = range_spec.find("-");
473 size_t slash_offset = range_spec.find("/"); 470 size_t slash_offset = range_spec.find("/");
474 471
475 if (dash_offset == std::string::npos || slash_offset == std::string::npos || 472 if (dash_offset == std::string::npos || slash_offset == std::string::npos ||
476 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) { 473 slash_offset < dash_offset || slash_offset + 1 == range_spec.length()) {
477 return false; 474 return false;
478 } 475 }
479 if (!base::StringToInt64(range_spec.substr(0, dash_offset), 476 if (!base::StringToInt64(range_spec.substr(0, dash_offset),
480 first_byte_position) || 477 first_byte_position) ||
481 !base::StringToInt64( 478 !base::StringToInt64(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 528 }
532 529
533 if (byte_pos() != first_byte_position) { 530 if (byte_pos() != first_byte_position) {
534 return false; 531 return false;
535 } 532 }
536 533
537 return true; 534 return true;
538 } 535 }
539 536
540 } // namespace media 537 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/buffered_resource_loader.cc ('k') | net/base/filename_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698