Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: chromecast/media/cdm/browser_cdm_cast.cc

Issue 903083003: Chromecast: change BrowserCdmCast threading model. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/media/cdm/browser_cdm_cast.h ('k') | chromecast/media/cma/pipeline/av_pipeline_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..766365a0f68b7fa1240609a5943fcf905e44eb49 100644
--- a/chromecast/media/cdm/browser_cdm_cast.cc
+++ b/chromecast/media/cdm/browser_cdm_cast.cc
@@ -9,11 +9,16 @@
namespace chromecast {
namespace media {
-BrowserCdmCast::BrowserCdmCast() {
+BrowserCdmCast::BrowserCdmCast()
+ : next_registration_id_(0) {
}
BrowserCdmCast::~BrowserCdmCast() {
- player_tracker_.NotifyCdmUnset();
+ 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 +36,25 @@ 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);
+ 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 +87,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
« no previous file with comments | « chromecast/media/cdm/browser_cdm_cast.h ('k') | chromecast/media/cma/pipeline/av_pipeline_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698