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

Side by Side Diff: media/blink/webcontentdecryptionmodule_impl.h

Issue 2402563002: Keep reference to CDM to avoid it's premature destruction (Closed)
Patch Set: nits Created 4 years, 2 months 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 | « media/blink/cdm_session_adapter.cc ('k') | media/blink/webcontentdecryptionmodule_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ 6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "media/blink/media_blink_export.h" 16 #include "media/blink/media_blink_export.h"
17 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" 17 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
18 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 18 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
19 19
20 namespace blink { 20 namespace blink {
21 #if defined(ENABLE_PEPPER_CDMS) 21 #if defined(ENABLE_PEPPER_CDMS)
22 class WebLocalFrame; 22 class WebLocalFrame;
23 #endif 23 #endif
24 class WebSecurityOrigin; 24 class WebSecurityOrigin;
25 } 25 }
26 26
27 namespace media { 27 namespace media {
28 28
29 struct CdmConfig; 29 struct CdmConfig;
30 class CdmContext;
31 class CdmFactory; 30 class CdmFactory;
32 class CdmSessionAdapter; 31 class CdmSessionAdapter;
32 class MediaKeys;
33 class WebContentDecryptionModuleSessionImpl; 33 class WebContentDecryptionModuleSessionImpl;
34 34
35 class MEDIA_BLINK_EXPORT WebContentDecryptionModuleImpl 35 class MEDIA_BLINK_EXPORT WebContentDecryptionModuleImpl
36 : public blink::WebContentDecryptionModule { 36 : public blink::WebContentDecryptionModule {
37 public: 37 public:
38 static void Create( 38 static void Create(
39 CdmFactory* cdm_factory, 39 CdmFactory* cdm_factory,
40 const base::string16& key_system, 40 const base::string16& key_system,
41 const blink::WebSecurityOrigin& security_origin, 41 const blink::WebSecurityOrigin& security_origin,
42 const CdmConfig& cdm_config, 42 const CdmConfig& cdm_config,
43 std::unique_ptr<blink::WebContentDecryptionModuleResult> result); 43 std::unique_ptr<blink::WebContentDecryptionModuleResult> result);
44 44
45 ~WebContentDecryptionModuleImpl() override; 45 ~WebContentDecryptionModuleImpl() override;
46 46
47 // blink::WebContentDecryptionModule implementation. 47 // blink::WebContentDecryptionModule implementation.
48 blink::WebContentDecryptionModuleSession* createSession() override; 48 blink::WebContentDecryptionModuleSession* createSession() override;
49 49
50 void setServerCertificate( 50 void setServerCertificate(
51 const uint8_t* server_certificate, 51 const uint8_t* server_certificate,
52 size_t server_certificate_length, 52 size_t server_certificate_length,
53 blink::WebContentDecryptionModuleResult result) override; 53 blink::WebContentDecryptionModuleResult result) override;
54 54
55 // Returns the CdmContext associated with this CDM, which must not be nullptr. 55 // Returns a reference to the CDM used by |adapter_|.
56 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor 56 scoped_refptr<MediaKeys> GetCdm();
57 // after WebContentDecryptionModule is freed. http://crbug.com/330324
58 CdmContext* GetCdmContext();
59 57
60 private: 58 private:
61 friend CdmSessionAdapter; 59 friend CdmSessionAdapter;
62 60
63 // Takes reference to |adapter|. 61 // Takes reference to |adapter|.
64 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter); 62 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
65 63
66 scoped_refptr<CdmSessionAdapter> adapter_; 64 scoped_refptr<CdmSessionAdapter> adapter_;
67 65
68 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl); 66 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
69 }; 67 };
70 68
71 // Allow typecasting from blink type as this is the only implementation. 69 // Allow typecasting from blink type as this is the only implementation.
72 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl( 70 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
73 blink::WebContentDecryptionModule* cdm) { 71 blink::WebContentDecryptionModule* cdm) {
74 return static_cast<WebContentDecryptionModuleImpl*>(cdm); 72 return static_cast<WebContentDecryptionModuleImpl*>(cdm);
75 } 73 }
76 74
77 } // namespace media 75 } // namespace media
78 76
79 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ 77 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
OLDNEW
« no previous file with comments | « media/blink/cdm_session_adapter.cc ('k') | media/blink/webcontentdecryptionmodule_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698