Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/media/renderer_webmediaplayer_delegate.h" | 5 #include "content/renderer/media/renderer_webmediaplayer_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 | 215 |
| 216 idle_delegate_map_.erase(delegate_id); | 216 idle_delegate_map_.erase(delegate_id); |
| 217 if (idle_delegate_map_.empty()) | 217 if (idle_delegate_map_.empty()) |
| 218 idle_cleanup_timer_.Stop(); | 218 idle_cleanup_timer_.Stop(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void RendererWebMediaPlayerDelegate::CleanupIdleDelegates( | 221 void RendererWebMediaPlayerDelegate::CleanupIdleDelegates( |
| 222 base::TimeDelta timeout) { | 222 base::TimeDelta timeout) { |
| 223 // Drop reentrant cleanups which can occur during forced suspension when the | |
| 224 // number of idle delegates is too high for a given device. | |
| 225 if (idle_cleanup_running_) | |
| 226 return; | |
| 227 | |
| 223 // Iterate over the delegates and suspend the idle ones. Note: The call to | 228 // Iterate over the delegates and suspend the idle ones. Note: The call to |
| 224 // OnHidden() can trigger calls into RemoveIdleDelegate(), so for iterator | 229 // OnHidden() can trigger calls into RemoveIdleDelegate(), so for iterator |
|
watk
2016/09/27 20:58:30
unrelated, but if you're making another change, "O
DaleCurtis
2016/09/27 21:03:49
Done.
| |
| 225 // validity we set |idle_cleanup_running_| to true and defer deletions. | 230 // validity we set |idle_cleanup_running_| to true and defer deletions. |
| 231 DCHECK(!idle_cleanup_running_); | |
| 226 base::AutoReset<bool> scoper(&idle_cleanup_running_, true); | 232 base::AutoReset<bool> scoper(&idle_cleanup_running_, true); |
|
watk
2016/09/27 20:58:30
Might make sense to consolidate the comments and p
DaleCurtis
2016/09/27 21:03:49
Hmm, don't like separating the comments like that,
| |
| 227 const base::TimeTicks now = tick_clock_->NowTicks(); | 233 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 228 for (auto& idle_delegate_entry : idle_delegate_map_) { | 234 for (auto& idle_delegate_entry : idle_delegate_map_) { |
| 229 if (now - idle_delegate_entry.second > timeout) { | 235 if (now - idle_delegate_entry.second > timeout) { |
| 230 id_map_.Lookup(idle_delegate_entry.first)->OnSuspendRequested(false); | 236 id_map_.Lookup(idle_delegate_entry.first)->OnSuspendRequested(false); |
| 231 | 237 |
| 232 // Whether or not the player accepted the suspension, mark it for removal | 238 // Whether or not the player accepted the suspension, mark it for removal |
| 233 // from future polls to avoid running the timer forever. | 239 // from future polls to avoid running the timer forever. |
| 234 idle_delegate_entry.second = base::TimeTicks(); | 240 idle_delegate_entry.second = base::TimeTicks(); |
| 235 } | 241 } |
| 236 } | 242 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 #endif // OS_ANDROID | 274 #endif // OS_ANDROID |
| 269 | 275 |
| 270 is_playing_background_video_ = is_playing; | 276 is_playing_background_video_ = is_playing; |
| 271 } | 277 } |
| 272 | 278 |
| 273 void RendererWebMediaPlayerDelegate::OnDestruct() { | 279 void RendererWebMediaPlayerDelegate::OnDestruct() { |
| 274 delete this; | 280 delete this; |
| 275 } | 281 } |
| 276 | 282 |
| 277 } // namespace media | 283 } // namespace media |
| OLD | NEW |