| 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 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
| 6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "media/blink/key_system_config_selector.h" | 14 #include "media/blink/key_system_config_selector.h" |
| 15 #include "media/blink/media_blink_export.h" | 15 #include "media/blink/media_blink_export.h" |
| 16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" | 16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class WebContentDecryptionModuleResult; | 20 class WebContentDecryptionModuleResult; |
| 21 struct WebMediaKeySystemConfiguration; | 21 struct WebMediaKeySystemConfiguration; |
| 22 class WebSecurityOrigin; | 22 class WebSecurityOrigin; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 CdmFactory* cdm_factory, | 38 CdmFactory* cdm_factory, |
| 39 MediaPermission* media_permission); | 39 MediaPermission* media_permission); |
| 40 ~WebEncryptedMediaClientImpl() override; | 40 ~WebEncryptedMediaClientImpl() override; |
| 41 | 41 |
| 42 // WebEncryptedMediaClient implementation. | 42 // WebEncryptedMediaClient implementation. |
| 43 void requestMediaKeySystemAccess( | 43 void requestMediaKeySystemAccess( |
| 44 blink::WebEncryptedMediaRequest request) override; | 44 blink::WebEncryptedMediaRequest request) override; |
| 45 | 45 |
| 46 // Create the CDM for |key_system| and |security_origin|. The caller owns | 46 // Create the CDM for |key_system| and |security_origin|. The caller owns |
| 47 // the created cdm (passed back using |result|). | 47 // the created cdm (passed back using |result|). |
| 48 void CreateCdm(const blink::WebString& key_system, | 48 void CreateCdm( |
| 49 const blink::WebSecurityOrigin& security_origin, | 49 const blink::WebString& key_system, |
| 50 const CdmConfig& cdm_config, | 50 const blink::WebSecurityOrigin& security_origin, |
| 51 scoped_ptr<blink::WebContentDecryptionModuleResult> result); | 51 const CdmConfig& cdm_config, |
| 52 std::unique_ptr<blink::WebContentDecryptionModuleResult> result); |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // Report usage of key system to UMA. There are 2 different counts logged: | 55 // Report usage of key system to UMA. There are 2 different counts logged: |
| 55 // 1. The key system is requested. | 56 // 1. The key system is requested. |
| 56 // 2. The requested key system and options are supported. | 57 // 2. The requested key system and options are supported. |
| 57 // Each stat is only reported once per renderer frame per key system. | 58 // Each stat is only reported once per renderer frame per key system. |
| 58 class Reporter; | 59 class Reporter; |
| 59 | 60 |
| 60 // Complete a requestMediaKeySystemAccess() request with a supported | 61 // Complete a requestMediaKeySystemAccess() request with a supported |
| 61 // accumulated configuration. | 62 // accumulated configuration. |
| 62 void OnRequestSucceeded( | 63 void OnRequestSucceeded( |
| 63 blink::WebEncryptedMediaRequest request, | 64 blink::WebEncryptedMediaRequest request, |
| 64 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, | 65 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, |
| 65 const CdmConfig& cdm_config); | 66 const CdmConfig& cdm_config); |
| 66 | 67 |
| 67 // Complete a requestMediaKeySystemAccess() request with an error message. | 68 // Complete a requestMediaKeySystemAccess() request with an error message. |
| 68 void OnRequestNotSupported(blink::WebEncryptedMediaRequest request, | 69 void OnRequestNotSupported(blink::WebEncryptedMediaRequest request, |
| 69 const blink::WebString& error_message); | 70 const blink::WebString& error_message); |
| 70 | 71 |
| 71 // Gets the Reporter for |key_system|. If it doesn't already exist, | 72 // Gets the Reporter for |key_system|. If it doesn't already exist, |
| 72 // create one. | 73 // create one. |
| 73 Reporter* GetReporter(const blink::WebString& key_system); | 74 Reporter* GetReporter(const blink::WebString& key_system); |
| 74 | 75 |
| 75 // Reporter singletons. | 76 // Reporter singletons. |
| 76 base::ScopedPtrHashMap<std::string, scoped_ptr<Reporter>> reporters_; | 77 base::ScopedPtrHashMap<std::string, std::unique_ptr<Reporter>> reporters_; |
| 77 | 78 |
| 78 base::Callback<bool(void)> are_secure_codecs_supported_cb_; | 79 base::Callback<bool(void)> are_secure_codecs_supported_cb_; |
| 79 CdmFactory* cdm_factory_; | 80 CdmFactory* cdm_factory_; |
| 80 KeySystemConfigSelector key_system_config_selector_; | 81 KeySystemConfigSelector key_system_config_selector_; |
| 81 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; | 82 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace media | 85 } // namespace media |
| 85 | 86 |
| 86 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 87 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
| OLD | NEW |