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_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "media/base/media_keys.h"
16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h"
17 #include "third_party/WebKit/public/platform/WebString.h"
21 class CdmSessionAdapter
;
24 class WebContentDecryptionModuleSessionImpl
25 : public blink::WebContentDecryptionModuleSession
{
27 WebContentDecryptionModuleSessionImpl(
28 const scoped_refptr
<CdmSessionAdapter
>& adapter
);
29 virtual ~WebContentDecryptionModuleSessionImpl();
31 // blink::WebContentDecryptionModuleSession implementation.
32 virtual void setClientInterface(Client
* client
);
33 virtual blink::WebString
sessionId() const;
34 // TODO(jrummell): Remove the next 3 methods once blink updated.
35 virtual void initializeNewSession(const blink::WebString
& mime_type
,
36 const uint8
* init_data
,
37 size_t init_data_length
);
38 virtual void update(const uint8
* response
, size_t response_length
);
39 virtual void release();
40 virtual void initializeNewSession(
41 const blink::WebString
& init_data_type
,
42 const uint8
* init_data
,
43 size_t init_data_length
,
44 const blink::WebString
& session_type
,
45 blink::WebContentDecryptionModuleResult result
);
46 virtual void load(const blink::WebString
& session_id
,
47 blink::WebContentDecryptionModuleResult result
);
48 virtual void update(const uint8
* response
,
49 size_t response_length
,
50 blink::WebContentDecryptionModuleResult result
);
51 virtual void close(blink::WebContentDecryptionModuleResult result
);
52 virtual void remove(blink::WebContentDecryptionModuleResult result
);
53 virtual void getUsableKeyIds(blink::WebContentDecryptionModuleResult result
);
55 // TODO(jrummell): Remove the next method once blink updated.
56 virtual void release(blink::WebContentDecryptionModuleResult result
);
59 void OnSessionMessage(const std::vector
<uint8
>& message
,
60 const GURL
& destination_url
);
61 void OnSessionKeysChange(bool has_additional_usable_key
);
62 void OnSessionExpirationUpdate(const base::Time
& new_expiry_time
);
63 void OnSessionClosed();
66 // Called when a new session is created.
67 blink::WebContentDecryptionModuleResult::SessionStatus
OnSessionInitialized(
68 const std::string
& web_session_id
);
70 scoped_refptr
<CdmSessionAdapter
> adapter_
;
75 // Web session ID is the app visible ID for this session generated by the CDM.
76 // This value is not set until the CDM resolves the initializeNewSession()
78 std::string web_session_id_
;
80 // Don't pass more than 1 close() event to blink::
81 // TODO(jrummell): Remove this once blink tests handle close() promise and
85 // Since promises will live until they are fired, use a weak reference when
86 // creating a promise in case this class disappears before the promise
88 base::WeakPtrFactory
<WebContentDecryptionModuleSessionImpl
> weak_ptr_factory_
;
90 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl
);
95 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_