| 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 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 bool is_backgrounded = | 1572 bool is_backgrounded = |
| 1573 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden(); | 1573 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden(); |
| 1574 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended, | 1574 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended, |
| 1575 is_backgrounded); | 1575 is_backgrounded); |
| 1576 SetDelegateState(state.delegate_state); | 1576 SetDelegateState(state.delegate_state); |
| 1577 SetMemoryReportingState(state.is_memory_reporting_enabled); | 1577 SetMemoryReportingState(state.is_memory_reporting_enabled); |
| 1578 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); | 1578 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); |
| 1579 } | 1579 } |
| 1580 | 1580 |
| 1581 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) { | 1581 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) { |
| 1582 if (!delegate_) | 1582 if (!delegate_ || delegate_state_ == new_state) |
| 1583 return; | |
| 1584 | |
| 1585 // Dedupe state changes in the general case, but make an exception for gone | |
| 1586 // since the delegate will use that information to decide when the idle timer | |
| 1587 // should be fired. | |
| 1588 if (delegate_state_ == new_state && new_state != DelegateState::GONE) | |
| 1589 return; | 1583 return; |
| 1590 | 1584 |
| 1591 delegate_state_ = new_state; | 1585 delegate_state_ = new_state; |
| 1592 | 1586 |
| 1593 switch (delegate_state_) { | 1587 switch (delegate_state_) { |
| 1594 case DelegateState::GONE: | 1588 case DelegateState::GONE: |
| 1595 delegate_->PlayerGone(delegate_id_); | 1589 delegate_->PlayerGone(delegate_id_); |
| 1596 break; | 1590 break; |
| 1597 case DelegateState::PLAYING: | 1591 case DelegateState::PLAYING: |
| 1598 delegate_->DidPlay( | 1592 delegate_->DidPlay( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 pipeline_metadata_.natural_size, | 1810 pipeline_metadata_.natural_size, |
| 1817 base::Bind(&GetCurrentTimeInternal, this))); | 1811 base::Bind(&GetCurrentTimeInternal, this))); |
| 1818 watch_time_reporter_->OnVolumeChange(volume_); | 1812 watch_time_reporter_->OnVolumeChange(volume_); |
| 1819 if (delegate_ && delegate_->IsHidden()) | 1813 if (delegate_ && delegate_->IsHidden()) |
| 1820 watch_time_reporter_->OnHidden(); | 1814 watch_time_reporter_->OnHidden(); |
| 1821 else | 1815 else |
| 1822 watch_time_reporter_->OnShown(); | 1816 watch_time_reporter_->OnShown(); |
| 1823 } | 1817 } |
| 1824 | 1818 |
| 1825 } // namespace media | 1819 } // namespace media |
| OLD | NEW |