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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // If connection error has happened, fail immediately. | 106 // If connection error has happened, fail immediately. |
107 if (remote_cdm_.encountered_error()) { | 107 if (remote_cdm_.encountered_error()) { |
108 LOG(ERROR) << "Remote CDM encountered error."; | 108 LOG(ERROR) << "Remote CDM encountered error."; |
109 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 109 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, |
110 "Mojo CDM creation failed."); | 110 "Mojo CDM creation failed."); |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 // Otherwise, set an error handler to catch the connection error. | 114 // Otherwise, set an error handler to catch the connection error. |
115 remote_cdm_.set_connection_error_handler( | 115 remote_cdm_.set_connection_error_with_reason_handler( |
116 base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this))); | 116 base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this))); |
117 | 117 |
118 pending_init_promise_ = std::move(promise); | 118 pending_init_promise_ = std::move(promise); |
119 | 119 |
120 remote_cdm_->Initialize( | 120 remote_cdm_->Initialize( |
121 key_system, security_origin.spec(), mojom::CdmConfig::From(cdm_config), | 121 key_system, security_origin.spec(), mojom::CdmConfig::From(cdm_config), |
122 base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this))); | 122 base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this))); |
123 } | 123 } |
124 | 124 |
125 void MojoCdm::OnConnectionError() { | 125 // TODO(xhwang): Properly handle CDM calls after connection error. |
126 LOG(ERROR) << "Remote CDM connection error."; | 126 // See http://crbug.com/671362 |
| 127 void MojoCdm::OnConnectionError(uint32_t custom_reason, |
| 128 const std::string& description) { |
| 129 LOG(ERROR) << "Remote CDM connection error: custom_reason=" << custom_reason |
| 130 << ", description=\"" << description << "\""; |
127 DCHECK(thread_checker_.CalledOnValidThread()); | 131 DCHECK(thread_checker_.CalledOnValidThread()); |
128 | 132 |
129 // Handle initial connection error. | 133 // Handle initial connection error. |
130 if (pending_init_promise_) { | 134 if (pending_init_promise_) { |
| 135 DCHECK(!cdm_session_tracker_.HasRemainingSessions()); |
131 pending_init_promise_->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 136 pending_init_promise_->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, |
132 "Mojo CDM creation failed."); | 137 "Mojo CDM creation failed."); |
| 138 // Dropping the promise could cause |this| to be destructed. |
133 pending_init_promise_.reset(); | 139 pending_init_promise_.reset(); |
| 140 return; |
134 } | 141 } |
135 | 142 |
136 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); | 143 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); |
137 } | 144 } |
138 | 145 |
139 void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate, | 146 void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate, |
140 std::unique_ptr<SimpleCdmPromise> promise) { | 147 std::unique_ptr<SimpleCdmPromise> promise) { |
141 DVLOG(2) << __func__; | 148 DVLOG(2) << __func__; |
142 DCHECK(thread_checker_.CalledOnValidThread()); | 149 DCHECK(thread_checker_.CalledOnValidThread()); |
143 | 150 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 mojom::CdmPromiseResultPtr result, | 344 mojom::CdmPromiseResultPtr result, |
338 const std::string& session_id) { | 345 const std::string& session_id) { |
339 if (result->success) { | 346 if (result->success) { |
340 cdm_session_tracker_.AddSession(session_id); | 347 cdm_session_tracker_.AddSession(session_id); |
341 promise->resolve(session_id); | 348 promise->resolve(session_id); |
342 } else | 349 } else |
343 RejectPromise(std::move(promise), std::move(result)); | 350 RejectPromise(std::move(promise), std::move(result)); |
344 } | 351 } |
345 | 352 |
346 } // namespace media | 353 } // namespace media |
OLD | NEW |