| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/shill_client_helper.h" | 5 #include "chromeos/dbus/shill_client_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 // Implements AppendValueDataAsVariant. If |dictionary_type| is | 436 // Implements AppendValueDataAsVariant. If |dictionary_type| is |
| 437 // DICTIONARY_TYPE_VARIANT and |value| is a Dictionary then it will be written | 437 // DICTIONARY_TYPE_VARIANT and |value| is a Dictionary then it will be written |
| 438 // as type 'a{ss}'. Otherwise dictionaries are written as type a{sv}. (This is | 438 // as type 'a{ss}'. Otherwise dictionaries are written as type a{sv}. (This is |
| 439 // to support Cellular.APN which expects a string -> string dictionary). | 439 // to support Cellular.APN which expects a string -> string dictionary). |
| 440 void AppendValueDataAsVariantInternal(dbus::MessageWriter* writer, | 440 void AppendValueDataAsVariantInternal(dbus::MessageWriter* writer, |
| 441 const base::Value& value, | 441 const base::Value& value, |
| 442 DictionaryType dictionary_type) { | 442 DictionaryType dictionary_type) { |
| 443 // Support basic types and string-to-string dictionary. | 443 // Support basic types and string-to-string dictionary. |
| 444 switch (value.GetType()) { | 444 switch (value.GetType()) { |
| 445 case base::Value::TYPE_DICTIONARY: { | 445 case base::Value::Type::DICTIONARY: { |
| 446 const base::DictionaryValue* dictionary = NULL; | 446 const base::DictionaryValue* dictionary = NULL; |
| 447 value.GetAsDictionary(&dictionary); | 447 value.GetAsDictionary(&dictionary); |
| 448 if (dictionary_type == DICTIONARY_TYPE_STRING) { | 448 if (dictionary_type == DICTIONARY_TYPE_STRING) { |
| 449 AppendStringDictionary(*dictionary, writer); | 449 AppendStringDictionary(*dictionary, writer); |
| 450 } else { | 450 } else { |
| 451 dbus::MessageWriter variant_writer(NULL); | 451 dbus::MessageWriter variant_writer(NULL); |
| 452 writer->OpenVariant("a{sv}", &variant_writer); | 452 writer->OpenVariant("a{sv}", &variant_writer); |
| 453 ShillClientHelper::AppendServicePropertiesDictionary(&variant_writer, | 453 ShillClientHelper::AppendServicePropertiesDictionary(&variant_writer, |
| 454 *dictionary); | 454 *dictionary); |
| 455 writer->CloseContainer(&variant_writer); | 455 writer->CloseContainer(&variant_writer); |
| 456 } | 456 } |
| 457 break; | 457 break; |
| 458 } | 458 } |
| 459 case base::Value::TYPE_LIST: { | 459 case base::Value::Type::LIST: { |
| 460 const base::ListValue* list = NULL; | 460 const base::ListValue* list = NULL; |
| 461 value.GetAsList(&list); | 461 value.GetAsList(&list); |
| 462 dbus::MessageWriter variant_writer(NULL); | 462 dbus::MessageWriter variant_writer(NULL); |
| 463 writer->OpenVariant("as", &variant_writer); | 463 writer->OpenVariant("as", &variant_writer); |
| 464 dbus::MessageWriter array_writer(NULL); | 464 dbus::MessageWriter array_writer(NULL); |
| 465 variant_writer.OpenArray("s", &array_writer); | 465 variant_writer.OpenArray("s", &array_writer); |
| 466 for (base::ListValue::const_iterator it = list->begin(); | 466 for (base::ListValue::const_iterator it = list->begin(); |
| 467 it != list->end(); ++it) { | 467 it != list->end(); ++it) { |
| 468 const base::Value& value = **it; | 468 const base::Value& value = **it; |
| 469 std::string value_string; | 469 std::string value_string; |
| 470 if (!value.GetAsString(&value_string)) | 470 if (!value.GetAsString(&value_string)) |
| 471 NET_LOG(ERROR) << "List value not a string: " << value; | 471 NET_LOG(ERROR) << "List value not a string: " << value; |
| 472 array_writer.AppendString(value_string); | 472 array_writer.AppendString(value_string); |
| 473 } | 473 } |
| 474 variant_writer.CloseContainer(&array_writer); | 474 variant_writer.CloseContainer(&array_writer); |
| 475 writer->CloseContainer(&variant_writer); | 475 writer->CloseContainer(&variant_writer); |
| 476 break; | 476 break; |
| 477 } | 477 } |
| 478 case base::Value::TYPE_BOOLEAN: | 478 case base::Value::Type::BOOLEAN: |
| 479 case base::Value::TYPE_INTEGER: | 479 case base::Value::Type::INTEGER: |
| 480 case base::Value::TYPE_DOUBLE: | 480 case base::Value::Type::DOUBLE: |
| 481 case base::Value::TYPE_STRING: | 481 case base::Value::Type::STRING: |
| 482 dbus::AppendBasicTypeValueDataAsVariant(writer, value); | 482 dbus::AppendBasicTypeValueDataAsVariant(writer, value); |
| 483 break; | 483 break; |
| 484 default: | 484 default: |
| 485 NET_LOG(ERROR) << "Unexpected value type: " << value.GetType(); | 485 NET_LOG(ERROR) << "Unexpected value type: " << value.GetType(); |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace | 489 } // namespace |
| 490 | 490 |
| 491 // static | 491 // static |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 return; | 545 return; |
| 546 std::unique_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); | 546 std::unique_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); |
| 547 if (!value.get()) | 547 if (!value.get()) |
| 548 return; | 548 return; |
| 549 | 549 |
| 550 for (auto& observer : observer_list_) | 550 for (auto& observer : observer_list_) |
| 551 observer.OnPropertyChanged(name, *value); | 551 observer.OnPropertyChanged(name, *value); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace chromeos | 554 } // namespace chromeos |
| OLD | NEW |