OLD | NEW |
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/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 if (!session_id_string) { | 583 if (!session_id_string) { |
584 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | 584 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); |
585 return; | 585 return; |
586 } | 586 } |
587 | 587 |
588 session_created_cb_.Run(session_id, session_id_string->value()); | 588 session_created_cb_.Run(session_id, session_id_string->value()); |
589 } | 589 } |
590 | 590 |
591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, | 591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, |
592 PP_Var message_var, | 592 PP_Var message_var, |
593 PP_Var default_url_var) { | 593 PP_Var destination_url_var) { |
594 // TODO(amogh.bihani): Replace all the default_url with destination_url. | |
595 if (session_message_cb_.is_null()) | 594 if (session_message_cb_.is_null()) |
596 return; | 595 return; |
597 | 596 |
598 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); | 597 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); |
599 | 598 |
600 std::vector<uint8> message; | 599 std::vector<uint8> message; |
601 if (message_array_buffer) { | 600 if (message_array_buffer) { |
602 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); | 601 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); |
603 message.assign(data, data + message_array_buffer->ByteLength()); | 602 message.assign(data, data + message_array_buffer->ByteLength()); |
604 } | 603 } |
605 | 604 |
606 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); | 605 StringVar* destination_url_string = StringVar::FromPPVar(destination_url_var); |
607 | 606 |
608 if (!default_url_string) { | 607 if (!destination_url_string) { |
609 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | 608 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); |
610 return; | 609 return; |
611 } | 610 } |
612 | 611 |
613 GURL verified_gurl = GURL(default_url_string->value()); | 612 GURL verified_gurl = GURL(destination_url_string->value()); |
614 if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { | 613 if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { |
615 DLOG(WARNING) << "SessionMessage default_url is invalid : " | 614 DLOG(WARNING) << "SessionMessage default_url is invalid : " |
616 << verified_gurl.possibly_invalid_spec(); | 615 << verified_gurl.possibly_invalid_spec(); |
617 verified_gurl = GURL::EmptyGURL(); // Replace invalid default_url. | 616 verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. |
618 } | 617 } |
619 | 618 |
620 session_message_cb_.Run(session_id, message, verified_gurl); | 619 session_message_cb_.Run(session_id, message, verified_gurl); |
621 } | 620 } |
622 | 621 |
623 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { | 622 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { |
624 if (session_ready_cb_.is_null()) | 623 if (session_ready_cb_.is_null()) |
625 return; | 624 return; |
626 | 625 |
627 session_ready_cb_.Run(session_id); | 626 session_ready_cb_.Run(session_id); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 const media::Decryptor::AudioBuffers empty_frames; | 1063 const media::Decryptor::AudioBuffers empty_frames; |
1065 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, | 1064 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, |
1066 empty_frames); | 1065 empty_frames); |
1067 } | 1066 } |
1068 | 1067 |
1069 if (!video_decode_cb_.is_null()) | 1068 if (!video_decode_cb_.is_null()) |
1070 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1069 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1071 } | 1070 } |
1072 | 1071 |
1073 } // namespace content | 1072 } // namespace content |
OLD | NEW |