Chromium Code Reviews| 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" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 | 380 |
| 381 bool init_cb_is_null = false; | 381 bool init_cb_is_null = false; |
| 382 { | 382 { |
| 383 base::AutoLock auto_lock(lock_); | 383 base::AutoLock auto_lock(lock_); |
| 384 init_cb_is_null = init_cb_.is_null(); | 384 init_cb_is_null = init_cb_.is_null(); |
| 385 } | 385 } |
| 386 if (init_cb_is_null) { | 386 if (init_cb_is_null) { |
| 387 loader_->Stop(); | 387 loader_->Stop(); |
| 388 return; | 388 return; |
| 389 } | 389 } |
| 390 | |
| 390 response_original_url_ = loader_->response_original_url(); | 391 response_original_url_ = loader_->response_original_url(); |
| 392 // The response original url is the URL of this resource after following | |
| 393 // redirects. Update |url_| to this so that we only follow redirects once for | |
| 394 // simplicity and efficiency. | |
| 395 // If it's empty, it was a response from a Service Worker, so keep the | |
|
hubbe
2016/04/28 19:34:17
Why do we care if it's a service worker?
watk
2016/04/28 20:05:16
I guess my phrasing is slightly misleading. It's n
| |
| 396 // original URL. | |
| 397 if (!response_original_url_.is_empty()) | |
| 398 url_ = response_original_url_; | |
| 391 | 399 |
| 392 // All responses must be successful. Resources that are assumed to be fully | 400 // All responses must be successful. Resources that are assumed to be fully |
| 393 // buffered must have a known content length. | 401 // buffered must have a known content length. |
| 394 bool success = status == BufferedResourceLoader::kOk && | 402 bool success = status == BufferedResourceLoader::kOk && |
| 395 (!assume_fully_buffered() || | 403 (!assume_fully_buffered() || |
| 396 loader_->instance_size() != kPositionNotSpecified); | 404 loader_->instance_size() != kPositionNotSpecified); |
| 397 | 405 |
| 398 if (success) { | 406 if (success) { |
| 399 total_bytes_ = loader_->instance_size(); | 407 total_bytes_ = loader_->instance_size(); |
| 400 streaming_ = | 408 streaming_ = |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 } | 616 } |
| 609 | 617 |
| 610 // If media is currently playing or the page indicated preload=auto or the | 618 // If media is currently playing or the page indicated preload=auto or the |
| 611 // the server does not support the byte range request or we do not want to go | 619 // the server does not support the byte range request or we do not want to go |
| 612 // too far ahead of the read head, use threshold strategy to enable/disable | 620 // too far ahead of the read head, use threshold strategy to enable/disable |
| 613 // deferring when the buffer is full/depleted. | 621 // deferring when the buffer is full/depleted. |
| 614 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 622 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
| 615 } | 623 } |
| 616 | 624 |
| 617 } // namespace media | 625 } // namespace media |
| OLD | NEW |