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

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

Issue 561643002: Encrypted Media: Add UMA for system code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 (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/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "content/renderer/media/crypto/key_systems.h"
ddorwin 2014/09/10 21:24:34 Is this allowed? crypto/ is not in src/content/ren
xhwang 2014/09/10 22:09:33 It seems this IS allowed.
11 #include "content/renderer/pepper/ppb_buffer_impl.h" 13 #include "content/renderer/pepper/ppb_buffer_impl.h"
12 #include "media/base/audio_buffer.h" 14 #include "media/base/audio_buffer.h"
13 #include "media/base/audio_decoder_config.h" 15 #include "media/base/audio_decoder_config.h"
14 #include "media/base/bind_to_current_loop.h" 16 #include "media/base/bind_to_current_loop.h"
15 #include "media/base/cdm_promise.h" 17 #include "media/base/cdm_promise.h"
16 #include "media/base/channel_layout.h" 18 #include "media/base/channel_layout.h"
17 #include "media/base/data_buffer.h" 19 #include "media/base/data_buffer.h"
18 #include "media/base/decoder_buffer.h" 20 #include "media/base/decoder_buffer.h"
19 #include "media/base/decrypt_config.h" 21 #include "media/base/decrypt_config.h"
20 #include "media/base/limits.h" 22 #include "media/base/limits.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return false; 89 return false;
88 90
89 memcpy(array, str.data(), str.size()); 91 memcpy(array, str.data(), str.size());
90 return true; 92 return true;
91 } 93 }
92 94
93 // Fills the |block_info| with information from |encrypted_buffer|. 95 // Fills the |block_info| with information from |encrypted_buffer|.
94 // 96 //
95 // Returns true if |block_info| is successfully filled. Returns false 97 // Returns true if |block_info| is successfully filled. Returns false
96 // otherwise. 98 // otherwise.
97 static bool MakeEncryptedBlockInfo( 99 bool MakeEncryptedBlockInfo(
98 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 100 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
99 uint32_t request_id, 101 uint32_t request_id,
100 PP_EncryptedBlockInfo* block_info) { 102 PP_EncryptedBlockInfo* block_info) {
101 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and 103 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and
102 // anywhere else. 104 // anywhere else.
103 memset(block_info, 0, sizeof(*block_info)); 105 memset(block_info, 0, sizeof(*block_info));
104 block_info->tracking_info.request_id = request_id; 106 block_info->tracking_info.request_id = request_id;
105 107
106 // EOS buffers need a request ID and nothing more. 108 // EOS buffers need a request ID and nothing more.
107 if (encrypted_buffer->end_of_stream()) 109 if (encrypted_buffer->end_of_stream())
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 case PP_CDMEXCEPTIONCODE_CLIENTERROR: 283 case PP_CDMEXCEPTIONCODE_CLIENTERROR:
282 return MediaKeys::CLIENT_ERROR; 284 return MediaKeys::CLIENT_ERROR;
283 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: 285 case PP_CDMEXCEPTIONCODE_OUTPUTERROR:
284 return MediaKeys::OUTPUT_ERROR; 286 return MediaKeys::OUTPUT_ERROR;
285 default: 287 default:
286 NOTREACHED(); 288 NOTREACHED();
287 return MediaKeys::UNKNOWN_ERROR; 289 return MediaKeys::UNKNOWN_ERROR;
288 } 290 }
289 } 291 }
290 292
293 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) {
294 // Sparse histogram macro does not cache the histogram, so it's safe to use
295 // macro with non-static histogram name here.
296 UMA_HISTOGRAM_SPARSE_SLOWLY(
297 "Media.EME." + KeySystemNameForUMA(key_system) + ".SystemCode",
298 system_code);
299 }
300
291 } // namespace 301 } // namespace
292 302
293 ContentDecryptorDelegate::ContentDecryptorDelegate( 303 ContentDecryptorDelegate::ContentDecryptorDelegate(
294 PP_Instance pp_instance, 304 PP_Instance pp_instance,
295 const PPP_ContentDecryptor_Private* plugin_decryption_interface) 305 const PPP_ContentDecryptor_Private* plugin_decryption_interface)
296 : pp_instance_(pp_instance), 306 : pp_instance_(pp_instance),
297 plugin_decryption_interface_(plugin_decryption_interface), 307 plugin_decryption_interface_(plugin_decryption_interface),
298 next_decryption_request_id_(1), 308 next_decryption_request_id_(1),
299 audio_samples_per_second_(0), 309 audio_samples_per_second_(0),
300 audio_channel_count_(0), 310 audio_channel_count_(0),
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 770
761 KeyIdsPromise* key_ids_promise(static_cast<KeyIdsPromise*>(promise.get())); 771 KeyIdsPromise* key_ids_promise(static_cast<KeyIdsPromise*>(promise.get()));
762 key_ids_promise->resolve(key_ids_vector); 772 key_ids_promise->resolve(key_ids_vector);
763 } 773 }
764 774
765 void ContentDecryptorDelegate::OnPromiseRejected( 775 void ContentDecryptorDelegate::OnPromiseRejected(
766 uint32 promise_id, 776 uint32 promise_id,
767 PP_CdmExceptionCode exception_code, 777 PP_CdmExceptionCode exception_code,
768 uint32 system_code, 778 uint32 system_code,
769 PP_Var error_description) { 779 PP_Var error_description) {
780 ReportSystemCodeUMA(key_system_, system_code);
781
770 StringVar* error_description_string = StringVar::FromPPVar(error_description); 782 StringVar* error_description_string = StringVar::FromPPVar(error_description);
771 DCHECK(error_description_string); 783 DCHECK(error_description_string);
772 784
773 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); 785 scoped_ptr<CdmPromise> promise = TakePromise(promise_id);
774 DCHECK(promise); 786 DCHECK(promise);
775 if (promise) { 787 if (promise) {
776 promise->reject(PpExceptionTypeToMediaException(exception_code), 788 promise->reject(PpExceptionTypeToMediaException(exception_code),
777 system_code, 789 system_code,
778 error_description_string->value()); 790 error_description_string->value());
779 } 791 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 DCHECK(web_session_id_string); 851 DCHECK(web_session_id_string);
840 852
841 session_closed_cb_.Run(web_session_id_string->value()); 853 session_closed_cb_.Run(web_session_id_string->value());
842 } 854 }
843 855
844 void ContentDecryptorDelegate::OnSessionError( 856 void ContentDecryptorDelegate::OnSessionError(
845 PP_Var web_session_id, 857 PP_Var web_session_id,
846 PP_CdmExceptionCode exception_code, 858 PP_CdmExceptionCode exception_code,
847 uint32 system_code, 859 uint32 system_code,
848 PP_Var error_description) { 860 PP_Var error_description) {
861 ReportSystemCodeUMA(key_system_, system_code);
862
849 if (session_error_cb_.is_null()) 863 if (session_error_cb_.is_null())
850 return; 864 return;
851 865
852 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); 866 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id);
853 DCHECK(web_session_id_string); 867 DCHECK(web_session_id_string);
854 868
855 StringVar* error_description_string = StringVar::FromPPVar(error_description); 869 StringVar* error_description_string = StringVar::FromPPVar(error_description);
856 DCHECK(error_description_string); 870 DCHECK(error_description_string);
857 871
858 session_error_cb_.Run(web_session_id_string->value(), 872 session_error_cb_.Run(web_session_id_string->value(),
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1316
1303 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( 1317 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise(
1304 uint32_t promise_id) { 1318 uint32_t promise_id) {
1305 PromiseMap::iterator it = promises_.find(promise_id); 1319 PromiseMap::iterator it = promises_.find(promise_id);
1306 if (it == promises_.end()) 1320 if (it == promises_.end())
1307 return scoped_ptr<CdmPromise>(); 1321 return scoped_ptr<CdmPromise>();
1308 return promises_.take_and_erase(it); 1322 return promises_.take_and_erase(it);
1309 } 1323 }
1310 1324
1311 } // namespace content 1325 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698