Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1086)

Side by Side Diff: content/renderer/media/webcontentdecryptionmodulesession_impl.h

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: helpers Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "content/renderer/media/webcontentdecryptionmoduleresult_helper.h"
16 #include "media/base/media_keys.h" 17 #include "media/base/media_keys.h"
17 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h " 18 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h "
18 #include "third_party/WebKit/public/platform/WebString.h" 19 #include "third_party/WebKit/public/platform/WebString.h"
19 20
20 namespace media { 21 namespace media {
21 class MediaKeys; 22 class MediaKeys;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 class CdmSessionAdapter; 26 class CdmSessionAdapter;
(...skipping 16 matching lines...) Expand all
42 virtual void release(); 43 virtual void release();
43 virtual void initializeNewSession( 44 virtual void initializeNewSession(
44 const blink::WebString& init_data_type, 45 const blink::WebString& init_data_type,
45 const uint8* init_data, 46 const uint8* init_data,
46 size_t init_data_length, 47 size_t init_data_length,
47 const blink::WebString& session_type, 48 const blink::WebString& session_type,
48 blink::WebContentDecryptionModuleResult result); 49 blink::WebContentDecryptionModuleResult result);
49 virtual void update(const uint8* response, 50 virtual void update(const uint8* response,
50 size_t response_length, 51 size_t response_length,
51 blink::WebContentDecryptionModuleResult result); 52 blink::WebContentDecryptionModuleResult result);
53 virtual void close(blink::WebContentDecryptionModuleResult result);
54 virtual void remove(blink::WebContentDecryptionModuleResult result);
55 virtual void getUsableKeyIds(blink::WebContentDecryptionModuleResult result);
56
57 // TODO(jrummell): Remove the next method once blink updated.
52 virtual void release(blink::WebContentDecryptionModuleResult result); 58 virtual void release(blink::WebContentDecryptionModuleResult result);
53 59
54 // Callbacks. 60 // Callbacks.
55 void OnSessionMessage(const std::vector<uint8>& message, 61 void OnSessionMessage(const std::vector<uint8>& message,
56 const GURL& destination_url); 62 const GURL& destination_url);
63 void OnSessionKeysChange(bool has_additional_usable_key);
64 void OnSessionExpirationChange(double new_expiry_time);
57 void OnSessionReady(); 65 void OnSessionReady();
58 void OnSessionClosed(); 66 void OnSessionClosed();
59 void OnSessionError(media::MediaKeys::Exception exception_code, 67 void OnSessionError(media::MediaKeys::Exception exception_code,
60 uint32 system_code, 68 uint32 system_code,
61 const std::string& error_message); 69 const std::string& error_message);
62 70
63 private: 71 private:
64 typedef std::map<uint32, blink::WebContentDecryptionModuleResult> ResultMap;
65
66 // These function are used as callbacks when CdmPromise resolves/rejects. 72 // These function are used as callbacks when CdmPromise resolves/rejects.
67 // |result_index| = kReservedIndex means that there is no 73 // |result_index| = kReservedIndex means that there is no
68 // WebContentDecryptionModuleResult. 74 // WebContentDecryptionModuleResult.
69 void SessionCreated(uint32 result_index, const std::string& web_session_id); 75 void OnSessionInitialized(uint32 result_index,
70 void SessionUpdatedOrReleased(uint32 result_index); 76 const std::string& web_session_id);
71 void SessionError(uint32 result_index, 77 void OnPromiseRejected(uint32 result_index,
72 media::MediaKeys::Exception exception_code, 78 media::MediaKeys::Exception exception_code,
73 uint32 system_code, 79 uint32 system_code,
74 const std::string& error_message); 80 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 81
83 scoped_refptr<CdmSessionAdapter> adapter_; 82 scoped_refptr<CdmSessionAdapter> adapter_;
84 83
85 // Non-owned pointer. 84 // Non-owned pointer.
86 Client* client_; 85 Client* client_;
87 86
88 // Web session ID is the app visible ID for this session generated by the CDM. 87 // 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() 88 // This value is not set until the CDM resolves the initializeNewSession()
90 // promise. 89 // promise.
91 std::string web_session_id_; 90 std::string web_session_id_;
92 91
93 // Don't pass more than 1 close() event to blink:: 92 // Don't pass more than 1 close() event to blink::
94 // TODO(jrummell): Remove this once blink tests handle close() promise and 93 // TODO(jrummell): Remove this once blink tests handle close() promise and
95 // closed() event. 94 // closed() event.
96 bool is_closed_; 95 bool is_closed_;
97 96
98 // Keep track of all the outstanding WebContentDecryptionModuleResult objects. 97 // Keep track of all the outstanding WebContentDecryptionModuleResult objects.
99 uint32 next_available_result_index_; 98 WebContentDecryptionModuleResultHelper outstanding_results_;
100 ResultMap outstanding_results_;
101 99
102 // Since promises will live until they are fired, use a weak reference when 100 // 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 101 // creating a promise in case this class disappears before the promise
104 // actually fires. 102 // actually fires.
105 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_; 103 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_;
106 104
107 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl); 105 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl);
108 }; 106 };
109 107
110 } // namespace content 108 } // namespace content
111 109
112 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_ 110 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698