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

Side by Side Diff: chromecast/media/cma/ipc_streamer/decrypt_config_marshaller.cc

Issue 1875623002: Convert //chromecast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/media/cma/ipc_streamer/decrypt_config_marshaller.h" 5 #include "chromecast/media/cma/ipc_streamer/decrypt_config_marshaller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chromecast/media/cma/base/cast_decrypt_config_impl.h" 10 #include "chromecast/media/cma/base/cast_decrypt_config_impl.h"
(...skipping 21 matching lines...) Expand all
32 CHECK(msg->WritePod(config.iv().size())); 32 CHECK(msg->WritePod(config.iv().size()));
33 CHECK(msg->WriteBuffer(config.iv().data(), config.iv().size())); 33 CHECK(msg->WriteBuffer(config.iv().data(), config.iv().size()));
34 CHECK(msg->WritePod(config.subsamples().size())); 34 CHECK(msg->WritePod(config.subsamples().size()));
35 for (size_t k = 0; k < config.subsamples().size(); k++) { 35 for (size_t k = 0; k < config.subsamples().size(); k++) {
36 CHECK(msg->WritePod(config.subsamples()[k].clear_bytes)); 36 CHECK(msg->WritePod(config.subsamples()[k].clear_bytes));
37 CHECK(msg->WritePod(config.subsamples()[k].cypher_bytes)); 37 CHECK(msg->WritePod(config.subsamples()[k].cypher_bytes));
38 } 38 }
39 } 39 }
40 40
41 // static 41 // static
42 scoped_ptr<CastDecryptConfig> DecryptConfigMarshaller::Read(MediaMessage* msg) { 42 std::unique_ptr<CastDecryptConfig> DecryptConfigMarshaller::Read(
43 MediaMessage* msg) {
43 size_t key_id_size = 0; 44 size_t key_id_size = 0;
44 CHECK(msg->ReadPod(&key_id_size)); 45 CHECK(msg->ReadPod(&key_id_size));
45 CHECK_GT(key_id_size, 0u); 46 CHECK_GT(key_id_size, 0u);
46 CHECK_LT(key_id_size, kMaxKeyIdSize); 47 CHECK_LT(key_id_size, kMaxKeyIdSize);
47 scoped_ptr<char[]> key_id(new char[key_id_size]); 48 std::unique_ptr<char[]> key_id(new char[key_id_size]);
48 CHECK(msg->ReadBuffer(key_id.get(), key_id_size)); 49 CHECK(msg->ReadBuffer(key_id.get(), key_id_size));
49 50
50 size_t iv_size = 0; 51 size_t iv_size = 0;
51 CHECK(msg->ReadPod(&iv_size)); 52 CHECK(msg->ReadPod(&iv_size));
52 CHECK_GT(iv_size, 0u); 53 CHECK_GT(iv_size, 0u);
53 CHECK_LT(iv_size, kMaxIvSize); 54 CHECK_LT(iv_size, kMaxIvSize);
54 scoped_ptr<char[]> iv(new char[iv_size]); 55 std::unique_ptr<char[]> iv(new char[iv_size]);
55 CHECK(msg->ReadBuffer(iv.get(), iv_size)); 56 CHECK(msg->ReadBuffer(iv.get(), iv_size));
56 57
57 size_t subsample_count = 0; 58 size_t subsample_count = 0;
58 CHECK(msg->ReadPod(&subsample_count)); 59 CHECK(msg->ReadPod(&subsample_count));
59 CHECK_GT(subsample_count, 0u); 60 CHECK_GT(subsample_count, 0u);
60 CHECK_LT(subsample_count, kMaxSubsampleCount); 61 CHECK_LT(subsample_count, kMaxSubsampleCount);
61 std::vector<SubsampleEntry> subsamples(subsample_count); 62 std::vector<SubsampleEntry> subsamples(subsample_count);
62 for (size_t k = 0; k < subsample_count; k++) { 63 for (size_t k = 0; k < subsample_count; k++) {
63 subsamples[k].clear_bytes = 0; 64 subsamples[k].clear_bytes = 0;
64 subsamples[k].cypher_bytes = 0; 65 subsamples[k].cypher_bytes = 0;
65 CHECK(msg->ReadPod(&subsamples[k].clear_bytes)); 66 CHECK(msg->ReadPod(&subsamples[k].clear_bytes));
66 CHECK(msg->ReadPod(&subsamples[k].cypher_bytes)); 67 CHECK(msg->ReadPod(&subsamples[k].cypher_bytes));
67 } 68 }
68 69
69 return scoped_ptr<CastDecryptConfig>( 70 return std::unique_ptr<CastDecryptConfig>(
70 new CastDecryptConfigImpl(std::string(key_id.get(), key_id_size), 71 new CastDecryptConfigImpl(std::string(key_id.get(), key_id_size),
71 std::string(iv.get(), iv_size), subsamples)); 72 std::string(iv.get(), iv_size), subsamples));
72 } 73 }
73 74
74 } // namespace media 75 } // namespace media
75 } // namespace chromecast 76 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698