| 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_data_source.h" | 5 #include "media/blink/buffered_data_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "build/build_config.h" |
| 14 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 | 17 |
| 17 using blink::WebFrame; | 18 using blink::WebFrame; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // BufferedDataSource has an intermediate buffer, this value governs the initial | 22 // BufferedDataSource has an intermediate buffer, this value governs the initial |
| 22 // size of that buffer. It is set to 32KB because this is a typical read size | 23 // size of that buffer. It is set to 32KB because this is a typical read size |
| 23 // of FFmpeg. | 24 // of FFmpeg. |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 380 |
| 380 bool init_cb_is_null = false; | 381 bool init_cb_is_null = false; |
| 381 { | 382 { |
| 382 base::AutoLock auto_lock(lock_); | 383 base::AutoLock auto_lock(lock_); |
| 383 init_cb_is_null = init_cb_.is_null(); | 384 init_cb_is_null = init_cb_.is_null(); |
| 384 } | 385 } |
| 385 if (init_cb_is_null) { | 386 if (init_cb_is_null) { |
| 386 loader_->Stop(); | 387 loader_->Stop(); |
| 387 return; | 388 return; |
| 388 } | 389 } |
| 390 |
| 389 response_original_url_ = loader_->response_original_url(); | 391 response_original_url_ = loader_->response_original_url(); |
| 392 #if defined(OS_ANDROID) |
| 393 // The response original url is the URL of this resource after following |
| 394 // redirects. Update |url_| to this so that we only follow redirects once. |
| 395 // We do this on Android only to preserve the behavior we had before the |
| 396 // unified media pipeline. This behavior will soon exist on all platforms |
| 397 // as we switch to MultiBufferDataSource (http://crbug.com/514719). |
| 398 // If the response URL is empty (which happens when it's from a Service |
| 399 // Worker), keep the original one. |
| 400 if (!response_original_url_.is_empty()) |
| 401 url_ = response_original_url_; |
| 402 #endif // defined(OS_ANDROID) |
| 390 | 403 |
| 391 // All responses must be successful. Resources that are assumed to be fully | 404 // All responses must be successful. Resources that are assumed to be fully |
| 392 // buffered must have a known content length. | 405 // buffered must have a known content length. |
| 393 bool success = status == BufferedResourceLoader::kOk && | 406 bool success = status == BufferedResourceLoader::kOk && |
| 394 (!assume_fully_buffered() || | 407 (!assume_fully_buffered() || |
| 395 loader_->instance_size() != kPositionNotSpecified); | 408 loader_->instance_size() != kPositionNotSpecified); |
| 396 | 409 |
| 397 if (success) { | 410 if (success) { |
| 398 total_bytes_ = loader_->instance_size(); | 411 total_bytes_ = loader_->instance_size(); |
| 399 streaming_ = | 412 streaming_ = |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 } | 620 } |
| 608 | 621 |
| 609 // If media is currently playing or the page indicated preload=auto or the | 622 // If media is currently playing or the page indicated preload=auto or the |
| 610 // the server does not support the byte range request or we do not want to go | 623 // the server does not support the byte range request or we do not want to go |
| 611 // too far ahead of the read head, use threshold strategy to enable/disable | 624 // too far ahead of the read head, use threshold strategy to enable/disable |
| 612 // deferring when the buffer is full/depleted. | 625 // deferring when the buffer is full/depleted. |
| 613 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 626 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
| 614 } | 627 } |
| 615 | 628 |
| 616 } // namespace media | 629 } // namespace media |
| OLD | NEW |