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 CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "media/base/media_keys.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
23 class WebContentDecryptionModuleSessionImpl
24 : public blink::WebContentDecryptionModuleSession
{
26 typedef base::Callback
<void(uint32 session_id
)> SessionClosedCB
;
28 WebContentDecryptionModuleSessionImpl(
30 media::MediaKeys
* media_keys
,
32 const SessionClosedCB
& session_closed_cb
);
33 virtual ~WebContentDecryptionModuleSessionImpl();
35 // blink::WebContentDecryptionModuleSession implementation.
36 virtual blink::WebString
sessionId() const;
37 virtual void initializeNewSession(const blink::WebString
& mime_type
,
38 const uint8
* init_data
,
39 size_t init_data_length
);
40 virtual void update(const uint8
* response
, size_t response_length
);
41 virtual void release();
43 // TODO(xhwang): Drop generateKeyRequest() and close() after blink side is
45 virtual void generateKeyRequest(const blink::WebString
& mime_type
,
46 const uint8
* init_data
,
47 size_t init_data_length
);
51 void OnSessionCreated(const std::string
& web_session_id
);
52 void OnSessionMessage(const std::vector
<uint8
>& message
,
53 const std::string
& destination_url
);
54 void OnSessionReady();
55 void OnSessionClosed();
56 void OnSessionError(media::MediaKeys::KeyError error_code
, int system_code
);
59 // Non-owned pointers.
60 media::MediaKeys
* media_keys_
;
63 SessionClosedCB session_closed_cb_
;
65 // Web session ID is the app visible ID for this session generated by the CDM.
66 // This value is not set until the CDM calls OnSessionCreated().
67 blink::WebString web_session_id_
;
69 // Session ID is used to uniquely track this object so that CDM callbacks
70 // can get routed to the correct object.
71 const uint32 session_id_
;
73 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl
);
76 } // namespace content
78 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_