| OLD | NEW |
| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 | 383 |
| 384 void ResourceMultiBufferDataProvider::DidReceiveData(const char* data, | 384 void ResourceMultiBufferDataProvider::DidReceiveData(const char* data, |
| 385 int data_length) { | 385 int data_length) { |
| 386 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; | 386 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; |
| 387 DCHECK(!Available()); | 387 DCHECK(!Available()); |
| 388 DCHECK(active_loader_); | 388 DCHECK(active_loader_); |
| 389 DCHECK_GT(data_length, 0); | 389 DCHECK_GT(data_length, 0); |
| 390 | 390 |
| 391 url_data_->AddBytesReadFromNetwork(data_length); |
| 392 |
| 391 if (bytes_to_discard_) { | 393 if (bytes_to_discard_) { |
| 392 uint64_t tmp = std::min<uint64_t>(bytes_to_discard_, data_length); | 394 uint64_t tmp = std::min<uint64_t>(bytes_to_discard_, data_length); |
| 393 data_length -= tmp; | 395 data_length -= tmp; |
| 394 data += tmp; | 396 data += tmp; |
| 395 bytes_to_discard_ -= tmp; | 397 bytes_to_discard_ -= tmp; |
| 396 if (data_length == 0) | 398 if (data_length == 0) |
| 397 return; | 399 return; |
| 398 } | 400 } |
| 399 | 401 |
| 400 // When we receive data, we allow more retries. | 402 // When we receive data, we allow more retries. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 579 } |
| 578 if (last_byte_position + 1 < byte_pos()) { | 580 if (last_byte_position + 1 < byte_pos()) { |
| 579 return false; | 581 return false; |
| 580 } | 582 } |
| 581 bytes_to_discard_ = byte_pos() - first_byte_position; | 583 bytes_to_discard_ = byte_pos() - first_byte_position; |
| 582 | 584 |
| 583 return true; | 585 return true; |
| 584 } | 586 } |
| 585 | 587 |
| 586 } // namespace media | 588 } // namespace media |
| OLD | NEW |