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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/cdm_session_adapter.h
diff --git a/content/renderer/media/cdm_session_adapter.h b/content/renderer/media/cdm_session_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e2dd35ace25fb4b4cc61bddb5b4bafafef2e38b
--- /dev/null
+++ b/content/renderer/media/cdm_session_adapter.h
@@ -0,0 +1,94 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
+#define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "media/base/media_keys.h"
+#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.
+#include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h"
+
+namespace content {
+class WebContentDecryptionModuleSessionImpl;
+
+// Owns the CDM instance and makes calls from session objects to the CDM.
+// Forwards the session ID-based callbacks of the MediaKeys interface to the
+// appropriate session object. Callers should hold references to this class
+// as long as they need the CDM instance.
+class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
+ public:
+ CdmSessionAdapter();
+
+ // Returns true on success.
+ bool Initialize(const std::string& key_system);
+
+ // Creates a new session and adds it to the internal map. The caller owns the
+ // created session. RemoveSession() must be called when destroying it.
+ WebContentDecryptionModuleSessionImpl* CreateSession(
+ blink::WebContentDecryptionModuleSession::Client* client);
+
+ // Removes a session from the internal map.
+ void RemoveSession(uint32 session_id);
+
+ // Initializes the session specified by |session_id| with the |content_type|
+ // and |init_data| provided.
+ void InitializeNewSession(uint32 session_id,
+ const std::string& content_type,
+ const uint8* init_data,
+ int init_data_length);
+
+ // Updates the session specified by |session_id| with |response|.
+ void UpdateSession(uint32 session_id,
+ const uint8* response,
+ int response_length);
+
+ // Releases the session specified by |session_id|.
+ void ReleaseSession(uint32 session_id);
+
+ // Returns the Decryptor associated with this CDM. May be NULL if no
+ // Decryptor is associated with the MediaKeys object.
+ // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
+ // after WebContentDecryptionModule is freed. http://crbug.com/330324
+ media::Decryptor* GetDecryptor();
+
+ private:
+ friend class base::RefCounted<CdmSessionAdapter>;
+ typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap;
+
+ ~CdmSessionAdapter();
+
+ // Callbacks for firing session events.
+ void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
+ void OnSessionMessage(uint32 session_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url);
+ void OnSessionReady(uint32 session_id);
+ void OnSessionClosed(uint32 session_id);
+ void OnSessionError(uint32 session_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code);
+
+ // Helper function of the callbacks.
+ WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id);
+
+ scoped_ptr<media::MediaKeys> media_keys_;
+
+ base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_;
+
+ SessionMap sessions_;
+
+ // Session ID should be unique per renderer process for debugging purposes.
+ static uint32 next_session_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698