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 "webkit/media/crypto/ppapi_decryptor.h" | 5 #include "webkit/media/crypto/ppapi_decryptor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 cdm_plugin_(plugin_instance), | 25 cdm_plugin_(plugin_instance), |
26 render_loop_proxy_(base::MessageLoopProxy::current()) { | 26 render_loop_proxy_(base::MessageLoopProxy::current()) { |
27 DCHECK(client_); | 27 DCHECK(client_); |
28 DCHECK(cdm_plugin_); | 28 DCHECK(cdm_plugin_); |
29 cdm_plugin_->set_decrypt_client(client); | 29 cdm_plugin_->set_decrypt_client(client); |
30 } | 30 } |
31 | 31 |
32 PpapiDecryptor::~PpapiDecryptor() { | 32 PpapiDecryptor::~PpapiDecryptor() { |
33 } | 33 } |
34 | 34 |
35 void PpapiDecryptor::GenerateKeyRequest(const std::string& key_system, | 35 bool PpapiDecryptor::GenerateKeyRequest(const std::string& key_system, |
36 const uint8* init_data, | 36 const uint8* init_data, |
37 int init_data_length) { | 37 int init_data_length) { |
38 DVLOG(1) << "GenerateKeyRequest()"; | 38 DVLOG(1) << "GenerateKeyRequest()"; |
39 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 39 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
40 DCHECK(cdm_plugin_); | 40 DCHECK(cdm_plugin_); |
41 | 41 |
42 // TODO(xhwang): Finalize the data type for |init_data| to avoid unnecessary | 42 // TODO(xhwang): Finalize the data type for |init_data| to avoid unnecessary |
43 // data type conversions. | 43 // data type conversions. |
44 if (!cdm_plugin_->GenerateKeyRequest( | 44 if (!cdm_plugin_->GenerateKeyRequest( |
45 key_system, | 45 key_system, |
46 std::string(reinterpret_cast<const char*>(init_data), | 46 std::string(reinterpret_cast<const char*>(init_data), |
47 init_data_length))) { | 47 init_data_length))) { |
48 ReportFailureToCallPlugin(key_system, ""); | 48 ReportFailureToCallPlugin(key_system, ""); |
| 49 return false; |
49 } | 50 } |
| 51 |
| 52 return true; |
50 } | 53 } |
51 | 54 |
52 void PpapiDecryptor::AddKey(const std::string& key_system, | 55 void PpapiDecryptor::AddKey(const std::string& key_system, |
53 const uint8* key, | 56 const uint8* key, |
54 int key_length, | 57 int key_length, |
55 const uint8* init_data, | 58 const uint8* init_data, |
56 int init_data_length, | 59 int init_data_length, |
57 const std::string& session_id) { | 60 const std::string& session_id) { |
58 DVLOG(1) << "AddKey()"; | 61 DVLOG(1) << "AddKey()"; |
59 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 62 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void PpapiDecryptor::Stop() { | 100 void PpapiDecryptor::Stop() { |
98 } | 101 } |
99 | 102 |
100 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system, | 103 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system, |
101 const std::string& session_id) { | 104 const std::string& session_id) { |
102 DVLOG(1) << "Failed to call plugin."; | 105 DVLOG(1) << "Failed to call plugin."; |
103 client_->KeyError(key_system, session_id, kUnknownError, 0); | 106 client_->KeyError(key_system, session_id, kUnknownError, 0); |
104 } | 107 } |
105 | 108 |
106 } // namespace webkit_media | 109 } // namespace webkit_media |
OLD | NEW |