| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 // 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 |
| 229 // OnSuspendRequested() can trigger calls into RemoveIdleDelegate(), so for | 229 // OnSuspendRequested() can trigger calls into RemoveIdleDelegate(), so for |
| 230 // iterator validity we set |idle_cleanup_running_| to true and defer | 230 // iterator validity we set |idle_cleanup_running_| to true and defer |
| 231 // deletions. | 231 // deletions. |
| 232 DCHECK(!idle_cleanup_running_); | 232 DCHECK(!idle_cleanup_running_); |
| 233 base::AutoReset<bool> scoper(&idle_cleanup_running_, true); | 233 base::AutoReset<bool> scoper(&idle_cleanup_running_, true); |
| 234 const base::TimeTicks now = tick_clock_->NowTicks(); | 234 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 235 for (auto& idle_delegate_entry : idle_delegate_map_) { | 235 for (auto& idle_delegate_entry : idle_delegate_map_) { |
| 236 if (now - idle_delegate_entry.second > timeout) { | 236 if (now - idle_delegate_entry.second > timeout) { |
| 237 id_map_.Lookup(idle_delegate_entry.first)->OnSuspendRequested(false); | 237 if (id_map_.Lookup(idle_delegate_entry.first) |
| 238 | 238 ->OnSuspendRequested(false)) { |
| 239 // Whether or not the player accepted the suspension, mark it for removal | 239 // If the player accepted the suspension, mark it for removal |
| 240 // from future polls to avoid running the timer forever. | 240 // from future polls to avoid running the timer forever. |
| 241 idle_delegate_entry.second = base::TimeTicks(); | 241 idle_delegate_entry.second = base::TimeTicks(); |
| 242 } |
| 242 } | 243 } |
| 243 } | 244 } |
| 244 | 245 |
| 245 // Take care of any removals that happened during the above iteration. | 246 // Take care of any removals that happened during the above iteration. |
| 246 for (auto it = idle_delegate_map_.begin(); it != idle_delegate_map_.end();) { | 247 for (auto it = idle_delegate_map_.begin(); it != idle_delegate_map_.end();) { |
| 247 if (it->second.is_null()) | 248 if (it->second.is_null()) |
| 248 it = idle_delegate_map_.erase(it); | 249 it = idle_delegate_map_.erase(it); |
| 249 else | 250 else |
| 250 ++it; | 251 ++it; |
| 251 } | 252 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 275 #endif // OS_ANDROID | 276 #endif // OS_ANDROID |
| 276 | 277 |
| 277 is_playing_background_video_ = is_playing; | 278 is_playing_background_video_ = is_playing; |
| 278 } | 279 } |
| 279 | 280 |
| 280 void RendererWebMediaPlayerDelegate::OnDestruct() { | 281 void RendererWebMediaPlayerDelegate::OnDestruct() { |
| 281 delete this; | 282 delete this; |
| 282 } | 283 } |
| 283 | 284 |
| 284 } // namespace media | 285 } // namespace media |
| OLD | NEW |