Chromium Code Reviews| Index: chromecast/media/cdm/browser_cdm_cast.cc |
| diff --git a/chromecast/media/cdm/browser_cdm_cast.cc b/chromecast/media/cdm/browser_cdm_cast.cc |
| index c9fbee746bff4bf5d0241e67f8399f45717a7312..f509f85c848ecb1a81e722583f40f79bfe63b8a9 100644 |
| --- a/chromecast/media/cdm/browser_cdm_cast.cc |
| +++ b/chromecast/media/cdm/browser_cdm_cast.cc |
| @@ -13,7 +13,13 @@ BrowserCdmCast::BrowserCdmCast() { |
| } |
| BrowserCdmCast::~BrowserCdmCast() { |
| - player_tracker_.NotifyCdmUnset(); |
| + { |
|
erickung1
2015/02/07 01:31:10
Nit: maybe no need the parentheses?
gunsch
2015/02/07 01:44:27
Done.
|
| + base::AutoLock auto_lock(callback_lock_); |
| + for (std::map<uint32_t, base::Closure>::const_iterator it = |
| + cdm_unset_callbacks_.begin(); it != cdm_unset_callbacks_.end(); ++it) { |
| + it->second.Run(); |
| + } |
| + } |
| } |
| void BrowserCdmCast::SetCallbacks( |
| @@ -31,11 +37,27 @@ void BrowserCdmCast::SetCallbacks( |
| int BrowserCdmCast::RegisterPlayer(const base::Closure& new_key_cb, |
| const base::Closure& cdm_unset_cb) { |
| - return player_tracker_.RegisterPlayer(new_key_cb, cdm_unset_cb); |
| + int registration_id = next_registration_id_++; |
| + DCHECK(!new_key_cb.is_null()); |
| + DCHECK(!cdm_unset_cb.is_null()); |
| + { |
| + base::AutoLock auto_lock(callback_lock_); |
| + DCHECK(!ContainsKey(new_key_callbacks_, registration_id)); |
| + DCHECK(!ContainsKey(cdm_unset_callbacks_, registration_id)); |
| + new_key_callbacks_[registration_id] = new_key_cb; |
| + cdm_unset_callbacks_[registration_id] = cdm_unset_cb; |
| + } |
| + return registration_id; |
| } |
| void BrowserCdmCast::UnregisterPlayer(int registration_id) { |
| - player_tracker_.UnregisterPlayer(registration_id); |
| + { |
|
erickung1
2015/02/07 01:31:10
Nit: maybe no need the parentheses?
gunsch
2015/02/07 01:44:27
Done.
|
| + base::AutoLock auto_lock(callback_lock_); |
| + DCHECK(ContainsKey(new_key_callbacks_, registration_id)); |
| + DCHECK(ContainsKey(cdm_unset_callbacks_, registration_id)); |
| + new_key_callbacks_.erase(registration_id); |
| + cdm_unset_callbacks_.erase(registration_id); |
| + } |
| } |
| void BrowserCdmCast::OnSessionMessage(const std::string& web_session_id, |
| @@ -68,7 +90,13 @@ void BrowserCdmCast::OnSessionKeysChange( |
| session_keys_change_cb_.Run(web_session_id, true, cdm_keys_info.Pass()); |
| // Notify listeners of a new key. |
| - player_tracker_.NotifyNewKey(); |
| + { |
| + base::AutoLock auto_lock(callback_lock_); |
| + for (std::map<uint32_t, base::Closure>::const_iterator it = |
| + new_key_callbacks_.begin(); it != new_key_callbacks_.end(); ++it) { |
| + it->second.Run(); |
| + } |
| + } |
| } |
| } // namespace media |