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

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

Issue 171073002: Move SessionIdAdapter out of WebContentDecryptionModuleImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes Created 6 years, 10 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
(Empty)
1 // Copyright 2014 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.
4
5 #ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "media/base/media_keys.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
ddorwin 2014/02/19 21:09:15 This one isn't used, right?
jrummell 2014/02/19 21:23:14 Done.
15 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h "
16
17 namespace content {
18 class WebContentDecryptionModuleSessionImpl;
19
20 // Owns the CDM instance and makes calls from session objects to the CDM.
21 // Forwards the session ID-based callbacks of the MediaKeys interface to the
22 // appropriate session object. Callers should hold references to this class
23 // as long as they need the CDM instance.
24 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
25 public:
26 CdmSessionAdapter();
27
28 // Returns true on success.
29 bool Initialize(const std::string& key_system);
30
31 // Creates a new session and adds it to the internal map. The caller owns the
32 // created session. RemoveSession() must be called when destroying it.
33 WebContentDecryptionModuleSessionImpl* CreateSession(
34 blink::WebContentDecryptionModuleSession::Client* client);
35
36 // Removes a session from the internal map.
37 void RemoveSession(uint32 session_id);
38
39 // Initializes the session specified by |session_id| with the |content_type|
40 // and |init_data| provided.
41 void InitializeNewSession(uint32 session_id,
42 const std::string& content_type,
43 const uint8* init_data,
44 int init_data_length);
45
46 // Updates the session specified by |session_id| with |response|.
47 void UpdateSession(uint32 session_id,
48 const uint8* response,
49 int response_length);
50
51 // Releases the session specified by |session_id|.
52 void ReleaseSession(uint32 session_id);
53
54 // Returns the Decryptor associated with this CDM. May be NULL if no
55 // Decryptor is associated with the MediaKeys object.
56 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
57 // after WebContentDecryptionModule is freed. http://crbug.com/330324
58 media::Decryptor* GetDecryptor();
59
60 private:
61 friend class base::RefCounted<CdmSessionAdapter>;
62 typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap;
63
64 ~CdmSessionAdapter();
65
66 // Callbacks for firing session events.
67 void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
68 void OnSessionMessage(uint32 session_id,
69 const std::vector<uint8>& message,
70 const std::string& destination_url);
71 void OnSessionReady(uint32 session_id);
72 void OnSessionClosed(uint32 session_id);
73 void OnSessionError(uint32 session_id,
74 media::MediaKeys::KeyError error_code,
75 int system_code);
76
77 // Helper function of the callbacks.
78 WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id);
79
80 scoped_ptr<media::MediaKeys> media_keys_;
81
82 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_;
83
84 SessionMap sessions_;
85
86 // Session ID should be unique per renderer process for debugging purposes.
87 static uint32 next_session_id_;
88
89 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter);
90 };
91
92 } // namespace content
93
94 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698