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 CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ |
7 | 7 |
8 #if !defined(ENABLE_PEPPER_CDMS) | 8 #if !defined(ENABLE_PEPPER_CDMS) |
9 #error This file should only be included when ENABLE_PEPPER_CDMS is defined | 9 #error This file should only be included when ENABLE_PEPPER_CDMS is defined |
10 #endif | 10 #endif |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h" | 15 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h" |
| 16 // TODO(dcheng): Temporary. Convert back to a forward declare. |
| 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 class WebFrame; | |
19 class WebHelperPlugin; | 20 class WebHelperPlugin; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 class ContentDecryptorDelegate; | 25 class ContentDecryptorDelegate; |
25 class PepperPluginInstanceImpl; | 26 class PepperPluginInstanceImpl; |
26 | 27 |
27 // Deleter for blink::WebHelperPlugin. | 28 // Deleter for blink::WebHelperPlugin. |
28 struct WebHelperPluginDeleter { | 29 struct WebHelperPluginDeleter { |
29 void operator()(blink::WebHelperPlugin* plugin) const; | 30 void operator()(blink::WebHelperPlugin* plugin) const; |
30 }; | 31 }; |
31 | 32 |
32 // Implements a wrapper on blink::WebHelperPlugin so that the plugin gets | 33 // Implements a wrapper on blink::WebHelperPlugin so that the plugin gets |
33 // destroyed properly. It owns all the objects derived from WebHelperPlugin | 34 // destroyed properly. It owns all the objects derived from WebHelperPlugin |
34 // (WebPlugin, PepperPluginInstanceImpl, ContentDecryptionDelegate), and will | 35 // (WebPlugin, PepperPluginInstanceImpl, ContentDecryptionDelegate), and will |
35 // free them as necessary when this wrapper is destroyed. In particular, it | 36 // free them as necessary when this wrapper is destroyed. In particular, it |
36 // takes a reference to PepperPluginInstanceImpl so it won't go away until | 37 // takes a reference to PepperPluginInstanceImpl so it won't go away until |
37 // this object is destroyed. | 38 // this object is destroyed. |
38 // | 39 // |
39 // Implemented so that lower layers in Chromium don't need to be aware of | 40 // Implemented so that lower layers in Chromium don't need to be aware of |
40 // blink:: objects. | 41 // blink:: objects. |
41 class PepperCdmWrapperImpl : public PepperCdmWrapper { | 42 class PepperCdmWrapperImpl : public PepperCdmWrapper { |
42 public: | 43 public: |
43 static scoped_ptr<PepperCdmWrapper> Create(blink::WebFrame* frame, | 44 static scoped_ptr<PepperCdmWrapper> Create(blink::WebLocalFrame* frame, |
44 const std::string& pluginType); | 45 const std::string& pluginType); |
45 | 46 |
46 virtual ~PepperCdmWrapperImpl(); | 47 virtual ~PepperCdmWrapperImpl(); |
47 | 48 |
48 // Returns the ContentDecryptorDelegate* associated with this plugin. | 49 // Returns the ContentDecryptorDelegate* associated with this plugin. |
49 virtual ContentDecryptorDelegate* GetCdmDelegate() OVERRIDE; | 50 virtual ContentDecryptorDelegate* GetCdmDelegate() OVERRIDE; |
50 | 51 |
51 private: | 52 private: |
52 typedef scoped_ptr<blink::WebHelperPlugin, WebHelperPluginDeleter> | 53 typedef scoped_ptr<blink::WebHelperPlugin, WebHelperPluginDeleter> |
53 ScopedHelperPlugin; | 54 ScopedHelperPlugin; |
54 | 55 |
55 // Takes ownership of |helper_plugin| and |plugin_instance|. | 56 // Takes ownership of |helper_plugin| and |plugin_instance|. |
56 PepperCdmWrapperImpl( | 57 PepperCdmWrapperImpl( |
57 ScopedHelperPlugin helper_plugin, | 58 ScopedHelperPlugin helper_plugin, |
58 const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance); | 59 const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance); |
59 | 60 |
60 ScopedHelperPlugin helper_plugin_; | 61 ScopedHelperPlugin helper_plugin_; |
61 scoped_refptr<PepperPluginInstanceImpl> plugin_instance_; | 62 scoped_refptr<PepperPluginInstanceImpl> plugin_instance_; |
62 | 63 |
63 DISALLOW_COPY_AND_ASSIGN(PepperCdmWrapperImpl); | 64 DISALLOW_COPY_AND_ASSIGN(PepperCdmWrapperImpl); |
64 }; | 65 }; |
65 | 66 |
66 } // namespace content | 67 } // namespace content |
67 | 68 |
68 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ | 69 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_ |
OLD | NEW |