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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 virtual void release(); | 42 virtual void release(); |
43 virtual void initializeNewSession( | 43 virtual void initializeNewSession( |
44 const blink::WebString& init_data_type, | 44 const blink::WebString& init_data_type, |
45 const uint8* init_data, | 45 const uint8* init_data, |
46 size_t init_data_length, | 46 size_t init_data_length, |
47 const blink::WebString& session_type, | 47 const blink::WebString& session_type, |
48 blink::WebContentDecryptionModuleResult result); | 48 blink::WebContentDecryptionModuleResult result); |
49 virtual void update(const uint8* response, | 49 virtual void update(const uint8* response, |
50 size_t response_length, | 50 size_t response_length, |
51 blink::WebContentDecryptionModuleResult result); | 51 blink::WebContentDecryptionModuleResult result); |
| 52 virtual void close(blink::WebContentDecryptionModuleResult result); |
| 53 virtual void remove(blink::WebContentDecryptionModuleResult result); |
| 54 virtual void getUsableKeyIds(blink::WebContentDecryptionModuleResult result); |
| 55 |
| 56 // TODO(jrummell): Remove the next method once blink updated. |
52 virtual void release(blink::WebContentDecryptionModuleResult result); | 57 virtual void release(blink::WebContentDecryptionModuleResult result); |
53 | 58 |
54 // Callbacks. | 59 // Callbacks. |
55 void OnSessionMessage(const std::vector<uint8>& message, | 60 void OnSessionMessage(const std::vector<uint8>& message, |
56 const GURL& destination_url); | 61 const GURL& destination_url); |
| 62 void OnSessionKeysChange(bool has_additional_usable_key); |
| 63 void OnSessionExpirationChange(double new_expiry_time); |
57 void OnSessionReady(); | 64 void OnSessionReady(); |
58 void OnSessionClosed(); | 65 void OnSessionClosed(); |
59 void OnSessionError(media::MediaKeys::Exception exception_code, | 66 void OnSessionError(media::MediaKeys::Exception exception_code, |
60 uint32 system_code, | 67 uint32 system_code, |
61 const std::string& error_message); | 68 const std::string& error_message); |
62 | 69 |
63 private: | 70 private: |
64 typedef std::map<uint32, blink::WebContentDecryptionModuleResult> ResultMap; | 71 // Called when a new session is created. |
65 | 72 blink::WebContentDecryptionModuleResult::SessionStatus OnSessionInitialized( |
66 // These function are used as callbacks when CdmPromise resolves/rejects. | 73 const std::string& web_session_id); |
67 // |result_index| = kReservedIndex means that there is no | |
68 // WebContentDecryptionModuleResult. | |
69 void SessionCreated(uint32 result_index, const std::string& web_session_id); | |
70 void SessionUpdatedOrReleased(uint32 result_index); | |
71 void SessionError(uint32 result_index, | |
72 media::MediaKeys::Exception exception_code, | |
73 uint32 system_code, | |
74 const std::string& error_message); | |
75 | |
76 // As initializeNewSession(), update(), and release() get passed a | |
77 // WebContentDecryptionModuleResult, keep track of them since this class owns | |
78 // it and needs to keep them around until completed. Returns the index used | |
79 // to locate the WebContentDecryptionModuleResult when the operation is | |
80 // complete. | |
81 uint32 AddResult(blink::WebContentDecryptionModuleResult result); | |
82 | 74 |
83 scoped_refptr<CdmSessionAdapter> adapter_; | 75 scoped_refptr<CdmSessionAdapter> adapter_; |
84 | 76 |
85 // Non-owned pointer. | 77 // Non-owned pointer. |
86 Client* client_; | 78 Client* client_; |
87 | 79 |
88 // Web session ID is the app visible ID for this session generated by the CDM. | 80 // Web session ID is the app visible ID for this session generated by the CDM. |
89 // This value is not set until the CDM resolves the initializeNewSession() | 81 // This value is not set until the CDM resolves the initializeNewSession() |
90 // promise. | 82 // promise. |
91 std::string web_session_id_; | 83 std::string web_session_id_; |
92 | 84 |
93 // Don't pass more than 1 close() event to blink:: | 85 // Don't pass more than 1 close() event to blink:: |
94 // TODO(jrummell): Remove this once blink tests handle close() promise and | 86 // TODO(jrummell): Remove this once blink tests handle close() promise and |
95 // closed() event. | 87 // closed() event. |
96 bool is_closed_; | 88 bool is_closed_; |
97 | 89 |
98 // Keep track of all the outstanding WebContentDecryptionModuleResult objects. | |
99 uint32 next_available_result_index_; | |
100 ResultMap outstanding_results_; | |
101 | |
102 // Since promises will live until they are fired, use a weak reference when | 90 // Since promises will live until they are fired, use a weak reference when |
103 // creating a promise in case this class disappears before the promise | 91 // creating a promise in case this class disappears before the promise |
104 // actually fires. | 92 // actually fires. |
105 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_; | 93 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_; |
106 | 94 |
107 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); | 95 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); |
108 }; | 96 }; |
109 | 97 |
110 } // namespace content | 98 } // namespace content |
111 | 99 |
112 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ | 100 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ |
OLD | NEW |