OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "media/base/media_keys.h" | 13 #include "media/base/media_keys.h" |
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h
" | 14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h
" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 class MediaKeys; | 18 class MediaKeys; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 class WebContentDecryptionModuleSessionImpl | 23 class WebContentDecryptionModuleSessionImpl |
24 : public blink::WebContentDecryptionModuleSession { | 24 : public blink::WebContentDecryptionModuleSession { |
25 public: | 25 public: |
26 typedef base::Callback<void(uint32 reference_id)> SessionClosedCB; | 26 typedef base::Callback<void(uint32 session_id)> SessionClosedCB; |
27 | 27 |
28 WebContentDecryptionModuleSessionImpl( | 28 WebContentDecryptionModuleSessionImpl( |
| 29 uint32 session_id, |
29 media::MediaKeys* media_keys, | 30 media::MediaKeys* media_keys, |
30 Client* client, | 31 Client* client, |
31 const SessionClosedCB& session_closed_cb); | 32 const SessionClosedCB& session_closed_cb); |
32 virtual ~WebContentDecryptionModuleSessionImpl(); | 33 virtual ~WebContentDecryptionModuleSessionImpl(); |
33 | 34 |
34 // blink::WebContentDecryptionModuleSession implementation. | 35 // blink::WebContentDecryptionModuleSession implementation. |
35 virtual blink::WebString sessionId() const OVERRIDE; | 36 virtual blink::WebString sessionId() const OVERRIDE; |
36 virtual void generateKeyRequest(const blink::WebString& mime_type, | 37 virtual void generateKeyRequest(const blink::WebString& mime_type, |
37 const uint8* init_data, | 38 const uint8* init_data, |
38 size_t init_data_length) OVERRIDE; | 39 size_t init_data_length) OVERRIDE; |
39 virtual void update(const uint8* response, size_t response_length) OVERRIDE; | 40 virtual void update(const uint8* response, size_t response_length) OVERRIDE; |
40 virtual void close() OVERRIDE; | 41 virtual void close() OVERRIDE; |
41 | 42 |
42 const std::string& session_id() const { return session_id_; } | |
43 | |
44 uint32 reference_id() const { return reference_id_; } | |
45 | |
46 // Callbacks. | 43 // Callbacks. |
47 void OnSessionCreated(const std::string& session_id); | 44 void OnSessionCreated(const std::string& web_session_id); |
48 void OnSessionMessage(const std::vector<uint8>& message, | 45 void OnSessionMessage(const std::vector<uint8>& message, |
49 const std::string& destination_url); | 46 const std::string& destination_url); |
50 void OnSessionReady(); | 47 void OnSessionReady(); |
51 void OnSessionClosed(); | 48 void OnSessionClosed(); |
52 void OnSessionError(media::MediaKeys::KeyError error_code, int system_code); | 49 void OnSessionError(media::MediaKeys::KeyError error_code, int system_code); |
53 | 50 |
54 private: | 51 private: |
55 // Non-owned pointers. | 52 // Non-owned pointers. |
56 media::MediaKeys* media_keys_; | 53 media::MediaKeys* media_keys_; |
57 Client* client_; | 54 Client* client_; |
58 | 55 |
59 SessionClosedCB session_closed_cb_; | 56 SessionClosedCB session_closed_cb_; |
60 | 57 |
61 // Session ID is the user visible ID for this session generated by the CDM. | 58 // Web session ID is the app visible ID for this session generated by the CDM. |
62 // This value is not set until the CDM calls OnSessionCreated(). | 59 // This value is not set until the CDM calls OnSessionCreated(). |
63 std::string session_id_; | 60 blink::WebString web_session_id_; |
64 | 61 |
65 // Reference ID is used to uniquely track this object so that CDM callbacks | 62 // Session ID is used to uniquely track this object so that CDM callbacks |
66 // can get routed to the correct object. | 63 // can get routed to the correct object. |
67 const uint32 reference_id_; | 64 const uint32 session_id_; |
68 | |
69 // Reference ID should be unique per renderer process for debugging purposes. | |
70 static uint32 next_reference_id_; | |
71 | 65 |
72 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); | 66 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); |
73 }; | 67 }; |
74 | 68 |
75 } // namespace content | 69 } // namespace content |
76 | 70 |
77 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 71 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
OLD | NEW |