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

Side by Side Diff: media/cdm/proxy_decryptor.cc

Issue 1224053003: Clear Key CDM should resolve the promise if session not found (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 5 years, 5 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/cdm/proxy_decryptor.h" 5 #include "media/cdm/proxy_decryptor.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 pending_requests_.push_back( 126 pending_requests_.push_back(
127 new PendingGenerateKeyRequestData(init_data_type, init_data_vector)); 127 new PendingGenerateKeyRequestData(init_data_type, init_data_vector));
128 return; 128 return;
129 } 129 }
130 130
131 GenerateKeyRequestInternal(init_data_type, init_data_vector); 131 GenerateKeyRequestInternal(init_data_type, init_data_vector);
132 } 132 }
133 133
134 // Returns true if |data| is prefixed with |header| and has data after the 134 // Returns true if |data| is prefixed with |header| and has data after the
135 // |header|. 135 // |header|.
136 bool HasHeader(const std::vector<uint8>& data, const std::string& header) { 136 static bool HasHeader(const std::vector<uint8>& data,
137 const std::string& header) {
137 return data.size() > header.size() && 138 return data.size() > header.size() &&
138 std::equal(header.begin(), header.end(), data.begin()); 139 std::equal(header.begin(), header.end(), data.begin());
139 } 140 }
140 141
141 // Removes the first |length| items from |data|. 142 // Removes the first |length| items from |data|.
142 void StripHeader(std::vector<uint8>& data, size_t length) { 143 static void StripHeader(std::vector<uint8>& data, size_t length) {
143 data.erase(data.begin(), data.begin() + length); 144 data.erase(data.begin(), data.begin() + length);
144 } 145 }
145 146
146 void ProxyDecryptor::GenerateKeyRequestInternal( 147 void ProxyDecryptor::GenerateKeyRequestInternal(
147 EmeInitDataType init_data_type, 148 EmeInitDataType init_data_type,
148 const std::vector<uint8>& init_data) { 149 const std::vector<uint8>& init_data) {
149 DVLOG(1) << __FUNCTION__; 150 DVLOG(1) << __FUNCTION__;
150 DCHECK(!is_creating_cdm_); 151 DCHECK(!is_creating_cdm_);
151 152
152 if (!media_keys_) { 153 if (!media_keys_) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // This will include all other CDM4 errors and any error generated 385 // This will include all other CDM4 errors and any error generated
385 // by CDM5 or later. 386 // by CDM5 or later.
386 error_code = MediaKeys::kUnknownError; 387 error_code = MediaKeys::kUnknownError;
387 break; 388 break;
388 } 389 }
389 key_error_cb_.Run(session_id, error_code, system_code); 390 key_error_cb_.Run(session_id, error_code, system_code);
390 } 391 }
391 392
392 void ProxyDecryptor::SetSessionId(SessionCreationType session_type, 393 void ProxyDecryptor::SetSessionId(SessionCreationType session_type,
393 const std::string& session_id) { 394 const std::string& session_id) {
395 // LoadSession() returns empty |session_id| if the session is not found, so
396 // convert this into an error.
397 if (session_type == LoadSession && session_id.empty()) {
398 OnLegacySessionError(session_id, MediaKeys::INVALID_ACCESS_ERROR, 0,
399 "Incorrect session id specified for LoadSession().");
ddorwin 2015/07/10 00:35:12 * s/Incorrect/Unknown/ or something like that. * L
400 return;
401 }
402
394 // Loaded sessions are considered persistent. 403 // Loaded sessions are considered persistent.
395 bool is_persistent = 404 bool is_persistent =
396 session_type == PersistentSession || session_type == LoadSession; 405 session_type == PersistentSession || session_type == LoadSession;
397 active_sessions_.insert(std::make_pair(session_id, is_persistent)); 406 active_sessions_.insert(std::make_pair(session_id, is_persistent));
398 407
399 // For LoadSession(), generate the KeyAdded event. 408 // For LoadSession(), generate the KeyAdded event.
400 if (session_type == LoadSession) 409 if (session_type == LoadSession)
401 GenerateKeyAdded(session_id); 410 GenerateKeyAdded(session_id);
402 } 411 }
403 412
404 } // namespace media 413 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/ppapi/external_clear_key/clear_key_cdm.cc ('k') | media/test/data/eme_player_js/globals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698