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/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> |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1105 | 1105 |
| 1106 opaque_ = opaque; | 1106 opaque_ = opaque; |
| 1107 // Modify content opaqueness of cc::Layer directly so that | 1107 // Modify content opaqueness of cc::Layer directly so that |
| 1108 // SetContentsOpaqueIsFixed is ignored. | 1108 // SetContentsOpaqueIsFixed is ignored. |
| 1109 if (video_weblayer_) | 1109 if (video_weblayer_) |
| 1110 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1110 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 void WebMediaPlayerImpl::OnHidden() { | 1113 void WebMediaPlayerImpl::OnHidden() { |
| 1114 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1114 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1115 | |
| 1116 // Don't allow paused players to resume when shown. It's important to check | |
| 1117 // this here since |delegate_state_| is generally cleared during suspend. | |
|
sandersd (OOO until July 31)
2016/06/07 01:41:16
It's worth noting here that PAUSED_BUT_NOT_IDLE is
| |
| 1118 if (delegate_state_ == DelegateState::PAUSED) | |
| 1119 is_idle_ = true; | |
| 1120 | |
| 1121 last_hidden_time_ = base::TimeTicks::Now(); | |
| 1115 UpdatePlayState(); | 1122 UpdatePlayState(); |
| 1116 } | 1123 } |
| 1117 | 1124 |
| 1118 void WebMediaPlayerImpl::OnShown() { | 1125 void WebMediaPlayerImpl::OnShown() { |
| 1119 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1126 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1120 must_suspend_ = false; | 1127 must_suspend_ = false; |
| 1128 | |
| 1129 // Don't auto-resume playback on players that have been idle for some time. | |
| 1130 // We don't do this when seeking since Blink is waiting for the seeked event | |
| 1131 // and will get into a bad state if we try and suspend. | |
|
sandersd (OOO until July 31)
2016/06/07 01:41:16
"try to suspend."
| |
| 1132 if (!paused_ && !seeking_ && !last_hidden_time_.is_null() && | |
|
sandersd (OOO until July 31)
2016/06/07 01:41:16
If this is intended to match DelegateState::PAUSED
| |
| 1133 base::TimeTicks::Now() - last_hidden_time_ > | |
| 1134 base::TimeDelta::FromSeconds(5)) { | |
| 1135 OnPause(); | |
|
sandersd (OOO until July 31)
2016/06/07 01:41:16
Since OnPause() calls UpdatePlayState(), it's prob
| |
| 1136 is_idle_ = true; | |
| 1137 } | |
| 1138 | |
| 1139 last_hidden_time_ = base::TimeTicks(); | |
| 1121 UpdatePlayState(); | 1140 UpdatePlayState(); |
| 1122 } | 1141 } |
| 1123 | 1142 |
| 1124 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { | 1143 void WebMediaPlayerImpl::OnSuspendRequested(bool must_suspend) { |
| 1125 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1144 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1126 | 1145 |
| 1127 if (must_suspend) { | 1146 if (must_suspend) { |
| 1128 must_suspend_ = true; | 1147 must_suspend_ = true; |
| 1129 } else { | 1148 } else { |
| 1130 // TODO(sandersd): Remove this when idleness is separate from play state. | 1149 // TODO(sandersd): Remove this when idleness is separate from play state. |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1613 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1632 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
| 1614 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1633 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
| 1615 << ", Demuxer: " << demuxer_memory_usage; | 1634 << ", Demuxer: " << demuxer_memory_usage; |
| 1616 | 1635 |
| 1617 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1636 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
| 1618 last_reported_memory_usage_ = current_memory_usage; | 1637 last_reported_memory_usage_ = current_memory_usage; |
| 1619 adjust_allocated_memory_cb_.Run(delta); | 1638 adjust_allocated_memory_cb_.Run(delta); |
| 1620 } | 1639 } |
| 1621 | 1640 |
| 1622 } // namespace media | 1641 } // namespace media |
| OLD | NEW |