Mark //testing/perf target testonly.
[chromium-blink-merge.git] / media / blink / webcontentdecryptionmodule_impl.h
blob8febe73553405da6b9868570fdf92dd8895da2bb
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "media/base/media_export.h"
12 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
13 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
15 namespace blink {
16 #if defined(ENABLE_PEPPER_CDMS)
17 class WebLocalFrame;
18 #endif
19 class WebSecurityOrigin;
22 namespace media {
24 class CdmContext;
25 class CdmFactory;
26 class CdmSessionAdapter;
27 class WebContentDecryptionModuleSessionImpl;
29 class MEDIA_EXPORT WebContentDecryptionModuleImpl
30 : public blink::WebContentDecryptionModule {
31 public:
32 static void Create(CdmFactory* cdm_factory,
33 const blink::WebSecurityOrigin& security_origin,
34 const base::string16& key_system,
35 blink::WebContentDecryptionModuleResult result);
37 virtual ~WebContentDecryptionModuleImpl();
39 // blink::WebContentDecryptionModule implementation.
40 virtual blink::WebContentDecryptionModuleSession* createSession();
42 virtual void setServerCertificate(
43 const uint8* server_certificate,
44 size_t server_certificate_length,
45 blink::WebContentDecryptionModuleResult result);
47 // Returns the CdmContext associated with this CDM, which must not be nullptr.
48 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
49 // after WebContentDecryptionModule is freed. http://crbug.com/330324
50 CdmContext* GetCdmContext();
52 private:
53 // Takes reference to |adapter|.
54 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
56 scoped_refptr<CdmSessionAdapter> adapter_;
58 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
61 // Allow typecasting from blink type as this is the only implementation.
62 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
63 blink::WebContentDecryptionModule* cdm) {
64 return static_cast<WebContentDecryptionModuleImpl*>(cdm);
67 } // namespace media
69 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_