Commit 87cebfb0 authored by jrummell@chromium.org's avatar jrummell@chromium.org

Set callback interface on WebCDMSessionImpl after creation.

In order to allow MediaKeySession to be created only when resolving
the promise, add the ability to set the client callback interface on
WebContentDecryptionModuleSessionImpl after the object is created.

This will be used in a subsequent CL to update blink. Requires a third
change to remove the old methods once blink is updated.

BUG=358271
TEST=EME layouts tests pass

Review URL: https://codereview.chromium.org/380953002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283854 0039d316-1c4b-4281-b951-d872f2087c98
parent 981934cd
...@@ -51,9 +51,8 @@ bool CdmSessionAdapter::Initialize( ...@@ -51,9 +51,8 @@ bool CdmSessionAdapter::Initialize(
return media_keys_; return media_keys_;
} }
WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession( WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() {
blink::WebContentDecryptionModuleSession::Client* client) { return new WebContentDecryptionModuleSessionImpl(this);
return new WebContentDecryptionModuleSessionImpl(client, this);
} }
bool CdmSessionAdapter::RegisterSession( bool CdmSessionAdapter::RegisterSession(
......
...@@ -50,8 +50,7 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { ...@@ -50,8 +50,7 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
// Creates a new session and adds it to the internal map. The caller owns the // Creates a new session and adds it to the internal map. The caller owns the
// created session. RemoveSession() must be called when destroying it, if // created session. RemoveSession() must be called when destroying it, if
// RegisterSession() was called. // RegisterSession() was called.
WebContentDecryptionModuleSessionImpl* CreateSession( WebContentDecryptionModuleSessionImpl* CreateSession();
blink::WebContentDecryptionModuleSession::Client* client);
// Adds a session to the internal map. Called once the session is successfully // Adds a session to the internal map. Called once the session is successfully
// initialized. Returns true if the session was registered, false if there is // initialized. Returns true if the session was registered, false if there is
......
...@@ -84,10 +84,17 @@ WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { ...@@ -84,10 +84,17 @@ WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() {
} }
// The caller owns the created session. // The caller owns the created session.
blink::WebContentDecryptionModuleSession*
WebContentDecryptionModuleImpl::createSession() {
return adapter_->CreateSession();
}
blink::WebContentDecryptionModuleSession* blink::WebContentDecryptionModuleSession*
WebContentDecryptionModuleImpl::createSession( WebContentDecryptionModuleImpl::createSession(
blink::WebContentDecryptionModuleSession::Client* client) { blink::WebContentDecryptionModuleSession::Client* client) {
return adapter_->CreateSession(client); WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession();
session->setClientInterface(client);
return session;
} }
media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() {
......
...@@ -59,6 +59,8 @@ class WebContentDecryptionModuleImpl ...@@ -59,6 +59,8 @@ class WebContentDecryptionModuleImpl
#endif // defined(ENABLE_BROWSER_CDMS) #endif // defined(ENABLE_BROWSER_CDMS)
// blink::WebContentDecryptionModule implementation. // blink::WebContentDecryptionModule implementation.
virtual blink::WebContentDecryptionModuleSession* createSession();
// TODO(jrummell): Remove this method once blink updated.
virtual blink::WebContentDecryptionModuleSession* createSession( virtual blink::WebContentDecryptionModuleSession* createSession(
blink::WebContentDecryptionModuleSession::Client* client); blink::WebContentDecryptionModuleSession::Client* client);
......
...@@ -46,10 +46,8 @@ static blink::WebContentDecryptionModuleException ConvertException( ...@@ -46,10 +46,8 @@ static blink::WebContentDecryptionModuleException ConvertException(
} }
WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
Client* client,
const scoped_refptr<CdmSessionAdapter>& adapter) const scoped_refptr<CdmSessionAdapter>& adapter)
: adapter_(adapter), : adapter_(adapter),
client_(client),
is_closed_(false), is_closed_(false),
next_available_result_index_(1), next_available_result_index_(1),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
...@@ -75,6 +73,10 @@ WebContentDecryptionModuleSessionImpl:: ...@@ -75,6 +73,10 @@ WebContentDecryptionModuleSessionImpl::
outstanding_results_.clear(); outstanding_results_.clear();
} }
void WebContentDecryptionModuleSessionImpl::setClientInterface(Client* client) {
client_ = client;
}
blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const {
return blink::WebString::fromUTF8(web_session_id_); return blink::WebString::fromUTF8(web_session_id_);
} }
...@@ -209,6 +211,7 @@ void WebContentDecryptionModuleSessionImpl::release( ...@@ -209,6 +211,7 @@ void WebContentDecryptionModuleSessionImpl::release(
void WebContentDecryptionModuleSessionImpl::OnSessionMessage( void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
const std::vector<uint8>& message, const std::vector<uint8>& message,
const GURL& destination_url) { const GURL& destination_url) {
DCHECK(client_) << "Client not set before message event";
client_->message( client_->message(
message.empty() ? NULL : &message[0], message.size(), destination_url); message.empty() ? NULL : &message[0], message.size(), destination_url);
} }
......
...@@ -28,11 +28,11 @@ class WebContentDecryptionModuleSessionImpl ...@@ -28,11 +28,11 @@ class WebContentDecryptionModuleSessionImpl
: public blink::WebContentDecryptionModuleSession { : public blink::WebContentDecryptionModuleSession {
public: public:
WebContentDecryptionModuleSessionImpl( WebContentDecryptionModuleSessionImpl(
Client* client,
const scoped_refptr<CdmSessionAdapter>& adapter); const scoped_refptr<CdmSessionAdapter>& adapter);
virtual ~WebContentDecryptionModuleSessionImpl(); virtual ~WebContentDecryptionModuleSessionImpl();
// blink::WebContentDecryptionModuleSession implementation. // blink::WebContentDecryptionModuleSession implementation.
virtual void setClientInterface(Client* client);
virtual blink::WebString sessionId() const; virtual blink::WebString sessionId() const;
// TODO(jrummell): Remove the next 3 methods once blink updated. // TODO(jrummell): Remove the next 3 methods once blink updated.
virtual void initializeNewSession(const blink::WebString& mime_type, virtual void initializeNewSession(const blink::WebString& mime_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment