Roll ANGLE bc75f36:ef9d63e
[chromium-blink-merge.git] / content / renderer / media / crypto / pepper_cdm_wrapper_impl.h
blob7f54f0c74dca638a1d4e521f196f1fb0f965fbf0
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 CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_
8 #if !defined(ENABLE_PEPPER_CDMS)
9 #error This file should only be included when ENABLE_PEPPER_CDMS is defined
10 #endif
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h"
17 namespace blink {
18 class WebHelperPlugin;
19 class WebLocalFrame;
22 namespace content {
24 class ContentDecryptorDelegate;
25 class PepperPluginInstanceImpl;
27 // Deleter for blink::WebHelperPlugin.
28 struct WebHelperPluginDeleter {
29 void operator()(blink::WebHelperPlugin* plugin) const;
32 // Implements a wrapper on blink::WebHelperPlugin so that the plugin gets
33 // destroyed properly. It owns all the objects derived from WebHelperPlugin
34 // (WebPlugin, PepperPluginInstanceImpl, ContentDecryptionDelegate), and will
35 // 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 // this object is destroyed.
39 // Implemented so that lower layers in Chromium don't need to be aware of
40 // blink:: objects.
41 class PepperCdmWrapperImpl : public PepperCdmWrapper {
42 public:
43 static scoped_ptr<PepperCdmWrapper> Create(blink::WebLocalFrame* frame,
44 const std::string& pluginType,
45 const GURL& security_origin);
47 virtual ~PepperCdmWrapperImpl();
49 // Returns the ContentDecryptorDelegate* associated with this plugin.
50 virtual ContentDecryptorDelegate* GetCdmDelegate() OVERRIDE;
52 private:
53 typedef scoped_ptr<blink::WebHelperPlugin, WebHelperPluginDeleter>
54 ScopedHelperPlugin;
56 // Takes ownership of |helper_plugin| and |plugin_instance|.
57 PepperCdmWrapperImpl(
58 ScopedHelperPlugin helper_plugin,
59 const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance);
61 ScopedHelperPlugin helper_plugin_;
62 scoped_refptr<PepperPluginInstanceImpl> plugin_instance_;
64 DISALLOW_COPY_AND_ASSIGN(PepperCdmWrapperImpl);
67 } // namespace content
69 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_