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

Unified Diff: media/crypto/aes_decryptor.cc

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: fixed remaining style issues Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/crypto/aes_decryptor.cc
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc
index 8136cadfb82751c1685d7cd6518a6552e19eb11c..60e5a57543d0254c863d878926c740df50b32ef7 100644
--- a/media/crypto/aes_decryptor.cc
+++ b/media/crypto/aes_decryptor.cc
@@ -47,8 +47,8 @@ static void CopySubsamples(const std::vector<SubsampleEntry>& subsamples,
// data if decryption succeeded or NULL if decryption failed.
static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
crypto::SymmetricKey* key) {
- CHECK(input.GetDataSize());
- CHECK(input.GetDecryptConfig());
+ CHECK(input.data_size());
+ CHECK(input.decrypt_config());
CHECK(key);
crypto::Encryptor encryptor;
@@ -57,19 +57,19 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
return NULL;
}
- DCHECK_EQ(input.GetDecryptConfig()->iv().size(),
+ DCHECK_EQ(input.decrypt_config()->iv().size(),
static_cast<size_t>(DecryptConfig::kDecryptionKeySize));
- if (!encryptor.SetCounter(input.GetDecryptConfig()->iv())) {
+ if (!encryptor.SetCounter(input.decrypt_config()->iv())) {
DVLOG(1) << "Could not set counter block.";
return NULL;
}
- const int data_offset = input.GetDecryptConfig()->data_offset();
+ const int data_offset = input.decrypt_config()->data_offset();
const char* sample =
- reinterpret_cast<const char*>(input.GetData() + data_offset);
- int sample_size = input.GetDataSize() - data_offset;
+ reinterpret_cast<const char*>(input.data() + data_offset);
+ int sample_size = input.data_size() - data_offset;
- if (input.GetDecryptConfig()->subsamples().empty()) {
+ if (input.decrypt_config()->subsamples().empty()) {
std::string decrypted_text;
base::StringPiece encrypted_text(sample, sample_size);
if (!encryptor.Decrypt(encrypted_text, &decrypted_text)) {
@@ -84,7 +84,7 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
}
const std::vector<SubsampleEntry>& subsamples =
- input.GetDecryptConfig()->subsamples();
+ input.decrypt_config()->subsamples();
int total_clear_size = 0;
int total_encrypted_size = 0;
@@ -104,8 +104,10 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
// copy the decrypted bytes over the encrypted bytes in the output.
// TODO(strobe): attempt to reduce number of memory copies
scoped_ptr<uint8[]> encrypted_bytes(new uint8[total_encrypted_size]);
- CopySubsamples(subsamples, kSrcContainsClearBytes,
- reinterpret_cast<const uint8*>(sample), encrypted_bytes.get());
+ CopySubsamples(subsamples,
+ kSrcContainsClearBytes,
+ reinterpret_cast<const uint8*>(sample),
+ encrypted_bytes.get());
base::StringPiece encrypted_text(
reinterpret_cast<const char*>(encrypted_bytes.get()),
@@ -118,9 +120,10 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
scoped_refptr<DecoderBuffer> output = DecoderBuffer::CopyFrom(
reinterpret_cast<const uint8*>(sample), sample_size);
- CopySubsamples(subsamples, kDstContainsClearBytes,
+ CopySubsamples(subsamples,
+ kDstContainsClearBytes,
reinterpret_cast<const uint8*>(decrypted_text.data()),
- output->GetWritableData());
+ output->writable_data());
return output;
}
@@ -131,12 +134,9 @@ AesDecryptor::AesDecryptor(const KeyAddedCB& key_added_cb,
: key_added_cb_(key_added_cb),
key_error_cb_(key_error_cb),
key_message_cb_(key_message_cb),
- need_key_cb_(need_key_cb) {
-}
+ need_key_cb_(need_key_cb) {}
-AesDecryptor::~AesDecryptor() {
- STLDeleteValues(&key_map_);
-}
+AesDecryptor::~AesDecryptor() { STLDeleteValues(&key_map_); }
bool AesDecryptor::GenerateKeyRequest(const std::string& type,
const uint8* init_data,
@@ -147,8 +147,8 @@ bool AesDecryptor::GenerateKeyRequest(const std::string& type,
// just fire the event with the |init_data| as the request.
std::string message;
if (init_data && init_data_length) {
- message = std::string(reinterpret_cast<const char*>(init_data),
- init_data_length);
+ message =
+ std::string(reinterpret_cast<const char*>(init_data), init_data_length);
}
key_message_cb_.Run(session_id_string, message, std::string());
@@ -173,7 +173,7 @@ void AesDecryptor::AddKey(const uint8* key,
// TODO(xhwang): Fix the decryptor to accept no |init_data|. See
// http://crbug.com/123265. Until then, ensure a non-empty value is passed.
- static const uint8 kDummyInitData[1] = { 0 };
+ static const uint8 kDummyInitData[1] = {0};
if (!init_data) {
init_data = kDummyInitData;
init_data_length = arraysize(kDummyInitData);
@@ -183,7 +183,7 @@ void AesDecryptor::AddKey(const uint8* key,
// compliant later (http://crbug.com/123262, http://crbug.com/123265).
std::string key_id_string(reinterpret_cast<const char*>(init_data),
init_data_length);
- std::string key_string(reinterpret_cast<const char*>(key) , key_length);
+ std::string key_string(reinterpret_cast<const char*>(key), key_length);
scoped_ptr<DecryptionKey> decryption_key(new DecryptionKey(key_string));
if (!decryption_key) {
DVLOG(1) << "Could not create key.";
@@ -208,12 +208,9 @@ void AesDecryptor::AddKey(const uint8* key,
key_added_cb_.Run(session_id);
}
-void AesDecryptor::CancelKeyRequest(const std::string& session_id) {
-}
+void AesDecryptor::CancelKeyRequest(const std::string& session_id) {}
-Decryptor* AesDecryptor::GetDecryptor() {
- return this;
-}
+Decryptor* AesDecryptor::GetDecryptor() { return this; }
void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
const NewKeyCB& new_key_cb) {
@@ -232,16 +229,16 @@ void AesDecryptor::RegisterNewKeyCB(StreamType stream_type,
void AesDecryptor::Decrypt(StreamType stream_type,
const scoped_refptr<DecoderBuffer>& encrypted,
const DecryptCB& decrypt_cb) {
- CHECK(encrypted->GetDecryptConfig());
+ CHECK(encrypted->decrypt_config());
scoped_refptr<DecoderBuffer> decrypted;
// An empty iv string signals that the frame is unencrypted.
- if (encrypted->GetDecryptConfig()->iv().empty()) {
- int data_offset = encrypted->GetDecryptConfig()->data_offset();
- decrypted = DecoderBuffer::CopyFrom(encrypted->GetData() + data_offset,
- encrypted->GetDataSize() - data_offset);
+ if (encrypted->decrypt_config()->iv().empty()) {
+ int data_offset = encrypted->decrypt_config()->data_offset();
+ decrypted = DecoderBuffer::CopyFrom(encrypted->data() + data_offset,
+ encrypted->data_size() - data_offset);
} else {
- const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
+ const std::string& key_id = encrypted->decrypt_config()->key_id();
DecryptionKey* key = GetKey(key_id);
if (!key) {
DVLOG(1) << "Could not find a matching key for the given key ID.";
@@ -258,8 +255,8 @@ void AesDecryptor::Decrypt(StreamType stream_type,
}
}
- decrypted->SetTimestamp(encrypted->GetTimestamp());
- decrypted->SetDuration(encrypted->GetDuration());
+ decrypted->set_timestamp(encrypted->timestamp());
+ decrypted->set_duration(encrypted->duration());
decrypt_cb.Run(kSuccess, decrypted);
}
@@ -321,15 +318,14 @@ AesDecryptor::DecryptionKey* AesDecryptor::GetKey(
}
AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret)
- : secret_(secret) {
-}
+ : secret_(secret) {}
AesDecryptor::DecryptionKey::~DecryptionKey() {}
bool AesDecryptor::DecryptionKey::Init() {
CHECK(!secret_.empty());
- decryption_key_.reset(crypto::SymmetricKey::Import(
- crypto::SymmetricKey::AES, secret_));
+ decryption_key_.reset(
+ crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_));
if (!decryption_key_)
return false;
return true;

Powered by Google App Engine
This is Rietveld 408576698