-// cdm::Host_4 methods
-
-double CdmAdapter::GetCurrentWallTimeInSeconds() {
- return GetCurrentWallTime();
-}
-
-void CdmAdapter::OnSessionCreated(uint32_t session_id,
- const char* web_session_id,
- uint32_t web_session_id_length) {
- uint32_t promise_id = cdm_->LookupPromiseId(session_id);
- cdm_->AssignWebSessionId(session_id, web_session_id, web_session_id_length);
- OnResolveNewSessionPromise(promise_id, web_session_id, web_session_id_length);
-}
-
-void CdmAdapter::OnSessionMessage(uint32_t session_id,
- const char* message,
- uint32_t message_length,
- const char* destination_url,
- uint32_t destination_url_length) {
- std::string web_session_id = cdm_->LookupWebSessionId(session_id);
- OnSessionMessage(web_session_id.data(),
- web_session_id.length(),
- message,
- message_length,
- destination_url,
- destination_url_length);
-}
-
-void CdmAdapter::OnSessionReady(uint32_t session_id) {
- uint32_t promise_id = cdm_->LookupPromiseId(session_id);
- if (promise_id) {
- OnResolvePromise(promise_id);
- } else {
- std::string web_session_id = cdm_->LookupWebSessionId(session_id);
- PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::SendSessionReadyInternal, web_session_id));
- }
-}
-
-void CdmAdapter::OnSessionClosed(uint32_t session_id) {
- uint32_t promise_id = cdm_->LookupPromiseId(session_id);
- std::string web_session_id = cdm_->LookupWebSessionId(session_id);
- cdm_->DropWebSessionId(web_session_id);
- if (promise_id) {
- OnResolvePromise(promise_id);
- } else {
- OnSessionClosed(web_session_id.data(), web_session_id.length());
- }
-}
-
-void CdmAdapter::OnSessionError(uint32_t session_id,
- cdm::MediaKeyError error_code,
- uint32_t system_code) {
- uint32_t promise_id = cdm_->LookupPromiseId(session_id);
-
- // Existing cdm::MediaKeyError don't map to DOM error names. Convert them
- // into non-standard names so that the prefixed API can extract them.
- // TODO(jrummell): Remove this conversion and the inverse when CDM4 is gone.
- cdm::Error error;
- switch (error_code) {
- case cdm::kPrefixedClientError:
- error = cdm::kClientError;
- break;
- case cdm::kPrefixedOutputError:
- error = cdm::kOutputError;
- break;
- case cdm::kPrefixedUnknownError:
- default:
- error = cdm::kUnknownError;
- break;
- }
-
- if (promise_id) {
- RejectPromise(promise_id, error, system_code, std::string());
- } else {
- std::string web_session_id = cdm_->LookupWebSessionId(session_id);
- OnSessionError(web_session_id.data(),
- web_session_id.length(),
- error,
- system_code,
- NULL,
- 0);
- }
-}
-
-// cdm::Host_6 methods
-