| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 int render_frame_id, | 65 int render_frame_id, |
| 66 int cdm_id, | 66 int cdm_id, |
| 67 uint32_t promise_id) | 67 uint32_t promise_id) |
| 68 : manager_(manager), | 68 : manager_(manager), |
| 69 render_frame_id_(render_frame_id), | 69 render_frame_id_(render_frame_id), |
| 70 cdm_id_(cdm_id), | 70 cdm_id_(cdm_id), |
| 71 promise_id_(promise_id) { | 71 promise_id_(promise_id) { |
| 72 DCHECK(manager_); | 72 DCHECK(manager_); |
| 73 } | 73 } |
| 74 | 74 |
| 75 ~CdmPromiseInternal() final {} | 75 ~CdmPromiseInternal() final { |
| 76 if (!IsPromiseSettled()) |
| 77 RejectPromiseOnDestruction(); |
| 78 } |
| 76 | 79 |
| 77 // CdmPromiseTemplate<> implementation. | 80 // CdmPromiseTemplate<> implementation. |
| 78 void resolve(const T&... result) final; | 81 void resolve(const T&... result) final; |
| 79 | 82 |
| 80 void reject(MediaKeys::Exception exception, | 83 void reject(MediaKeys::Exception exception, |
| 81 uint32_t system_code, | 84 uint32_t system_code, |
| 82 const std::string& error_message) final { | 85 const std::string& error_message) final { |
| 83 MarkPromiseSettled(); | 86 MarkPromiseSettled(); |
| 84 if (manager_) { | 87 if (manager_) { |
| 85 manager_->RejectPromise(render_frame_id_, cdm_id_, promise_id_, exception, | 88 manager_->RejectPromise(render_frame_id_, cdm_id_, promise_id_, exception, |
| 86 system_code, error_message); | 89 system_code, error_message); |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 | 92 |
| 90 private: | 93 private: |
| 94 using media::CdmPromiseTemplate<T...>::IsPromiseSettled; |
| 91 using media::CdmPromiseTemplate<T...>::MarkPromiseSettled; | 95 using media::CdmPromiseTemplate<T...>::MarkPromiseSettled; |
| 96 using media::CdmPromiseTemplate<T...>::RejectPromiseOnDestruction; |
| 92 | 97 |
| 93 base::WeakPtr<BrowserCdmManager> const manager_; | 98 base::WeakPtr<BrowserCdmManager> const manager_; |
| 94 const int render_frame_id_; | 99 const int render_frame_id_; |
| 95 const int cdm_id_; | 100 const int cdm_id_; |
| 96 const uint32_t promise_id_; | 101 const uint32_t promise_id_; |
| 97 }; | 102 }; |
| 98 | 103 |
| 99 template <> | 104 template <> |
| 100 void CdmPromiseInternal<>::resolve() { | 105 void CdmPromiseInternal<>::resolve() { |
| 101 MarkPromiseSettled(); | 106 MarkPromiseSettled(); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); | 727 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); |
| 723 if (!cdm) { | 728 if (!cdm) { |
| 724 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 729 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
| 725 return; | 730 return; |
| 726 } | 731 } |
| 727 | 732 |
| 728 cdm->LoadSession(session_type, session_id, std::move(promise)); | 733 cdm->LoadSession(session_type, session_id, std::move(promise)); |
| 729 } | 734 } |
| 730 | 735 |
| 731 } // namespace content | 736 } // namespace content |
| OLD | NEW |