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

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

Issue 1932823002: Fix seeking after redirect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/resource_multibuffer_data_provider.h ('k') | no next file » | 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"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 // Check to see whether the server supports byte ranges. 256 // Check to see whether the server supports byte ranges.
257 std::string accept_ranges = 257 std::string accept_ranges =
258 response.httpHeaderField("Accept-Ranges").utf8(); 258 response.httpHeaderField("Accept-Ranges").utf8();
259 if (accept_ranges.find("bytes") != std::string::npos) 259 if (accept_ranges.find("bytes") != std::string::npos)
260 destination_url_data->set_range_supported(); 260 destination_url_data->set_range_supported();
261 261
262 // If we have verified the partial response and it is correct. 262 // If we have verified the partial response and it is correct.
263 // It's also possible for a server to support range requests 263 // It's also possible for a server to support range requests
264 // without advertising "Accept-Ranges: bytes". 264 // without advertising "Accept-Ranges: bytes".
265 if (partial_response && VerifyPartialResponse(response)) { 265 if (partial_response &&
266 VerifyPartialResponse(response, destination_url_data)) {
266 destination_url_data->set_range_supported(); 267 destination_url_data->set_range_supported();
267 } else if (ok_response && pos_ == 0) { 268 } else if (ok_response && pos_ == 0) {
268 // We accept a 200 response for a Range:0- request, trusting the 269 // We accept a 200 response for a Range:0- request, trusting the
269 // Accept-Ranges header, because Apache thinks that's a reasonable thing 270 // Accept-Ranges header, because Apache thinks that's a reasonable thing
270 // to return. 271 // to return.
271 destination_url_data->set_length(content_length); 272 destination_url_data->set_length(content_length);
272 } else if (response.httpStatusCode() == kHttpRangeNotSatisfiable) { 273 } else if (response.httpStatusCode() == kHttpRangeNotSatisfiable) {
273 // Really, we should never request a range that doesn't exist, but 274 // Really, we should never request a range that doesn't exist, but
274 // if we do, let's handle it in a sane way. 275 // if we do, let's handle it in a sane way.
275 // Unsatisfiable range 276 // Unsatisfiable range
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 477 }
477 return ret; 478 return ret;
478 } 479 }
479 480
480 int64_t ResourceMultiBufferDataProvider::block_size() const { 481 int64_t ResourceMultiBufferDataProvider::block_size() const {
481 int64_t ret = 1; 482 int64_t ret = 1;
482 return ret << url_data_->multibuffer()->block_size_shift(); 483 return ret << url_data_->multibuffer()->block_size_shift();
483 } 484 }
484 485
485 bool ResourceMultiBufferDataProvider::VerifyPartialResponse( 486 bool ResourceMultiBufferDataProvider::VerifyPartialResponse(
486 const WebURLResponse& response) { 487 const WebURLResponse& response,
488 const scoped_refptr<UrlData>& url_data) {
487 int64_t first_byte_position, last_byte_position, instance_size; 489 int64_t first_byte_position, last_byte_position, instance_size;
488 if (!ParseContentRange(response.httpHeaderField("Content-Range").utf8(), 490 if (!ParseContentRange(response.httpHeaderField("Content-Range").utf8(),
489 &first_byte_position, &last_byte_position, 491 &first_byte_position, &last_byte_position,
490 &instance_size)) { 492 &instance_size)) {
491 return false; 493 return false;
492 } 494 }
493 495
494 if (url_data_->length() == kPositionNotSpecified) { 496 if (url_data_->length() == kPositionNotSpecified) {
495 url_data_->set_length(instance_size); 497 url_data->set_length(instance_size);
496 } 498 }
497 499
498 if (byte_pos() != first_byte_position) { 500 if (byte_pos() != first_byte_position) {
499 return false; 501 return false;
500 } 502 }
501 503
502 return true; 504 return true;
503 } 505 }
504 506
505 } // namespace media 507 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698