Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: media/mojo/clients/mojo_cdm.cc

Issue 2444683002: Move MediaKeys::Exception to CdmPromise::Exception (Closed)
Patch Set: include "media/base/media_keys.h" Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void MojoCdm::InitializeCdm(const std::string& key_system, 99 void MojoCdm::InitializeCdm(const std::string& key_system,
100 const GURL& security_origin, 100 const GURL& security_origin,
101 const media::CdmConfig& cdm_config, 101 const media::CdmConfig& cdm_config,
102 std::unique_ptr<CdmInitializedPromise> promise) { 102 std::unique_ptr<CdmInitializedPromise> promise) {
103 DVLOG(1) << __FUNCTION__ << ": " << key_system; 103 DVLOG(1) << __FUNCTION__ << ": " << key_system;
104 DCHECK(thread_checker_.CalledOnValidThread()); 104 DCHECK(thread_checker_.CalledOnValidThread());
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(NOT_SUPPORTED_ERROR, 0, "Mojo CDM creation failed."); 109 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0,
110 "Mojo CDM creation failed.");
110 return; 111 return;
111 } 112 }
112 113
113 // Otherwise, set an error handler to catch the connection error. 114 // Otherwise, set an error handler to catch the connection error.
114 remote_cdm_.set_connection_error_handler( 115 remote_cdm_.set_connection_error_handler(
115 base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this))); 116 base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this)));
116 117
117 pending_init_promise_ = std::move(promise); 118 pending_init_promise_ = std::move(promise);
118 119
119 remote_cdm_->Initialize( 120 remote_cdm_->Initialize(
120 key_system, security_origin.spec(), mojom::CdmConfig::From(cdm_config), 121 key_system, security_origin.spec(), mojom::CdmConfig::From(cdm_config),
121 base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this))); 122 base::Bind(&MojoCdm::OnCdmInitialized, base::Unretained(this)));
122 } 123 }
123 124
124 void MojoCdm::OnConnectionError() { 125 void MojoCdm::OnConnectionError() {
125 LOG(ERROR) << "Remote CDM connection error."; 126 LOG(ERROR) << "Remote CDM connection error.";
126 DCHECK(thread_checker_.CalledOnValidThread()); 127 DCHECK(thread_checker_.CalledOnValidThread());
127 128
128 // We only handle initial connection error. 129 // We only handle initial connection error.
129 if (!pending_init_promise_) 130 if (!pending_init_promise_)
130 return; 131 return;
131 132
132 pending_init_promise_->reject(NOT_SUPPORTED_ERROR, 0, 133 pending_init_promise_->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0,
133 "Mojo CDM creation failed."); 134 "Mojo CDM creation failed.");
134 pending_init_promise_.reset(); 135 pending_init_promise_.reset();
135 } 136 }
136 137
137 void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate, 138 void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate,
138 std::unique_ptr<SimpleCdmPromise> promise) { 139 std::unique_ptr<SimpleCdmPromise> promise) {
139 DVLOG(2) << __FUNCTION__; 140 DVLOG(2) << __FUNCTION__;
140 DCHECK(thread_checker_.CalledOnValidThread()); 141 DCHECK(thread_checker_.CalledOnValidThread());
141 142
142 remote_cdm_->SetServerCertificate( 143 remote_cdm_->SetServerCertificate(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 std::unique_ptr<NewSessionCdmPromise> promise, 334 std::unique_ptr<NewSessionCdmPromise> promise,
334 mojom::CdmPromiseResultPtr result, 335 mojom::CdmPromiseResultPtr result,
335 const std::string& session_id) { 336 const std::string& session_id) {
336 if (result->success) 337 if (result->success)
337 promise->resolve(session_id); 338 promise->resolve(session_id);
338 else 339 else
339 RejectPromise(std::move(promise), std::move(result)); 340 RejectPromise(std::move(promise), std::move(result));
340 } 341 }
341 342
342 } // namespace media 343 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/ppapi/external_clear_key/clear_key_cdm.cc ('k') | media/mojo/interfaces/content_decryption_module.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698