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

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

Issue 171073002: Move SessionIdAdapter out of WebContentDecryptionModuleImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_ID_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_CDM_SESSION_ID_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
15 namespace content {
16 class WebContentDecryptionModuleSessionImpl;
17
18 // Forwards the session ID-based callbacks of the MediaKeys interface to the
19 // appropriate session object. Both WebContentDecryptionModuleImpl and
20 // WebContentDecryptionModuleSessionImpl will hold references to this object.
21 class CdmSessionIdAdapter : public base::RefCounted<CdmSessionIdAdapter> {
22 public:
23 CdmSessionIdAdapter();
24
25 // On success returns true.
26 bool Initialize(const std::string& key_system);
27
28 // Generates a unique internal session id.
29 uint32 GenerateSessionId();
30
31 // Adds a session to the internal map. Does not take ownership of the session.
32 void AddSession(uint32 session_id,
33 WebContentDecryptionModuleSessionImpl* session);
34
35 // Removes a session from the internal map.
36 void RemoveSession(uint32 session_id);
37
38 // Creates a session with the |content_type| and |init_data| provided.
39 bool CreateSession(uint32 session_id,
40 const std::string& content_type,
41 const uint8* init_data,
42 int init_data_length);
43
44 // Updates a session specified by |session_id| with |response|.
45 void UpdateSession(uint32 session_id,
46 const uint8* response,
47 int response_length);
48
49 // Releases the session specified by |session_id|.
50 void ReleaseSession(uint32 session_id);
51
52 // Returns the Decryptor associated with this CDM. May be NULL if no
53 // Decryptor associated with the MediaKeys object.
54 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
55 // after WebContentDecryptionModule is freed. http://crbug.com/330324
56 media::Decryptor* GetDecryptor();
57
58 private:
59 friend class base::RefCounted<CdmSessionIdAdapter>;
60 typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap;
61
62 ~CdmSessionIdAdapter();
63
64 // Callbacks for firing session events.
65 void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
66 void OnSessionMessage(uint32 session_id,
67 const std::vector<uint8>& message,
68 const std::string& destination_url);
69 void OnSessionReady(uint32 session_id);
70 void OnSessionClosed(uint32 session_id);
71 void OnSessionError(uint32 session_id,
72 media::MediaKeys::KeyError error_code,
73 int system_code);
74
75 // Helper function of the callbacks.
76 WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id);
77
78 // Keep ownership of MediaKeys.
79 scoped_ptr<media::MediaKeys> media_keys_;
80
81 base::WeakPtrFactory<CdmSessionIdAdapter> weak_ptr_factory_;
82
83 SessionMap sessions_;
84
85 // Session ID should be unique per renderer process for debugging purposes.
86 static uint32 next_session_id_;
87
88 DISALLOW_COPY_AND_ASSIGN(CdmSessionIdAdapter);
89 };
90
91 } // namespace content
92
93 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ID_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698