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

Side by Side Diff: content/renderer/pepper/content_decryptor_delegate.cc

Issue 839063004: Convert KeyInformation from Pepper type to MediaKeys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/pepper/content_decryptor_delegate.h" 5 #include "content/renderer/pepper/content_decryptor_delegate.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 case PP_CDMEXCEPTIONCODE_CLIENTERROR: 285 case PP_CDMEXCEPTIONCODE_CLIENTERROR:
286 return MediaKeys::CLIENT_ERROR; 286 return MediaKeys::CLIENT_ERROR;
287 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: 287 case PP_CDMEXCEPTIONCODE_OUTPUTERROR:
288 return MediaKeys::OUTPUT_ERROR; 288 return MediaKeys::OUTPUT_ERROR;
289 default: 289 default:
290 NOTREACHED(); 290 NOTREACHED();
291 return MediaKeys::UNKNOWN_ERROR; 291 return MediaKeys::UNKNOWN_ERROR;
292 } 292 }
293 } 293 }
294 294
295 media::CdmKeyInformation::KeyStatus PpCdmKeyStatusToCdmKeyInformationKeyStatus(
296 PP_CdmKeyStatus status) {
297 switch (status) {
298 case PP_CDMKEYSTATUS_USABLE:
299 return media::CdmKeyInformation::USABLE;
300 case PP_CDMKEYSTATUS_INVALID:
ddorwin 2015/01/09 03:27:36 We should fix the naming sometime.
jrummell 2015/01/09 17:24:28 Acknowledged.
301 return media::CdmKeyInformation::INTERNAL_ERROR;
302 case PP_CDMKEYSTATUS_EXPIRED:
303 return media::CdmKeyInformation::EXPIRED;
304 case PP_CDMKEYSTATUS_OUTPUTNOTALLOWED:
ddorwin 2015/01/09 03:27:35 And this probably shouldn't be one word.
jrummell 2015/01/09 17:24:28 Acknowledged.
305 return media::CdmKeyInformation::OUTPUT_NOT_ALLOWED;
306 default:
307 NOTREACHED();
308 return media::CdmKeyInformation::INTERNAL_ERROR;
309 }
310 }
311
295 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. 312 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated.
296 // See http://crbug.com/412987 for details. 313 // See http://crbug.com/412987 for details.
297 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) { 314 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) {
298 // Sparse histogram macro does not cache the histogram, so it's safe to use 315 // Sparse histogram macro does not cache the histogram, so it's safe to use
299 // macro with non-static histogram name here. 316 // macro with non-static histogram name here.
300 UMA_HISTOGRAM_SPARSE_SLOWLY( 317 UMA_HISTOGRAM_SPARSE_SLOWLY(
301 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode", 318 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode",
302 system_code); 319 system_code);
303 } 320 }
304 321
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 std::vector<uint8> message_vector; 764 std::vector<uint8> message_vector;
748 if (message_array_buffer) { 765 if (message_array_buffer) {
749 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); 766 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map());
750 message_vector.assign(data, data + message_array_buffer->ByteLength()); 767 message_vector.assign(data, data + message_array_buffer->ByteLength());
751 } 768 }
752 769
753 session_message_cb_.Run(web_session_id_string->value(), message_vector, 770 session_message_cb_.Run(web_session_id_string->value(), message_vector,
754 GURL::EmptyGURL()); 771 GURL::EmptyGURL());
755 } 772 }
756 773
757 // TODO(jrummell): Decode |key_information| and pass it to the callback.
758 void ContentDecryptorDelegate::OnSessionKeysChange( 774 void ContentDecryptorDelegate::OnSessionKeysChange(
759 PP_Var web_session_id, 775 PP_Var web_session_id,
760 PP_Bool has_additional_usable_key, 776 PP_Bool has_additional_usable_key,
761 uint32_t key_count, 777 uint32_t key_count,
762 const struct PP_KeyInformation key_information[]) { 778 const struct PP_KeyInformation key_information[]) {
763 if (session_keys_change_cb_.is_null()) 779 if (session_keys_change_cb_.is_null())
764 return; 780 return;
765 781
766 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); 782 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id);
767 DCHECK(web_session_id_string); 783 DCHECK(web_session_id_string);
768 784
769 // TODO(jrummell): Pass key information through Pepper. 785 media::CdmKeysInfo keys_info;
786 keys_info.reserve(key_count);
787 for (uint32_t i = 0; i < key_count; ++i) {
788 scoped_ptr<media::CdmKeyInformation> key_info(new media::CdmKeyInformation);
789 key_info->key_id.assign(
790 key_information[i].key_id,
ddorwin 2015/01/09 03:27:36 nit: With 5 references to it, you might consider m
jrummell 2015/01/09 17:24:28 Done. I would think the compilers are smart enough
791 key_information[i].key_id + key_information[i].key_id_size);
792 key_info->status = PpCdmKeyStatusToCdmKeyInformationKeyStatus(
793 key_information[i].key_status);
794 key_info->system_code = key_information[i].system_code;
795 keys_info.push_back(key_info.release());
796 }
797
770 session_keys_change_cb_.Run(web_session_id_string->value(), 798 session_keys_change_cb_.Run(web_session_id_string->value(),
771 PP_ToBool(has_additional_usable_key), 799 PP_ToBool(has_additional_usable_key),
772 media::CdmKeysInfo()); 800 keys_info.Pass());
773 } 801 }
774 802
775 void ContentDecryptorDelegate::OnSessionExpirationChange( 803 void ContentDecryptorDelegate::OnSessionExpirationChange(
776 PP_Var web_session_id, 804 PP_Var web_session_id,
777 PP_Time new_expiry_time) { 805 PP_Time new_expiry_time) {
778 if (session_expiration_update_cb_.is_null()) 806 if (session_expiration_update_cb_.is_null())
779 return; 807 return;
780 808
781 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); 809 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id);
782 DCHECK(web_session_id_string); 810 DCHECK(web_session_id_string);
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 1286
1259 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( 1287 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise(
1260 uint32_t promise_id) { 1288 uint32_t promise_id) {
1261 PromiseMap::iterator it = promises_.find(promise_id); 1289 PromiseMap::iterator it = promises_.find(promise_id);
1262 if (it == promises_.end()) 1290 if (it == promises_.end())
1263 return scoped_ptr<CdmPromise>(); 1291 return scoped_ptr<CdmPromise>();
1264 return promises_.take_and_erase(it); 1292 return promises_.take_and_erase(it);
1265 } 1293 }
1266 1294
1267 } // namespace content 1295 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698