| 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 "media/mojo/clients/mojo_cdm.h" | 5 #include "media/mojo/clients/mojo_cdm.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 base::AutoLock auto_lock(lock_); | 77 base::AutoLock auto_lock(lock_); |
| 78 | 78 |
| 79 // Release |decryptor_| on the correct thread. If GetDecryptor() is never | 79 // Release |decryptor_| on the correct thread. If GetDecryptor() is never |
| 80 // called but |decryptor_ptr_info_| is not null, it is not bound to any thread | 80 // called but |decryptor_ptr_info_| is not null, it is not bound to any thread |
| 81 // and is safe to be released on the current thread. | 81 // and is safe to be released on the current thread. |
| 82 if (decryptor_task_runner_ && | 82 if (decryptor_task_runner_ && |
| 83 !decryptor_task_runner_->BelongsToCurrentThread() && decryptor_) { | 83 !decryptor_task_runner_->BelongsToCurrentThread() && decryptor_) { |
| 84 decryptor_task_runner_->DeleteSoon(FROM_HERE, decryptor_.release()); | 84 decryptor_task_runner_->DeleteSoon(FROM_HERE, decryptor_.release()); |
| 85 } | 85 } |
| 86 |
| 87 // Reject any outstanding promises and close all the existing sessions. |
| 88 cdm_promise_adapter_.Clear(); |
| 89 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); |
| 86 } | 90 } |
| 87 | 91 |
| 88 // Using base::Unretained(this) below is safe because |this| owns |remote_cdm_|, | 92 // Using base::Unretained(this) below is safe because |this| owns |remote_cdm_|, |
| 89 // and if |this| is destroyed, |remote_cdm_| will be destroyed as well. Then the | 93 // and if |this| is destroyed, |remote_cdm_| will be destroyed as well. Then the |
| 90 // error handler can't be invoked and callbacks won't be dispatched. | 94 // error handler can't be invoked and callbacks won't be dispatched. |
| 91 | 95 |
| 92 void MojoCdm::InitializeCdm(const std::string& key_system, | 96 void MojoCdm::InitializeCdm(const std::string& key_system, |
| 93 const GURL& security_origin, | 97 const GURL& security_origin, |
| 94 const CdmConfig& cdm_config, | 98 const CdmConfig& cdm_config, |
| 95 std::unique_ptr<CdmInitializedPromise> promise) { | 99 std::unique_ptr<CdmInitializedPromise> promise) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 cdm_session_tracker_.AddSession(session_id); | 390 cdm_session_tracker_.AddSession(session_id); |
| 387 cdm_promise_adapter_.ResolvePromise(promise_id, session_id); | 391 cdm_promise_adapter_.ResolvePromise(promise_id, session_id); |
| 388 } else { | 392 } else { |
| 389 cdm_promise_adapter_.RejectPromise(promise_id, result->exception, | 393 cdm_promise_adapter_.RejectPromise(promise_id, result->exception, |
| 390 result->system_code, | 394 result->system_code, |
| 391 result->error_message); | 395 result->error_message); |
| 392 } | 396 } |
| 393 } | 397 } |
| 394 | 398 |
| 395 } // namespace media | 399 } // namespace media |
| OLD | NEW |