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

Side by Side Diff: chromecast/base/device_capabilities_impl.cc

Issue 2258493003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/base/device_capabilities_impl.h" 5 #include "chromecast/base/device_capabilities_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 "hi_res_audio_supported"; 54 "hi_res_audio_supported";
55 55
56 // static 56 // static
57 std::unique_ptr<DeviceCapabilities> DeviceCapabilities::Create() { 57 std::unique_ptr<DeviceCapabilities> DeviceCapabilities::Create() {
58 return base::WrapUnique(new DeviceCapabilitiesImpl); 58 return base::WrapUnique(new DeviceCapabilitiesImpl);
59 } 59 }
60 60
61 // static 61 // static
62 std::unique_ptr<DeviceCapabilities> DeviceCapabilities::CreateForTesting() { 62 std::unique_ptr<DeviceCapabilities> DeviceCapabilities::CreateForTesting() {
63 DeviceCapabilities* capabilities = new DeviceCapabilitiesImpl; 63 DeviceCapabilities* capabilities = new DeviceCapabilitiesImpl;
64 capabilities->SetCapability( 64 capabilities->SetCapability(kKeyBluetoothSupported,
65 kKeyBluetoothSupported, 65 base::MakeUnique<base::FundamentalValue>(false));
66 base::WrapUnique(new base::FundamentalValue(false))); 66 capabilities->SetCapability(kKeyDisplaySupported,
67 capabilities->SetCapability( 67 base::MakeUnique<base::FundamentalValue>(true));
68 kKeyDisplaySupported, base::WrapUnique(new base::FundamentalValue(true))); 68 capabilities->SetCapability(kKeyHiResAudioSupported,
69 capabilities->SetCapability( 69 base::MakeUnique<base::FundamentalValue>(false));
70 kKeyHiResAudioSupported, 70 capabilities->SetCapability(kKeyAssistantSupported,
71 base::WrapUnique(new base::FundamentalValue(false))); 71 base::MakeUnique<base::FundamentalValue>(true));
72 capabilities->SetCapability(
73 kKeyAssistantSupported,
74 base::WrapUnique(new base::FundamentalValue(true)));
75 return base::WrapUnique(capabilities); 72 return base::WrapUnique(capabilities);
76 } 73 }
77 74
78 scoped_refptr<DeviceCapabilities::Data> DeviceCapabilities::CreateData() { 75 scoped_refptr<DeviceCapabilities::Data> DeviceCapabilities::CreateData() {
79 return make_scoped_refptr(new Data); 76 return make_scoped_refptr(new Data);
80 } 77 }
81 78
82 scoped_refptr<DeviceCapabilities::Data> DeviceCapabilities::CreateData( 79 scoped_refptr<DeviceCapabilities::Data> DeviceCapabilities::CreateData(
83 std::unique_ptr<const base::DictionaryValue> dictionary) { 80 std::unique_ptr<const base::DictionaryValue> dictionary) {
84 DCHECK(dictionary.get()); 81 DCHECK(dictionary.get());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 152 }
156 153
157 void DeviceCapabilitiesImpl::Register(const std::string& key, 154 void DeviceCapabilitiesImpl::Register(const std::string& key,
158 Validator* validator) { 155 Validator* validator) {
159 DCHECK(IsValidRegisterKey(key)); 156 DCHECK(IsValidRegisterKey(key));
160 DCHECK(validator); 157 DCHECK(validator);
161 158
162 base::AutoLock auto_lock(validation_lock_); 159 base::AutoLock auto_lock(validation_lock_);
163 // Check that a validator has not already been registered for this key 160 // Check that a validator has not already been registered for this key
164 DCHECK_EQ(0u, validator_map_.count(key)); 161 DCHECK_EQ(0u, validator_map_.count(key));
165 validator_map_[key] = base::WrapUnique(new ValidatorInfo(validator)); 162 validator_map_[key] = base::MakeUnique<ValidatorInfo>(validator);
166 } 163 }
167 164
168 void DeviceCapabilitiesImpl::Unregister(const std::string& key, 165 void DeviceCapabilitiesImpl::Unregister(const std::string& key,
169 const Validator* validator) { 166 const Validator* validator) {
170 base::AutoLock auto_lock(validation_lock_); 167 base::AutoLock auto_lock(validation_lock_);
171 auto validator_it = validator_map_.find(key); 168 auto validator_it = validator_map_.find(key);
172 DCHECK(validator_it != validator_map_.end()); 169 DCHECK(validator_it != validator_map_.end());
173 // Check that validator being unregistered matches the original for |key|. 170 // Check that validator being unregistered matches the original for |key|.
174 // This prevents managers from accidentally unregistering incorrect 171 // This prevents managers from accidentally unregistering incorrect
175 // validators. 172 // validators.
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 DeviceCapabilitiesImpl::GenerateDataWithNewValue( 424 DeviceCapabilitiesImpl::GenerateDataWithNewValue(
428 const base::DictionaryValue& dict, 425 const base::DictionaryValue& dict,
429 const std::string& path, 426 const std::string& path,
430 std::unique_ptr<base::Value> new_value) { 427 std::unique_ptr<base::Value> new_value) {
431 std::unique_ptr<base::DictionaryValue> dict_deep_copy(dict.CreateDeepCopy()); 428 std::unique_ptr<base::DictionaryValue> dict_deep_copy(dict.CreateDeepCopy());
432 dict_deep_copy->Set(path, std::move(new_value)); 429 dict_deep_copy->Set(path, std::move(new_value));
433 return CreateData(std::move(dict_deep_copy)); 430 return CreateData(std::move(dict_deep_copy));
434 } 431 }
435 432
436 } // namespace chromecast 433 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/base/cast_sys_info_util_simple.cc ('k') | chromecast/base/device_capabilities_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698