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/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/debug/alias.h" | 17 #include "base/debug/alias.h" |
18 #include "base/debug/crash_logging.h" | 18 #include "base/debug/crash_logging.h" |
19 #include "base/metrics/field_trial.h" | |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
22 #include "base/task_runner_util.h" | 23 #include "base/task_runner_util.h" |
23 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
24 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "cc/blink/web_layer_impl.h" | 27 #include "cc/blink/web_layer_impl.h" |
27 #include "cc/layers/video_layer.h" | 28 #include "cc/layers/video_layer.h" |
28 #include "gpu/blink/webgraphicscontext3d_impl.h" | 29 #include "gpu/blink/webgraphicscontext3d_impl.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 284 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
284 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); | 285 media_log_->AddEvent(media_log_->CreateLoadEvent(url.string().utf8())); |
285 | 286 |
286 // Media source pipelines can start immediately. | 287 // Media source pipelines can start immediately. |
287 if (load_type == LoadTypeMediaSource) { | 288 if (load_type == LoadTypeMediaSource) { |
288 supports_save_ = false; | 289 supports_save_ = false; |
289 StartPipeline(); | 290 StartPipeline(); |
290 return; | 291 return; |
291 } | 292 } |
292 | 293 |
294 // TODO(hubbe): This experiment is temporary and should be removed once | |
DaleCurtis
2016/02/05 01:05:18
I suspect the experiment folk are going to want yo
hubbe
2016/02/09 22:01:59
Better now?
| |
295 // we have enough data to support the primacy of the new media cache. | |
296 // See http://crbug.com/514719 for details. | |
297 // | |
298 // Note: It's important to query the field trial state first, to ensure that | |
299 // UMA reports the correct group. | |
300 const std::string group_name = | |
301 base::FieldTrialList::FindFullName("UseNewMediaCacheTrial"); | |
302 const bool enabled_via_cli = | |
303 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
304 switches::kUseNewMediaCache); | |
305 const bool use_multibuffer = | |
306 enabled_via_cli || | |
307 base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE); | |
308 | |
293 // Otherwise it's a regular request which requires resolving the URL first. | 309 // Otherwise it's a regular request which requires resolving the URL first. |
294 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 310 if (use_multibuffer) { |
295 switches::kUseNewMediaCache)) { | |
296 // Remove this when MultiBufferDataSource becomes default. | 311 // Remove this when MultiBufferDataSource becomes default. |
297 LOG(WARNING) << "Using MultibufferDataSource"; | 312 LOG(WARNING) << "Using MultibufferDataSource"; |
298 data_source_.reset(new MultibufferDataSource( | 313 data_source_.reset(new MultibufferDataSource( |
299 url, static_cast<UrlData::CORSMode>(cors_mode), main_task_runner_, | 314 url, static_cast<UrlData::CORSMode>(cors_mode), main_task_runner_, |
300 url_index_, frame_, media_log_.get(), &buffered_data_source_host_, | 315 url_index_, frame_, media_log_.get(), &buffered_data_source_host_, |
301 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); | 316 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); |
302 } else { | 317 } else { |
303 data_source_.reset(new BufferedDataSource( | 318 data_source_.reset(new BufferedDataSource( |
304 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode), | 319 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode), |
305 main_task_runner_, frame_, media_log_.get(), | 320 main_task_runner_, frame_, media_log_.get(), |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1564 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
1550 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1565 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
1551 << ", Demuxer: " << demuxer_memory_usage; | 1566 << ", Demuxer: " << demuxer_memory_usage; |
1552 | 1567 |
1553 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1568 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
1554 last_reported_memory_usage_ = current_memory_usage; | 1569 last_reported_memory_usage_ = current_memory_usage; |
1555 adjust_allocated_memory_cb_.Run(delta); | 1570 adjust_allocated_memory_cb_.Run(delta); |
1556 } | 1571 } |
1557 | 1572 |
1558 } // namespace media | 1573 } // namespace media |
OLD | NEW |