| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/media/cdm/browser_cdm_manager.h" | 5 #include "content/browser/media/cdm/browser_cdm_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (!cdm) { | 317 if (!cdm) { |
| 318 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 318 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
| 319 return; | 319 return; |
| 320 } | 320 } |
| 321 | 321 |
| 322 if (certificate.empty()) { | 322 if (certificate.empty()) { |
| 323 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Empty certificate."); | 323 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Empty certificate."); |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 | 326 |
| 327 cdm->SetServerCertificate(&certificate[0], certificate.size(), | 327 cdm->SetServerCertificate(certificate, promise.Pass()); |
| 328 promise.Pass()); | |
| 329 } | 328 } |
| 330 | 329 |
| 331 void BrowserCdmManager::OnCreateSessionAndGenerateRequest( | 330 void BrowserCdmManager::OnCreateSessionAndGenerateRequest( |
| 332 int render_frame_id, | 331 int render_frame_id, |
| 333 int cdm_id, | 332 int cdm_id, |
| 334 uint32_t promise_id, | 333 uint32_t promise_id, |
| 335 CdmHostMsg_CreateSession_InitDataType init_data_type, | 334 CdmHostMsg_CreateSession_InitDataType init_data_type, |
| 336 const std::vector<uint8>& init_data) { | 335 const std::vector<uint8>& init_data) { |
| 337 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 336 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 338 | 337 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 << " is too long: " << response.size(); | 397 << " is too long: " << response.size(); |
| 399 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Response too long."); | 398 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Response too long."); |
| 400 return; | 399 return; |
| 401 } | 400 } |
| 402 | 401 |
| 403 if (response.empty()) { | 402 if (response.empty()) { |
| 404 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Response is empty."); | 403 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, "Response is empty."); |
| 405 return; | 404 return; |
| 406 } | 405 } |
| 407 | 406 |
| 408 cdm->UpdateSession(session_id, &response[0], response.size(), promise.Pass()); | 407 cdm->UpdateSession(session_id, response, promise.Pass()); |
| 409 } | 408 } |
| 410 | 409 |
| 411 void BrowserCdmManager::OnCloseSession(int render_frame_id, | 410 void BrowserCdmManager::OnCloseSession(int render_frame_id, |
| 412 int cdm_id, | 411 int cdm_id, |
| 413 uint32_t promise_id, | 412 uint32_t promise_id, |
| 414 const std::string& session_id) { | 413 const std::string& session_id) { |
| 415 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 414 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 416 | 415 |
| 417 scoped_ptr<SimplePromise> promise( | 416 scoped_ptr<SimplePromise> promise( |
| 418 new SimplePromise(this, render_frame_id, cdm_id, promise_id)); | 417 new SimplePromise(this, render_frame_id, cdm_id, promise_id)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 569 |
| 571 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); | 570 BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id); |
| 572 if (!cdm) { | 571 if (!cdm) { |
| 573 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 572 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
| 574 return; | 573 return; |
| 575 } | 574 } |
| 576 | 575 |
| 577 // Only the temporary session type is supported in browser CDM path. | 576 // Only the temporary session type is supported in browser CDM path. |
| 578 // TODO(xhwang): Add SessionType support if needed. | 577 // TODO(xhwang): Add SessionType support if needed. |
| 579 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, | 578 cdm->CreateSessionAndGenerateRequest(media::MediaKeys::TEMPORARY_SESSION, |
| 580 init_data_type, &init_data[0], | 579 init_data_type, init_data, |
| 581 init_data.size(), promise.Pass()); | 580 promise.Pass()); |
| 582 } | 581 } |
| 583 | 582 |
| 584 } // namespace content | 583 } // namespace content |
| OLD | NEW |