| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 | 
| OLD | NEW | 
|---|