| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cdm/player_tracker_impl.h" | 5 #include "media/cdm/player_tracker_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 PlayerTrackerImpl::PlayerTrackerImpl() : next_registration_id_(1) { | 24 PlayerTrackerImpl::PlayerTrackerImpl() : next_registration_id_(1) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 PlayerTrackerImpl::~PlayerTrackerImpl() {} | 27 PlayerTrackerImpl::~PlayerTrackerImpl() {} |
| 28 | 28 |
| 29 int PlayerTrackerImpl::RegisterPlayer(const base::Closure& new_key_cb, | 29 int PlayerTrackerImpl::RegisterPlayer(const base::Closure& new_key_cb, |
| 30 const base::Closure& cdm_unset_cb) { | 30 const base::Closure& cdm_unset_cb) { |
| 31 base::AutoLock lock(lock_); | 31 base::AutoLock lock(lock_); |
| 32 int registration_id = next_registration_id_++; | 32 int registration_id = next_registration_id_++; |
| 33 DCHECK(!ContainsKey(player_callbacks_map_, registration_id)); | 33 DCHECK(!base::ContainsKey(player_callbacks_map_, registration_id)); |
| 34 player_callbacks_map_.insert(std::make_pair( | 34 player_callbacks_map_.insert(std::make_pair( |
| 35 registration_id, PlayerCallbacks(new_key_cb, cdm_unset_cb))); | 35 registration_id, PlayerCallbacks(new_key_cb, cdm_unset_cb))); |
| 36 return registration_id; | 36 return registration_id; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void PlayerTrackerImpl::UnregisterPlayer(int registration_id) { | 39 void PlayerTrackerImpl::UnregisterPlayer(int registration_id) { |
| 40 base::AutoLock lock(lock_); | 40 base::AutoLock lock(lock_); |
| 41 DCHECK(ContainsKey(player_callbacks_map_, registration_id)) | 41 DCHECK(base::ContainsKey(player_callbacks_map_, registration_id)) |
| 42 << registration_id; | 42 << registration_id; |
| 43 player_callbacks_map_.erase(registration_id); | 43 player_callbacks_map_.erase(registration_id); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PlayerTrackerImpl::NotifyNewKey() { | 46 void PlayerTrackerImpl::NotifyNewKey() { |
| 47 std::vector<base::Closure> new_key_callbacks; | 47 std::vector<base::Closure> new_key_callbacks; |
| 48 | 48 |
| 49 { | 49 { |
| 50 base::AutoLock lock(lock_); | 50 base::AutoLock lock(lock_); |
| 51 for (const auto& entry : player_callbacks_map_) | 51 for (const auto& entry : player_callbacks_map_) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 63 base::AutoLock lock(lock_); | 63 base::AutoLock lock(lock_); |
| 64 for (const auto& entry : player_callbacks_map_) | 64 for (const auto& entry : player_callbacks_map_) |
| 65 cdm_unset_callbacks.push_back(entry.second.cdm_unset_cb); | 65 cdm_unset_callbacks.push_back(entry.second.cdm_unset_cb); |
| 66 } | 66 } |
| 67 | 67 |
| 68 for (const auto& cb : cdm_unset_callbacks) | 68 for (const auto& cb : cdm_unset_callbacks) |
| 69 cb.Run(); | 69 cb.Run(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace media | 72 } // namespace media |
| OLD | NEW |