Skip to content

Commit

Permalink
Implement LoadSession() for EME
Browse files Browse the repository at this point in the history
In preparation for MediaKeySession.load(), add support for load()
on the Chromium side.

BUG=338831
TEST=existing EME tests still pass (new tests coming once implemented)

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

Cr-Commit-Position: refs/heads/master@{#298798}
  • Loading branch information
jrummell-chromium authored and Commit bot committed Oct 9, 2014
1 parent bb621b7 commit 847afc9
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions content/renderer/media/cdm_session_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ void CdmSessionAdapter::InitializeNewSession(
promise.Pass());
}

void CdmSessionAdapter::LoadSession(
const std::string& web_session_id,
scoped_ptr<media::NewSessionCdmPromise> promise) {
media_keys_->LoadSession(web_session_id, promise.Pass());
}

void CdmSessionAdapter::UpdateSession(
const std::string& web_session_id,
const uint8* response,
Expand Down
4 changes: 4 additions & 0 deletions content/renderer/media/cdm_session_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> {
media::MediaKeys::SessionType session_type,
scoped_ptr<media::NewSessionCdmPromise> promise);

// Loads the session specified by |web_session_id|.
void LoadSession(const std::string& web_session_id,
scoped_ptr<media::NewSessionCdmPromise> promise);

// Updates the session specified by |web_session_id| with |response|.
void UpdateSession(const std::string& web_session_id,
const uint8* response,
Expand Down
18 changes: 18 additions & 0 deletions content/renderer/media/webcontentdecryptionmodulesession_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace content {

const char kCreateSessionUMAName[] = "CreateSession";
const char kLoadSessionUMAName[] = "LoadSession";

WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
const scoped_refptr<CdmSessionAdapter>& adapter)
Expand Down Expand Up @@ -64,6 +65,7 @@ void WebContentDecryptionModuleSessionImpl::initializeNewSession(
size_t init_data_length,
const blink::WebString& session_type,
blink::WebContentDecryptionModuleResult result) {
DCHECK(web_session_id_.empty());

// TODO(ddorwin): Guard against this in supported types check and remove this.
// Chromium only supports ASCII MIME types.
Expand Down Expand Up @@ -97,6 +99,22 @@ void WebContentDecryptionModuleSessionImpl::initializeNewSession(
base::Unretained(this)))));
}

void WebContentDecryptionModuleSessionImpl::load(
const blink::WebString& session_id,
blink::WebContentDecryptionModuleResult result) {
DCHECK(!session_id.isEmpty());
DCHECK(web_session_id_.empty());

adapter_->LoadSession(
base::UTF16ToASCII(session_id),
scoped_ptr<media::NewSessionCdmPromise>(new NewSessionCdmResultPromise(
result,
adapter_->GetKeySystemUMAPrefix() + kLoadSessionUMAName,
base::Bind(
&WebContentDecryptionModuleSessionImpl::OnSessionInitialized,
base::Unretained(this)))));
}

void WebContentDecryptionModuleSessionImpl::update(
const uint8* response,
size_t response_length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class WebContentDecryptionModuleSessionImpl
size_t init_data_length,
const blink::WebString& session_type,
blink::WebContentDecryptionModuleResult result);
virtual void load(const blink::WebString& session_id,
blink::WebContentDecryptionModuleResult result);
virtual void update(const uint8* response,
size_t response_length,
blink::WebContentDecryptionModuleResult result);
Expand Down
22 changes: 22 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11678,6 +11678,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>KeyError event count using the Clear Key key system.</summary>
</histogram>

<histogram name="Media.EME.ClearKey.LoadSession" enum="CdmPromiseResult">
<owner>sandersd@chromium.org</owner>
<summary>
Result of Clear Key loadSession promises handled by Chromium code.
</summary>
</histogram>

<histogram name="Media.EME.NeedKey">
<owner>xhwang@chromium.org</owner>
<summary>EME NeedKey event count.</summary>
Expand Down Expand Up @@ -11729,6 +11736,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>KeyError event count using an unknown key system.</summary>
</histogram>

<histogram name="Media.EME.Unknown.LoadSession" enum="CdmPromiseResult">
<owner>sandersd@chromium.org</owner>
<summary>
Result of loadSession promises for unknown key systems promises that were
handled by Chromium code.
</summary>
</histogram>

<histogram name="Media.EME.Unknown.SystemCode" units="system code">
<owner>xhwang@chromium.org</owner>
<summary>System code count using an unknown key system.</summary>
Expand Down Expand Up @@ -11772,6 +11787,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>KeyError event count using the Widevine key system.</summary>
</histogram>

<histogram name="Media.EME.Widevine.LoadSession" enum="CdmPromiseResult">
<owner>sandersd@chromium.org</owner>
<summary>
Result of Widevine loadSession promises handled by Chromium code.
</summary>
</histogram>

<histogram name="Media.EME.Widevine.SystemCode" units="system code">
<owner>xhwang@chromium.org</owner>
<summary>System code count using the Widevine key system.</summary>
Expand Down

0 comments on commit 847afc9

Please sign in to comment.