Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: media/blink/buffered_data_source.cc

Issue 1947693003: BufferedDataSource now caches redirects for subsequent requests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/blink/buffered_data_source_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | media/blink/buffered_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698