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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/utils.cc

Issue 2030013003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 "chrome/browser/extensions/api/bluetooth_low_energy/utils.h" 5 #include "chrome/browser/extensions/api/bluetooth_low_energy/utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <iterator> 8 #include <iterator>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 namespace api { 14 namespace api {
15 namespace bluetooth_low_energy { 15 namespace bluetooth_low_energy {
16 16
17 namespace { 17 namespace {
18 18
19 // Converts a list of CharacteristicProperty to a base::ListValue of strings. 19 // Converts a list of CharacteristicProperty to a base::ListValue of strings.
20 std::unique_ptr<base::ListValue> CharacteristicPropertiesToValue( 20 std::unique_ptr<base::ListValue> CharacteristicPropertiesToValue(
21 const std::vector<CharacteristicProperty> properties) { 21 const std::vector<CharacteristicProperty> properties) {
22 std::unique_ptr<base::ListValue> property_list(new base::ListValue()); 22 std::unique_ptr<base::ListValue> property_list(new base::ListValue());
23 for (std::vector<CharacteristicProperty>::const_iterator iter = 23 for (std::vector<CharacteristicProperty>::const_iterator iter =
24 properties.begin(); 24 properties.begin();
25 iter != properties.end(); 25 iter != properties.end();
26 ++iter) 26 ++iter)
27 property_list->Append(new base::StringValue(ToString(*iter))); 27 property_list->AppendString(ToString(*iter));
28 return property_list; 28 return property_list;
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 std::unique_ptr<base::DictionaryValue> CharacteristicToValue( 33 std::unique_ptr<base::DictionaryValue> CharacteristicToValue(
34 Characteristic* from) { 34 Characteristic* from) {
35 // Copy the properties. Use Characteristic::ToValue to generate the result 35 // Copy the properties. Use Characteristic::ToValue to generate the result
36 // dictionary without the properties, to prevent json_schema_compiler from 36 // dictionary without the properties, to prevent json_schema_compiler from
37 // failing. 37 // failing.
(...skipping 19 matching lines...) Expand all
57 to->GetDictionaryWithoutPathExpansion("characteristic", &chrc_value); 57 to->GetDictionaryWithoutPathExpansion("characteristic", &chrc_value);
58 DCHECK(chrc_value); 58 DCHECK(chrc_value);
59 chrc_value->SetWithoutPathExpansion( 59 chrc_value->SetWithoutPathExpansion(
60 "properties", CharacteristicPropertiesToValue(properties).release()); 60 "properties", CharacteristicPropertiesToValue(properties).release());
61 return to; 61 return to;
62 } 62 }
63 63
64 } // namespace bluetooth_low_energy 64 } // namespace bluetooth_low_energy
65 } // namespace api 65 } // namespace api
66 } // namespace extensions 66 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698