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(
return media_keys_;
}
WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession(
blink::WebContentDecryptionModuleSession::Client* client) {
return new WebContentDecryptionModuleSessionImpl(client, this);
WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() {
return new WebContentDecryptionModuleSessionImpl(this);
}
bool CdmSessionAdapter::RegisterSession(
......
......@@ -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
// created session. RemoveSession() must be called when destroying it, if
// RegisterSession() was called.
WebContentDecryptionModuleSessionImpl* CreateSession(
blink::WebContentDecryptionModuleSession::Client* client);
WebContentDecryptionModuleSessionImpl* CreateSession();
// 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
......
......@@ -84,10 +84,17 @@ WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() {
}
// The caller owns the created session.
blink::WebContentDecryptionModuleSession*
WebContentDecryptionModuleImpl::createSession() {
return adapter_->CreateSession();
}
blink::WebContentDecryptionModuleSession*
WebContentDecryptionModuleImpl::createSession(
blink::WebContentDecryptionModuleSession::Client* client) {
return adapter_->CreateSession(client);
WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession();
session->setClientInterface(client);
return session;
}
media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() {
......
......@@ -59,6 +59,8 @@ class WebContentDecryptionModuleImpl
#endif // defined(ENABLE_BROWSER_CDMS)
// blink::WebContentDecryptionModule implementation.
virtual blink::WebContentDecryptionModuleSession* createSession();
// TODO(jrummell): Remove this method once blink updated.
virtual blink::WebContentDecryptionModuleSession* createSession(
blink::WebContentDecryptionModuleSession::Client* client);
......
......@@ -46,10 +46,8 @@ static blink::WebContentDecryptionModuleException ConvertException(
}
WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
Client* client,
const scoped_refptr<CdmSessionAdapter>& adapter)
: adapter_(adapter),
client_(client),
is_closed_(false),
next_available_result_index_(1),
weak_ptr_factory_(this) {
......@@ -75,6 +73,10 @@ WebContentDecryptionModuleSessionImpl::
outstanding_results_.clear();
}
void WebContentDecryptionModuleSessionImpl::setClientInterface(Client* client) {
client_ = client;
}
blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const {
return blink::WebString::fromUTF8(web_session_id_);
}
......@@ -209,6 +211,7 @@ void WebContentDecryptionModuleSessionImpl::release(
void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
const std::vector<uint8>& message,
const GURL& destination_url) {
DCHECK(client_) << "Client not set before message event";
client_->message(
message.empty() ? NULL : &message[0], message.size(), destination_url);
}
......
......@@ -28,11 +28,11 @@ class WebContentDecryptionModuleSessionImpl
: public blink::WebContentDecryptionModuleSession {
public:
WebContentDecryptionModuleSessionImpl(
Client* client,
const scoped_refptr<CdmSessionAdapter>& adapter);
virtual ~WebContentDecryptionModuleSessionImpl();
// blink::WebContentDecryptionModuleSession implementation.
virtual void setClientInterface(Client* client);
virtual blink::WebString sessionId() const;
// TODO(jrummell): Remove the next 3 methods once blink updated.
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