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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 bool BufferedResourceLoader::range_supported() { | 325 bool BufferedResourceLoader::range_supported() { |
326 return range_supported_; | 326 return range_supported_; |
327 } | 327 } |
328 | 328 |
329 ///////////////////////////////////////////////////////////////////////////// | 329 ///////////////////////////////////////////////////////////////////////////// |
330 // blink::WebURLLoaderClient implementation. | 330 // blink::WebURLLoaderClient implementation. |
331 void BufferedResourceLoader::willFollowRedirect( | 331 void BufferedResourceLoader::willFollowRedirect( |
332 WebURLLoader* loader, | 332 WebURLLoader* loader, |
333 WebURLRequest& newRequest, | 333 WebURLRequest& newRequest, |
334 const WebURLResponse& redirectResponse) { | 334 const WebURLResponse& redirectResponse, |
335 | 335 int64_t encodedDataLength) { |
336 // The load may have been stopped and |start_cb| is destroyed. | 336 // The load may have been stopped and |start_cb| is destroyed. |
337 // In this case we shouldn't do anything. | 337 // In this case we shouldn't do anything. |
338 if (start_cb_.is_null()) { | 338 if (start_cb_.is_null()) { |
339 // Set the url in the request to an invalid value (empty url). | 339 // Set the url in the request to an invalid value (empty url). |
340 newRequest.setURL(blink::WebURL()); | 340 newRequest.setURL(blink::WebURL()); |
341 return; | 341 return; |
342 } | 342 } |
343 | 343 |
344 // Only allow |single_origin_| if we haven't seen a different origin yet. | 344 // Only allow |single_origin_| if we haven't seen a different origin yet. |
345 if (single_origin_) | 345 if (single_origin_) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 instance_size_ = content_length_; | 454 instance_size_ = content_length_; |
455 else if (last_byte_position_ == kPositionNotSpecified) | 455 else if (last_byte_position_ == kPositionNotSpecified) |
456 instance_size_ = content_length_ + first_byte_position_; | 456 instance_size_ = content_length_ + first_byte_position_; |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 // Calls with a successful response. | 460 // Calls with a successful response. |
461 DoneStart(kOk); | 461 DoneStart(kOk); |
462 } | 462 } |
463 | 463 |
464 void BufferedResourceLoader::didReceiveData( | 464 void BufferedResourceLoader::didReceiveData(WebURLLoader* loader, |
465 WebURLLoader* loader, | 465 const char* data, |
466 const char* data, | 466 int data_length, |
467 int data_length, | 467 int encoded_data_length, |
468 int encoded_data_length) { | 468 int encoded_body_length) { |
469 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; | 469 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; |
470 DCHECK(active_loader_.get()); | 470 DCHECK(active_loader_.get()); |
471 DCHECK_GT(data_length, 0); | 471 DCHECK_GT(data_length, 0); |
472 | 472 |
473 buffer_.Append(reinterpret_cast<const uint8_t*>(data), data_length); | 473 buffer_.Append(reinterpret_cast<const uint8_t*>(data), data_length); |
474 | 474 |
475 // If there is an active read request, try to fulfill the request. | 475 // If there is an active read request, try to fulfill the request. |
476 if (HasPendingRead() && CanFulfillRead()) | 476 if (HasPendingRead() && CanFulfillRead()) |
477 ReadInternal(); | 477 ReadInternal(); |
478 | 478 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 825 |
826 void BufferedResourceLoader::Log() { | 826 void BufferedResourceLoader::Log() { |
827 media_log_->AddEvent( | 827 media_log_->AddEvent( |
828 media_log_->CreateBufferedExtentsChangedEvent( | 828 media_log_->CreateBufferedExtentsChangedEvent( |
829 offset_ - buffer_.backward_bytes(), | 829 offset_ - buffer_.backward_bytes(), |
830 offset_, | 830 offset_, |
831 offset_ + buffer_.forward_bytes())); | 831 offset_ + buffer_.forward_bytes())); |
832 } | 832 } |
833 | 833 |
834 } // namespace media | 834 } // namespace media |
OLD | NEW |