Handle createCDM() when frame destroyed
[chromium-blink-merge.git] / media / blink / webencryptedmediaclient_impl.h
blob7b606dc448477a473de426c833fbce434c04eb27
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/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "media/base/cdm_factory.h"
14 #include "media/base/media_export.h"
15 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h"
17 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
19 namespace media {
21 class MediaPermission;
23 class MEDIA_EXPORT WebEncryptedMediaClientImpl
24 : public blink::WebEncryptedMediaClient {
25 public:
26 WebEncryptedMediaClientImpl(scoped_ptr<CdmFactory> cdm_factory,
27 MediaPermission* media_permission);
28 virtual ~WebEncryptedMediaClientImpl();
30 // WebEncryptedMediaClient implementation.
31 virtual void requestMediaKeySystemAccess(
32 blink::WebEncryptedMediaRequest request);
34 // Create the CDM for |key_system| and |security_origin|. The caller owns
35 // the created cdm (passed back using |result|).
36 void CreateCdm(const blink::WebString& key_system,
37 const blink::WebSecurityOrigin& security_origin,
38 blink::WebContentDecryptionModuleResult result);
40 private:
41 // Report usage of key system to UMA. There are 2 different counts logged:
42 // 1. The key system is requested.
43 // 2. The requested key system and options are supported.
44 // Each stat is only reported once per renderer frame per key system.
45 class Reporter;
47 // Gets the Reporter for |key_system|. If it doesn't already exist,
48 // create one.
49 Reporter* GetReporter(const std::string& key_system);
51 // Key system <-> Reporter map.
52 typedef base::ScopedPtrHashMap<std::string, Reporter> Reporters;
53 Reporters reporters_;
55 scoped_ptr<CdmFactory> cdm_factory_;
57 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_;
60 } // namespace media
62 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_