| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_shill_device_client.h" | 5 #include "chromeos/dbus/fake_shill_device_client.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) { | 597 if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) { |
| 598 LOG(ERROR) << "Notify for unknown service: " << path; | 598 LOG(ERROR) << "Notify for unknown service: " << path; |
| 599 return; | 599 return; |
| 600 } | 600 } |
| 601 base::Value* value = NULL; | 601 base::Value* value = NULL; |
| 602 if (!dict->GetWithoutPathExpansion(property, &value)) { | 602 if (!dict->GetWithoutPathExpansion(property, &value)) { |
| 603 LOG(ERROR) << "Notify for unknown property: " | 603 LOG(ERROR) << "Notify for unknown property: " |
| 604 << path << " : " << property; | 604 << path << " : " << property; |
| 605 return; | 605 return; |
| 606 } | 606 } |
| 607 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 607 for (auto& observer : GetObserverList(device_path)) |
| 608 GetObserverList(device_path), | 608 observer.OnPropertyChanged(property, *value); |
| 609 OnPropertyChanged(property, *value)); | |
| 610 } | 609 } |
| 611 | 610 |
| 612 base::DictionaryValue* FakeShillDeviceClient::GetDeviceProperties( | 611 base::DictionaryValue* FakeShillDeviceClient::GetDeviceProperties( |
| 613 const std::string& device_path) { | 612 const std::string& device_path) { |
| 614 base::DictionaryValue* properties = NULL; | 613 base::DictionaryValue* properties = NULL; |
| 615 if (!stub_devices_.GetDictionaryWithoutPathExpansion( | 614 if (!stub_devices_.GetDictionaryWithoutPathExpansion( |
| 616 device_path, &properties)) { | 615 device_path, &properties)) { |
| 617 properties = new base::DictionaryValue; | 616 properties = new base::DictionaryValue; |
| 618 stub_devices_.SetWithoutPathExpansion(device_path, properties); | 617 stub_devices_.SetWithoutPathExpansion(device_path, properties); |
| 619 } | 618 } |
| 620 return properties; | 619 return properties; |
| 621 } | 620 } |
| 622 | 621 |
| 623 FakeShillDeviceClient::PropertyObserverList& | 622 FakeShillDeviceClient::PropertyObserverList& |
| 624 FakeShillDeviceClient::GetObserverList(const dbus::ObjectPath& device_path) { | 623 FakeShillDeviceClient::GetObserverList(const dbus::ObjectPath& device_path) { |
| 625 auto iter = observer_list_.find(device_path); | 624 auto iter = observer_list_.find(device_path); |
| 626 if (iter != observer_list_.end()) | 625 if (iter != observer_list_.end()) |
| 627 return *(iter->second); | 626 return *(iter->second); |
| 628 PropertyObserverList* observer_list = new PropertyObserverList(); | 627 PropertyObserverList* observer_list = new PropertyObserverList(); |
| 629 observer_list_[device_path] = base::WrapUnique(observer_list); | 628 observer_list_[device_path] = base::WrapUnique(observer_list); |
| 630 return *observer_list; | 629 return *observer_list; |
| 631 } | 630 } |
| 632 | 631 |
| 633 } // namespace chromeos | 632 } // namespace chromeos |
| OLD | NEW |