Skip to content

Commit

Permalink
Remove ScopedVector from all other codes in media/
Browse files Browse the repository at this point in the history
base::ScopedVector is deprecated, see bug.

BUG=554289, 588249
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2891683002
Cr-Commit-Position: refs/heads/master@{#472700}
  • Loading branch information
xzhan96 authored and Commit bot committed May 18, 2017
1 parent 268fc24 commit 60c246a
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 111 deletions.
8 changes: 3 additions & 5 deletions chromecast/media/cdm/cast_cdm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void CastCdm::OnSessionKeysChange(const std::string& session_id,
logging::LogMessage log_message(__FILE__, __LINE__, logging::LOG_INFO);
log_message.stream() << "keystatuseschange ";
int status_count[::media::CdmKeyInformation::KEY_STATUS_MAX] = {0};
for (const auto* key_info : keys_info) {
for (const auto& key_info : keys_info) {
status_count[key_info->status]++;
}
for (int i = 0; i != ::media::CdmKeyInformation::KEY_STATUS_MAX; ++i) {
Expand Down Expand Up @@ -156,10 +156,8 @@ void CastCdm::KeyIdAndKeyPairsToInfo(const ::media::KeyIdAndKeyPairs& keys,
::media::CdmKeysInfo* keys_info) {
DCHECK(keys_info);
for (const std::pair<std::string, std::string>& key : keys) {
std::unique_ptr<::media::CdmKeyInformation> cdm_key_information(
new ::media::CdmKeyInformation(key.first,
::media::CdmKeyInformation::USABLE, 0));
keys_info->push_back(cdm_key_information.release());
keys_info->push_back(base::MakeUnique<::media::CdmKeyInformation>(
key.first, ::media::CdmKeyInformation::USABLE, 0));
}
}

Expand Down
3 changes: 2 additions & 1 deletion content/renderer/pepper/content_decryptor_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "base/callback_helpers.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/trace_event/trace_event.h"
Expand Down Expand Up @@ -809,7 +810,7 @@ void ContentDecryptorDelegate::OnSessionKeysChange(
keys_info.reserve(key_count);
for (uint32_t i = 0; i < key_count; ++i) {
const auto& info = key_information[i];
keys_info.push_back(new media::CdmKeyInformation(
keys_info.push_back(base::MakeUnique<media::CdmKeyInformation>(
info.key_id, info.key_id_size,
PpCdmKeyStatusToCdmKeyInformationKeyStatus(info.key_status),
info.system_code));
Expand Down
4 changes: 3 additions & 1 deletion media/base/android/media_drm_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -740,7 +741,8 @@ void MediaDrmBridge::OnSessionKeysChange(
<< base::HexEncode(&key_id[0], key_id.size()) << ", "
<< key_status;

cdm_keys_info.push_back(new CdmKeyInformation(key_id, key_status, 0));
cdm_keys_info.push_back(
base::MakeUnique<CdmKeyInformation>(key_id, key_status, 0));
}

task_runner_->PostTask(
Expand Down
3 changes: 1 addition & 2 deletions media/base/content_decryption_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "media/base/eme_constants.h"
#include "media/base/media_export.h"
#include "url/gurl.h"
Expand All @@ -34,7 +33,7 @@ class CdmPromiseTemplate;

typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise;
typedef CdmPromiseTemplate<> SimpleCdmPromise;
typedef ScopedVector<CdmKeyInformation> CdmKeysInfo;
typedef std::vector<std::unique_ptr<CdmKeyInformation>> CdmKeysInfo;

// Type of license required when creating/loading a session.
// Must be consistent with the values specified in the spec:
Expand Down
4 changes: 2 additions & 2 deletions media/blink/cdm_session_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id,
if (session) {
DVLOG(2) << __func__ << ": session_id = " << session_id;
DVLOG(2) << " - has_additional_usable_key = " << has_additional_usable_key;
for (const CdmKeyInformation* info : keys_info)
DVLOG(2) << " - " << *info;
for (const auto& info : keys_info)
DVLOG(2) << " - " << *(info.get());

session->OnSessionKeysChange(has_additional_usable_key,
std::move(keys_info));
Expand Down
2 changes: 1 addition & 1 deletion media/blink/webcontentdecryptionmodulesession_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange(
blink::WebVector<blink::WebEncryptedMediaKeyInformation> keys(
keys_info.size());
for (size_t i = 0; i < keys_info.size(); ++i) {
auto* key_info = keys_info[i];
auto& key_info = keys_info[i];
keys[i].SetId(blink::WebData(reinterpret_cast<char*>(&key_info->key_id[0]),
key_info->key_id.size()));
keys[i].SetStatus(convertStatus(key_info->status));
Expand Down
4 changes: 3 additions & 1 deletion media/cdm/aes_decryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
Expand Down Expand Up @@ -655,7 +656,8 @@ CdmKeysInfo AesDecryptor::GenerateKeysInfoList(
base::AutoLock auto_lock(key_map_lock_);
for (const auto& item : key_map_) {
if (item.second->Contains(session_id)) {
keys_info.push_back(new CdmKeyInformation(item.first, status, 0));
keys_info.push_back(
base::MakeUnique<CdmKeyInformation>(item.first, status, 0));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion media/cdm/aes_decryptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class AesDecryptorTest : public testing::TestWithParam<std::string> {
bool KeysInfoContains(const std::vector<uint8_t>& expected_key_id,
CdmKeyInformation::KeyStatus expected_status =
CdmKeyInformation::USABLE) {
for (auto* key_id : cdm_client_.keys_info()) {
for (auto& key_id : cdm_client_.keys_info()) {
if (key_id->key_id == expected_key_id &&
key_id->status == expected_status) {
return true;
Expand Down
3 changes: 2 additions & 1 deletion media/cdm/cdm_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -786,7 +787,7 @@ void CdmAdapter::OnSessionKeysChange(const char* session_id,
keys.reserve(keys_info_count);
for (uint32_t i = 0; i < keys_info_count; ++i) {
const auto& info = keys_info[i];
keys.push_back(new CdmKeyInformation(
keys.push_back(base::MakeUnique<CdmKeyInformation>(
info.key_id, info.key_id_size,
ToCdmKeyInformationKeyStatus(info.status), info.system_code));
}
Expand Down
6 changes: 3 additions & 3 deletions media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ cdm::KeyStatus ConvertKeyStatus(media::CdmKeyInformation::KeyStatus status) {
// Shallow copy all the key information from |keys_info| into |keys_vector|.
// |keys_vector| is only valid for the lifetime of |keys_info| because it
// contains pointers into the latter.
void ConvertCdmKeysInfo(const std::vector<media::CdmKeyInformation*>& keys_info,
void ConvertCdmKeysInfo(const media::CdmKeysInfo& keys_info,
std::vector<cdm::KeyInformation>* keys_vector) {
keys_vector->reserve(keys_info.size());
for (const auto& key_info : keys_info) {
Expand Down Expand Up @@ -868,7 +868,7 @@ void ClearKeyCdm::OnSessionKeysChange(const std::string& session_id,
}

std::vector<cdm::KeyInformation> keys_vector;
ConvertCdmKeysInfo(keys_info.get(), &keys_vector);
ConvertCdmKeysInfo(keys_info, &keys_vector);
host_->OnSessionKeysChange(new_session_id.data(), new_session_id.length(),
has_additional_usable_key, keys_vector.data(),
keys_vector.size());
Expand Down Expand Up @@ -943,7 +943,7 @@ void ClearKeyCdm::OnLoadSessionUpdated() {
keys_info.swap(keys_info_for_emulated_loadsession_);
has_received_keys_change_event_for_emulated_loadsession_ = false;
DCHECK(!keys_vector.empty());
ConvertCdmKeysInfo(keys_info.get(), &keys_vector);
ConvertCdmKeysInfo(keys_info, &keys_vector);
host_->OnSessionKeysChange(kLoadableSessionId, strlen(kLoadableSessionId),
!keys_vector.empty(), keys_vector.data(),
keys_vector.size());
Expand Down
12 changes: 7 additions & 5 deletions media/formats/webm/opus_packet_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "media/formats/webm/opus_packet_builder.h"

#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "media/formats/webm/webm_cluster_parser.h"

namespace media {
Expand Down Expand Up @@ -62,23 +64,23 @@ double OpusPacket::duration_ms() const {
return duration_ms_;
}

ScopedVector<OpusPacket> BuildAllOpusPackets() {
ScopedVector<OpusPacket> opus_packets;
std::vector<std::unique_ptr<OpusPacket>> BuildAllOpusPackets() {
std::vector<std::unique_ptr<OpusPacket>> opus_packets;

for (int frame_count = kMinOpusPacketFrameCount;
frame_count <= kMaxOpusPacketFrameCount; frame_count++) {
for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs;
opus_config_num++) {
bool is_VBR = false;
opus_packets.push_back(
new OpusPacket(opus_config_num, frame_count, is_VBR));
base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR));

if (frame_count >= 2) {
// Add another packet with VBR flag toggled. For frame counts >= 2,
// VBR triggers changes to packet framing.
is_VBR = true;
opus_packets.push_back(
new OpusPacket(opus_config_num, frame_count, is_VBR));
base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions media/formats/webm/opus_packet_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <vector>

#include "base/macros.h"
#include "base/memory/scoped_vector.h"

namespace media {

Expand Down Expand Up @@ -39,7 +38,7 @@ class OpusPacket {
};

// Builds an exhaustive collection of Opus packet configurations.
ScopedVector<OpusPacket> BuildAllOpusPackets();
std::vector<std::unique_ptr<OpusPacket>> BuildAllOpusPackets();

} // namespace media

Expand Down
4 changes: 2 additions & 2 deletions media/formats/webm/webm_cluster_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ TEST_F(WebMClusterParserTest,

TEST_F(WebMClusterParserTest, ReadOpusDurationsSimpleBlockAtEndOfCluster) {
int loop_count = 0;
for (const auto* packet_ptr : BuildAllOpusPackets()) {
for (const auto& packet_ptr : BuildAllOpusPackets()) {
InSequence s;

// Get a new parser each iteration to prevent exceeding the media log cap.
Expand Down Expand Up @@ -1103,7 +1103,7 @@ TEST_F(WebMClusterParserTest, ReadOpusDurationsSimpleBlockAtEndOfCluster) {

TEST_F(WebMClusterParserTest, PreferOpusDurationsOverBlockDurations) {
int loop_count = 0;
for (const auto* packet_ptr : BuildAllOpusPackets()) {
for (const auto& packet_ptr : BuildAllOpusPackets()) {
InSequence s;

// Get a new parser each iteration to prevent exceeding the media log cap.
Expand Down
21 changes: 11 additions & 10 deletions media/gpu/jpeg_decode_accelerator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
Expand Down Expand Up @@ -324,7 +324,7 @@ class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment {
// Parsed data of failure image.
std::unique_ptr<TestImageFile> image_data_invalid_;
// Parsed data from command line.
ScopedVector<TestImageFile> image_data_user_;
std::vector<std::unique_ptr<TestImageFile>> image_data_user_;

private:
const base::FilePath::CharType* user_jpeg_filenames_;
Expand Down Expand Up @@ -376,7 +376,7 @@ void JpegDecodeAcceleratorTestEnvironment::SetUp() {
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const auto& filename : filenames) {
base::FilePath input_file = GetTestDataFilePath(filename);
TestImageFile* image_data = new TestImageFile(filename);
auto image_data = base::MakeUnique<TestImageFile>(filename);
ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data));
image_data_user_.push_back(image_data);
}
Expand Down Expand Up @@ -443,23 +443,24 @@ void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) {
base::Thread decoder_thread("DecoderThread");
ASSERT_TRUE(decoder_thread.Start());

ScopedVector<ClientStateNotification<ClientState>> notes;
ScopedVector<JpegClient> clients;
std::vector<std::unique_ptr<ClientStateNotification<ClientState>>> notes;
std::vector<std::unique_ptr<JpegClient>> clients;

for (size_t i = 0; i < num_concurrent_decoders; i++) {
notes.push_back(new ClientStateNotification<ClientState>());
clients.push_back(new JpegClient(test_image_files_, notes.back()));
notes.push_back(base::MakeUnique<ClientStateNotification<ClientState>>());
clients.push_back(
base::MakeUnique<JpegClient>(test_image_files_, notes.back()));
decoder_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(&JpegClient::CreateJpegDecoder,
base::Unretained(clients.back())));
base::Unretained(clients.back().get())));
ASSERT_EQ(notes[i]->Wait(), CS_INITIALIZED);
}

for (size_t index = 0; index < test_image_files_.size(); index++) {
for (size_t i = 0; i < num_concurrent_decoders; i++) {
decoder_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(&JpegClient::StartDecode,
base::Unretained(clients[i]), index));
base::Unretained(clients[i].get(), index));
}
if (index < expected_status_.size()) {
for (size_t i = 0; i < num_concurrent_decoders; i++) {
Expand All @@ -471,7 +472,7 @@ void JpegDecodeAcceleratorTest::TestDecode(size_t num_concurrent_decoders) {
for (size_t i = 0; i < num_concurrent_decoders; i++) {
decoder_thread.task_runner()->PostTask(
FROM_HERE, base::Bind(&JpegClient::DestroyJpegDecoder,
base::Unretained(clients[i])));
base::Unretained(clients[i].get())));
}
decoder_thread.Stop();
}
Expand Down
Loading

0 comments on commit 60c246a

Please sign in to comment.