Chromium Code Reviews| 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..262c03fe40eb3dbba536014438ce3cdbdca5ed85 100644 |
| --- a/content/browser/media/cdm/browser_cdm_manager.cc |
| +++ b/content/browser/media/cdm/browser_cdm_manager.cc |
| @@ -248,25 +248,26 @@ void BrowserCdmManager::OnCreateSession( |
| } |
| GURL security_origin = iter->second; |
| - RenderFrameHost* rfh = |
| - RenderFrameHost::FromID(render_process_id_, render_frame_id); |
| - WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); |
| - DCHECK(web_contents); |
| - GetContentClient()->browser()->RequestPermission( |
| - content::PERMISSION_PROTECTED_MEDIA, |
| - web_contents, |
| - 0, // bridge id |
| - security_origin, |
| - // Only implemented for Android infobars which do not support |
| - // user gestures. |
| - true, |
| - base::Bind(&BrowserCdmManager::CreateSessionIfPermitted, |
| - this, |
| - render_frame_id, |
| - cdm_id, |
| - session_id, |
| - mime_type, |
| - init_data)); |
| + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&BrowserCdmManager::RequestSessionPermission, |
| + this, |
| + render_frame_id, |
| + security_origin, |
| + cdm_id, |
| + session_id, |
| + mime_type, |
| + init_data)); |
| + return; |
| + } |
| + RequestSessionPermission(render_frame_id, |
| + security_origin, |
| + cdm_id, |
| + session_id, |
| + mime_type, |
| + init_data); |
|
xhwang
2014/11/17 23:38:17
Can you do the thread check and post within Reques
gunsch
2014/11/19 21:59:01
Done.
|
| } |
| void BrowserCdmManager::OnUpdateSession( |
| @@ -356,6 +357,35 @@ void BrowserCdmManager::RemoveCdm(uint64 id) { |
| } |
| } |
| +void BrowserCdmManager::RequestSessionPermission( |
| + int render_frame_id, |
| + const GURL& security_origin, |
| + int cdm_id, |
| + uint32 session_id, |
| + const std::string& content_type, |
| + const std::vector<uint8>& init_data) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
|
xhwang
2014/11/17 23:38:17
See comment above. Check thread and post RequestSe
gunsch
2014/11/19 21:59:01
Done.
|
| + RenderFrameHost* rfh = |
| + RenderFrameHost::FromID(render_process_id_, render_frame_id); |
| + WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); |
| + DCHECK(web_contents); |
| + GetContentClient()->browser()->RequestPermission( |
| + content::PERMISSION_PROTECTED_MEDIA, |
| + web_contents, |
| + 0, // bridge id |
| + security_origin, |
| + // Only implemented for Android infobars which do not support |
| + // user gestures. |
| + true, |
| + base::Bind(&BrowserCdmManager::CreateSessionIfPermitted, |
| + this, |
| + render_frame_id, |
| + cdm_id, |
| + session_id, |
| + content_type, |
| + init_data)); |
| +} |
| + |
| void BrowserCdmManager::CreateSessionIfPermitted( |
| int render_frame_id, |
| int cdm_id, |