Files.app: Remove wait for startup animation.
[chromium-blink-merge.git] / media / blink / webencryptedmediaclient_impl.h
blobd34f27252ec052004b379582eac972bca4fc09af
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_
6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "media/base/media_export.h"
15 #include "media/blink/key_system_config_selector.h"
16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h"
18 namespace blink {
20 class WebContentDecryptionModuleResult;
21 struct WebMediaKeySystemConfiguration;
22 class WebSecurityOrigin;
24 } // namespace blink
26 namespace media {
28 struct CdmConfig;
29 class CdmFactory;
30 class KeySystems;
31 class MediaPermission;
33 class MEDIA_EXPORT WebEncryptedMediaClientImpl
34 : public blink::WebEncryptedMediaClient {
35 public:
36 WebEncryptedMediaClientImpl(
37 base::Callback<bool(void)> are_secure_codecs_supported_cb,
38 CdmFactory* cdm_factory,
39 MediaPermission* media_permission);
40 virtual ~WebEncryptedMediaClientImpl();
42 // WebEncryptedMediaClient implementation.
43 virtual void requestMediaKeySystemAccess(
44 blink::WebEncryptedMediaRequest request);
46 // Create the CDM for |key_system| and |security_origin|. The caller owns
47 // the created cdm (passed back using |result|).
48 void CreateCdm(const blink::WebString& key_system,
49 const blink::WebSecurityOrigin& security_origin,
50 const CdmConfig& cdm_config,
51 blink::WebContentDecryptionModuleResult result);
53 private:
54 // Report usage of key system to UMA. There are 2 different counts logged:
55 // 1. The key system is requested.
56 // 2. The requested key system and options are supported.
57 // Each stat is only reported once per renderer frame per key system.
58 class Reporter;
60 // Complete a requestMediaKeySystemAccess() request with a supported
61 // accumulated configuration.
62 void OnRequestSucceeded(
63 blink::WebEncryptedMediaRequest request,
64 const blink::WebMediaKeySystemConfiguration& accumulated_configuration,
65 const CdmConfig& cdm_config);
67 // Complete a requestMediaKeySystemAccess() request with an error message.
68 void OnRequestNotSupported(blink::WebEncryptedMediaRequest request,
69 const blink::WebString& error_message);
71 // Gets the Reporter for |key_system|. If it doesn't already exist,
72 // create one.
73 Reporter* GetReporter(const blink::WebString& key_system);
75 // Reporter singletons.
76 base::ScopedPtrHashMap<std::string, scoped_ptr<Reporter>> reporters_;
78 base::Callback<bool(void)> are_secure_codecs_supported_cb_;
79 CdmFactory* cdm_factory_;
80 KeySystemConfigSelector key_system_config_selector_;
81 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_;
84 } // namespace media
86 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_