OLD | NEW |
---|---|
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
13 #include "content/common/media/cdm_messages.h" | 13 #include "content/common/media/cdm_messages.h" |
14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/browser/permission_manager.h" | 17 #include "content/public/browser/permission_manager.h" |
18 #include "content/public/browser/permission_type.h" | 18 #include "content/public/browser/permission_type.h" |
19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "media/base/bind_to_current_loop.h" | |
23 #include "media/base/browser_cdm.h" | 24 #include "media/base/browser_cdm.h" |
24 #include "media/base/browser_cdm_factory.h" | 25 #include "media/base/browser_cdm_factory.h" |
25 #include "media/base/cdm_promise.h" | 26 #include "media/base/cdm_promise.h" |
26 #include "media/base/limits.h" | 27 #include "media/base/limits.h" |
27 | 28 |
28 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
29 #include "content/public/common/renderer_preferences.h" | 30 #include "content/public/common/renderer_preferences.h" |
30 #endif | 31 #endif |
31 | 32 |
32 namespace content { | 33 namespace content { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 | 433 |
433 cdm->CloseSession(session_id, promise.Pass()); | 434 cdm->CloseSession(session_id, promise.Pass()); |
434 } | 435 } |
435 | 436 |
436 void BrowserCdmManager::OnDestroyCdm(int render_frame_id, int cdm_id) { | 437 void BrowserCdmManager::OnDestroyCdm(int render_frame_id, int cdm_id) { |
437 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 438 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
438 RemoveCdm(GetId(render_frame_id, cdm_id)); | 439 RemoveCdm(GetId(render_frame_id, cdm_id)); |
439 } | 440 } |
440 | 441 |
441 // Use a weak pointer here instead of |this| to avoid circular references. | 442 // Use a weak pointer here instead of |this| to avoid circular references. |
442 #define BROWSER_CDM_MANAGER_CB(func) \ | 443 #define BROWSER_CDM_MANAGER_CB(func) \ |
443 base::Bind(&BrowserCdmManager::func, weak_ptr_factory_.GetWeakPtr(), \ | 444 media::BindToCurrentLoop( \ |
444 render_frame_id, cdm_id) | 445 base::Bind(&BrowserCdmManager::func, weak_ptr_factory_.GetWeakPtr(), \ |
446 render_frame_id, cdm_id)) | |
xhwang
2015/04/20 18:21:12
This will cause those callbacks to be posted alway
| |
445 | 447 |
446 void BrowserCdmManager::AddCdm(int render_frame_id, | 448 void BrowserCdmManager::AddCdm(int render_frame_id, |
447 int cdm_id, | 449 int cdm_id, |
448 const std::string& key_system, | 450 const std::string& key_system, |
449 const GURL& security_origin) { | 451 const GURL& security_origin) { |
450 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 452 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
451 DCHECK(!GetCdm(render_frame_id, cdm_id)); | 453 DCHECK(!GetCdm(render_frame_id, cdm_id)); |
452 | 454 |
453 bool use_secure_surface = false; | 455 bool use_secure_surface = false; |
454 | 456 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 } | 584 } |
583 | 585 |
584 // Only the temporary session type is supported in browser CDM path. | 586 // Only the temporary session type is supported in browser CDM path. |
585 // TODO(xhwang): Add SessionType support if needed. | 587 // TODO(xhwang): Add SessionType support if needed. |
586 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, | 588 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, |
587 init_data_type, &init_data[0], | 589 init_data_type, &init_data[0], |
588 init_data.size(), promise.Pass()); | 590 init_data.size(), promise.Pass()); |
589 } | 591 } |
590 | 592 |
591 } // namespace content | 593 } // namespace content |
OLD | NEW |