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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chromeos/dbus/blocking_method_caller.h" | 9 #include "chromeos/dbus/blocking_method_caller.h" |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 DLOG_IF(ERROR, value.GetType() != base::Value::TYPE_STRING) | 377 DLOG_IF(ERROR, value.GetType() != base::Value::TYPE_STRING) |
378 << "Unexpected type " << value.GetType(); | 378 << "Unexpected type " << value.GetType(); |
379 value.GetAsString(&value_string); | 379 value.GetAsString(&value_string); |
380 entry_writer.AppendString(value_string); | 380 entry_writer.AppendString(value_string); |
381 array_writer.CloseContainer(&entry_writer); | 381 array_writer.CloseContainer(&entry_writer); |
382 } | 382 } |
383 variant_writer.CloseContainer(&array_writer); | 383 variant_writer.CloseContainer(&array_writer); |
384 writer->CloseContainer(&variant_writer); | 384 writer->CloseContainer(&variant_writer); |
385 break; | 385 break; |
386 } | 386 } |
| 387 case base::Value::TYPE_LIST: { |
| 388 const base::ListValue* list = NULL; |
| 389 value.GetAsList(&list); |
| 390 dbus::MessageWriter variant_writer(NULL); |
| 391 writer->OpenVariant("as", &variant_writer); |
| 392 dbus::MessageWriter array_writer(NULL); |
| 393 variant_writer.OpenArray("s", &array_writer); |
| 394 for (base::ListValue::const_iterator it = list->begin(); |
| 395 it != list->end(); ++it) { |
| 396 const base::Value& value = **it; |
| 397 LOG_IF(ERROR, value.GetType() != base::Value::TYPE_STRING) |
| 398 << "Unexpected type " << value.GetType(); |
| 399 std::string value_string; |
| 400 value.GetAsString(&value_string); |
| 401 array_writer.AppendString(value_string); |
| 402 } |
| 403 variant_writer.CloseContainer(&array_writer); |
| 404 writer->CloseContainer(&variant_writer); |
| 405 break; |
| 406 } |
387 case base::Value::TYPE_BOOLEAN: | 407 case base::Value::TYPE_BOOLEAN: |
388 case base::Value::TYPE_INTEGER: | 408 case base::Value::TYPE_INTEGER: |
389 case base::Value::TYPE_DOUBLE: | 409 case base::Value::TYPE_DOUBLE: |
390 case base::Value::TYPE_STRING: | 410 case base::Value::TYPE_STRING: |
391 dbus::AppendBasicTypeValueDataAsVariant(writer, value); | 411 dbus::AppendBasicTypeValueDataAsVariant(writer, value); |
392 break; | 412 break; |
393 default: | 413 default: |
394 DLOG(ERROR) << "Unexpected type " << value.GetType(); | 414 DLOG(ERROR) << "Unexpected type " << value.GetType(); |
395 } | 415 } |
396 | 416 |
(...skipping 17 matching lines...) Expand all Loading... |
414 scoped_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); | 434 scoped_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); |
415 if (!value.get()) | 435 if (!value.get()) |
416 return; | 436 return; |
417 | 437 |
418 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, observer_list_, | 438 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, observer_list_, |
419 OnPropertyChanged(name, *value)); | 439 OnPropertyChanged(name, *value)); |
420 } | 440 } |
421 | 441 |
422 | 442 |
423 } // namespace chromeos | 443 } // namespace chromeos |
OLD | NEW |