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

Side by Side Diff: content/browser/media/cdm/browser_cdm_manager.cc

Issue 730453004: BrowserCdmManager: gets RenderFrameHost instance on the correct thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moves UI-thread trampoline inside RequestSessionPermission 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 unified diff | Download patch
« no previous file with comments | « content/browser/media/cdm/browser_cdm_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/media/cdm/browser_cdm_manager.h" 5 #include "content/browser/media/cdm/browser_cdm_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 std::map<uint64, GURL>::const_iterator iter = 244 std::map<uint64, GURL>::const_iterator iter =
245 cdm_security_origin_map_.find(GetId(render_frame_id, cdm_id)); 245 cdm_security_origin_map_.find(GetId(render_frame_id, cdm_id));
246 if (iter == cdm_security_origin_map_.end()) { 246 if (iter == cdm_security_origin_map_.end()) {
247 NOTREACHED(); 247 NOTREACHED();
248 SendSessionError(render_frame_id, cdm_id, session_id); 248 SendSessionError(render_frame_id, cdm_id, session_id);
249 return; 249 return;
250 } 250 }
251 GURL security_origin = iter->second; 251 GURL security_origin = iter->second;
252 252
253 RenderFrameHost* rfh = 253 RequestSessionPermission(render_frame_id,
254 RenderFrameHost::FromID(render_process_id_, render_frame_id); 254 security_origin,
255 WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); 255 cdm_id,
256 DCHECK(web_contents); 256 session_id,
257 GetContentClient()->browser()->RequestPermission( 257 mime_type,
258 content::PERMISSION_PROTECTED_MEDIA, 258 init_data);
259 web_contents,
260 0, // bridge id
261 security_origin,
262 // Only implemented for Android infobars which do not support
263 // user gestures.
264 true,
265 base::Bind(&BrowserCdmManager::CreateSessionIfPermitted,
266 this,
267 render_frame_id,
268 cdm_id,
269 session_id,
270 mime_type,
271 init_data));
272 } 259 }
273 260
274 void BrowserCdmManager::OnUpdateSession( 261 void BrowserCdmManager::OnUpdateSession(
275 int render_frame_id, 262 int render_frame_id,
276 int cdm_id, 263 int cdm_id,
277 uint32 session_id, 264 uint32 session_id,
278 const std::vector<uint8>& response) { 265 const std::vector<uint8>& response) {
279 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); 266 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id);
280 if (!cdm) { 267 if (!cdm) {
281 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; 268 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 351 DCHECK(task_runner_->RunsTasksOnCurrentThread());
365 352
366 cdm_map_.erase(id); 353 cdm_map_.erase(id);
367 cdm_security_origin_map_.erase(id); 354 cdm_security_origin_map_.erase(id);
368 if (cdm_cancel_permission_map_.count(id)) { 355 if (cdm_cancel_permission_map_.count(id)) {
369 cdm_cancel_permission_map_[id].Run(); 356 cdm_cancel_permission_map_[id].Run();
370 cdm_cancel_permission_map_.erase(id); 357 cdm_cancel_permission_map_.erase(id);
371 } 358 }
372 } 359 }
373 360
361 void BrowserCdmManager::RequestSessionPermission(
362 int render_frame_id,
363 const GURL& security_origin,
364 int cdm_id,
365 uint32 session_id,
366 const std::string& content_type,
367 const std::vector<uint8>& init_data) {
368 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
369 BrowserThread::PostTask(
370 BrowserThread::UI,
371 FROM_HERE,
372 base::Bind(&BrowserCdmManager::RequestSessionPermission,
373 this,
374 render_frame_id,
375 security_origin,
376 cdm_id,
377 session_id,
378 content_type,
379 init_data));
380 return;
381 }
382
383 RenderFrameHost* rfh =
384 RenderFrameHost::FromID(render_process_id_, render_frame_id);
385 WebContents* web_contents = WebContents::FromRenderFrameHost(rfh);
386 DCHECK(web_contents);
387 GetContentClient()->browser()->RequestPermission(
388 content::PERMISSION_PROTECTED_MEDIA,
389 web_contents,
390 0, // bridge id
391 security_origin,
392 // Only implemented for Android infobars which do not support
393 // user gestures.
394 true,
395 base::Bind(&BrowserCdmManager::CreateSessionIfPermitted,
396 this,
397 render_frame_id,
398 cdm_id,
399 session_id,
400 content_type,
401 init_data));
402 }
403
374 void BrowserCdmManager::CreateSessionIfPermitted( 404 void BrowserCdmManager::CreateSessionIfPermitted(
375 int render_frame_id, 405 int render_frame_id,
376 int cdm_id, 406 int cdm_id,
377 uint32 session_id, 407 uint32 session_id,
378 const std::string& content_type, 408 const std::string& content_type,
379 const std::vector<uint8>& init_data, 409 const std::vector<uint8>& init_data,
380 bool permitted) { 410 bool permitted) {
381 cdm_cancel_permission_map_.erase(GetId(render_frame_id, cdm_id)); 411 cdm_cancel_permission_map_.erase(GetId(render_frame_id, cdm_id));
382 if (!permitted) { 412 if (!permitted) {
383 SendSessionError(render_frame_id, cdm_id, session_id); 413 SendSessionError(render_frame_id, cdm_id, session_id);
384 return; 414 return;
385 } 415 }
386 416
387 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); 417 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id);
388 if (!cdm) { 418 if (!cdm) {
389 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id; 419 DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id;
390 SendSessionError(render_frame_id, cdm_id, session_id); 420 SendSessionError(render_frame_id, cdm_id, session_id);
391 return; 421 return;
392 } 422 }
393 423
394 // This could fail, in which case a SessionError will be fired. 424 // This could fail, in which case a SessionError will be fired.
395 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size()); 425 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size());
396 } 426 }
397 427
398 } // namespace content 428 } // namespace content
OLDNEW
« 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