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

Unified Diff: content/browser/media/cdm/browser_cdm_manager.cc

Issue 731793002: BrowserCdmManager: remove CDMs on correct thread on RenderFrameDeleted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address style comments (damienv) Created 6 years, 1 month 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 | « content/browser/media/cdm/browser_cdm_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/cdm/browser_cdm_manager.cc
diff --git a/content/browser/media/cdm/browser_cdm_manager.cc b/content/browser/media/cdm/browser_cdm_manager.cc
index d3d4630cb08b54547ac2494d541e47b9589d7875..99c763d9360e33824b37a267274d3dc0fa8b0027 100644
--- a/content/browser/media/cdm/browser_cdm_manager.cc
+++ b/content/browser/media/cdm/browser_cdm_manager.cc
@@ -122,16 +122,14 @@ media::BrowserCdm* BrowserCdmManager::GetCdm(int render_frame_id, int cdm_id) {
}
void BrowserCdmManager::RenderFrameDeleted(int render_frame_id) {
- DCHECK(task_runner_->RunsTasksOnCurrentThread());
-
- std::vector<uint64> ids_to_remove;
- for (CdmMap::iterator it = cdm_map_.begin(); it != cdm_map_.end(); ++it) {
- if (IdBelongsToFrame(it->first, render_frame_id))
- ids_to_remove.push_back(it->first);
+ if (!task_runner_->RunsTasksOnCurrentThread()) {
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&BrowserCdmManager::RemoveAllCdmForFrame,
+ this, render_frame_id));
+ return;
}
-
- for (size_t i = 0; i < ids_to_remove.size(); ++i)
- RemoveCdm(ids_to_remove[i]);
+ RemoveAllCdmForFrame(render_frame_id);
}
void BrowserCdmManager::OnSessionCreated(int render_frame_id,
@@ -345,6 +343,19 @@ void BrowserCdmManager::AddCdm(int render_frame_id,
cdm_security_origin_map_[id] = security_origin;
}
+void BrowserCdmManager::RemoveAllCdmForFrame(int render_frame_id) {
+ DCHECK(task_runner_->RunsTasksOnCurrentThread());
+
+ std::vector<uint64> ids_to_remove;
+ for (CdmMap::iterator it = cdm_map_.begin(); it != cdm_map_.end(); ++it) {
+ if (IdBelongsToFrame(it->first, render_frame_id))
+ ids_to_remove.push_back(it->first);
+ }
+
+ for (size_t i = 0; i < ids_to_remove.size(); ++i)
+ RemoveCdm(ids_to_remove[i]);
+}
+
void BrowserCdmManager::RemoveCdm(uint64 id) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
« no previous file with comments | « content/browser/media/cdm/browser_cdm_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698