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 "content/renderer/media/buffered_resource_loader.h" | 5 #include "content/renderer/media/buffered_resource_loader.h" |
6 | 6 |
7 #include "base/bits.h" | 7 #include "base/bits.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 // Expected content length can be |kPositionNotSpecified|, in that case | 384 // Expected content length can be |kPositionNotSpecified|, in that case |
385 // |content_length_| is not specified and this is a streaming response. | 385 // |content_length_| is not specified and this is a streaming response. |
386 content_length_ = response.expectedContentLength(); | 386 content_length_ = response.expectedContentLength(); |
387 | 387 |
388 // We make a strong assumption that when we reach here we have either | 388 // We make a strong assumption that when we reach here we have either |
389 // received a response from HTTP/HTTPS protocol or the request was | 389 // received a response from HTTP/HTTPS protocol or the request was |
390 // successful (in particular range request). So we only verify the partial | 390 // successful (in particular range request). So we only verify the partial |
391 // response for HTTP and HTTPS protocol. | 391 // response for HTTP and HTTPS protocol. |
392 if (url_.SchemeIs(url::kHttpScheme) || url_.SchemeIs(url::kHttpsScheme)) { | 392 if (url_.SchemeIsHTTPOrHTTPS()) { |
393 bool partial_response = (response.httpStatusCode() == kHttpPartialContent); | 393 bool partial_response = (response.httpStatusCode() == kHttpPartialContent); |
394 bool ok_response = (response.httpStatusCode() == kHttpOK); | 394 bool ok_response = (response.httpStatusCode() == kHttpOK); |
395 | 395 |
396 if (IsRangeRequest()) { | 396 if (IsRangeRequest()) { |
397 // Check to see whether the server supports byte ranges. | 397 // Check to see whether the server supports byte ranges. |
398 std::string accept_ranges = | 398 std::string accept_ranges = |
399 response.httpHeaderField("Accept-Ranges").utf8(); | 399 response.httpHeaderField("Accept-Ranges").utf8(); |
400 range_supported_ = (accept_ranges.find("bytes") != std::string::npos); | 400 range_supported_ = (accept_ranges.find("bytes") != std::string::npos); |
401 | 401 |
402 // If we have verified the partial response and it is correct, we will | 402 // If we have verified the partial response and it is correct, we will |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 777 |
778 void BufferedResourceLoader::Log() { | 778 void BufferedResourceLoader::Log() { |
779 media_log_->AddEvent( | 779 media_log_->AddEvent( |
780 media_log_->CreateBufferedExtentsChangedEvent( | 780 media_log_->CreateBufferedExtentsChangedEvent( |
781 offset_ - buffer_.backward_bytes(), | 781 offset_ - buffer_.backward_bytes(), |
782 offset_, | 782 offset_, |
783 offset_ + buffer_.forward_bytes())); | 783 offset_ + buffer_.forward_bytes())); |
784 } | 784 } |
785 | 785 |
786 } // namespace content | 786 } // namespace content |
OLD | NEW |