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

Side by Side Diff: chromeos/dbus/fake_shill_device_client.cc

Issue 2871653002: Remove raw base::DictionaryValue::SetWithoutPathExpansion in //chromeos (Closed)
Patch Set: Minor Fix Created 3 years, 7 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
« no previous file with comments | « no previous file | chromeos/dbus/fake_shill_ipconfig_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const std::string& name, 114 const std::string& name,
115 const base::Value& value, 115 const base::Value& value,
116 const base::Closure& callback, 116 const base::Closure& callback,
117 const ErrorCallback& error_callback) { 117 const ErrorCallback& error_callback) {
118 base::DictionaryValue* device_properties = NULL; 118 base::DictionaryValue* device_properties = NULL;
119 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), 119 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
120 &device_properties)) { 120 &device_properties)) {
121 PostNotFoundError(error_callback); 121 PostNotFoundError(error_callback);
122 return; 122 return;
123 } 123 }
124 device_properties->SetWithoutPathExpansion(name, value.DeepCopy()); 124 device_properties->SetWithoutPathExpansion(
125 name, base::MakeUnique<base::Value>(value));
125 base::ThreadTaskRunnerHandle::Get()->PostTask( 126 base::ThreadTaskRunnerHandle::Get()->PostTask(
126 FROM_HERE, 127 FROM_HERE,
127 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged, 128 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged,
128 weak_ptr_factory_.GetWeakPtr(), device_path, name)); 129 weak_ptr_factory_.GetWeakPtr(), device_path, name));
129 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 130 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
130 } 131 }
131 132
132 void FakeShillDeviceClient::ClearProperty( 133 void FakeShillDeviceClient::ClearProperty(
133 const dbus::ObjectPath& device_path, 134 const dbus::ObjectPath& device_path,
134 const std::string& name, 135 const std::string& name,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 base::DictionaryValue* device_properties = NULL; 489 base::DictionaryValue* device_properties = NULL;
489 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path, 490 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path,
490 &device_properties)) { 491 &device_properties)) {
491 NOTREACHED() << "Device not found: " << device_path; 492 NOTREACHED() << "Device not found: " << device_path;
492 return; 493 return;
493 } 494 }
494 495
495 base::DictionaryValue* simlock_dict = nullptr; 496 base::DictionaryValue* simlock_dict = nullptr;
496 if (!device_properties->GetDictionaryWithoutPathExpansion( 497 if (!device_properties->GetDictionaryWithoutPathExpansion(
497 shill::kSIMLockStatusProperty, &simlock_dict)) { 498 shill::kSIMLockStatusProperty, &simlock_dict)) {
498 simlock_dict = new base::DictionaryValue; 499 simlock_dict = device_properties->SetDictionaryWithoutPathExpansion(
499 device_properties->SetWithoutPathExpansion(shill::kSIMLockStatusProperty, 500 shill::kSIMLockStatusProperty,
500 simlock_dict); 501 base::MakeUnique<base::DictionaryValue>());
501 } 502 }
502 simlock_dict->Clear(); 503 simlock_dict->Clear();
503 simlock_dict->SetStringWithoutPathExpansion(shill::kSIMLockTypeProperty, 504 simlock_dict->SetStringWithoutPathExpansion(shill::kSIMLockTypeProperty,
504 status.type); 505 status.type);
505 simlock_dict->SetIntegerWithoutPathExpansion( 506 simlock_dict->SetIntegerWithoutPathExpansion(
506 shill::kSIMLockRetriesLeftProperty, status.retries_left); 507 shill::kSIMLockRetriesLeftProperty, status.retries_left);
507 simlock_dict->SetBooleanWithoutPathExpansion(shill::kSIMLockEnabledProperty, 508 simlock_dict->SetBooleanWithoutPathExpansion(shill::kSIMLockEnabledProperty,
508 status.lock_enabled); 509 status.lock_enabled);
509 NotifyObserversPropertyChanged(dbus::ObjectPath(device_path), 510 NotifyObserversPropertyChanged(dbus::ObjectPath(device_path),
510 shill::kSIMLockStatusProperty); 511 shill::kSIMLockStatusProperty);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 607 }
607 for (auto& observer : GetObserverList(device_path)) 608 for (auto& observer : GetObserverList(device_path))
608 observer.OnPropertyChanged(property, *value); 609 observer.OnPropertyChanged(property, *value);
609 } 610 }
610 611
611 base::DictionaryValue* FakeShillDeviceClient::GetDeviceProperties( 612 base::DictionaryValue* FakeShillDeviceClient::GetDeviceProperties(
612 const std::string& device_path) { 613 const std::string& device_path) {
613 base::DictionaryValue* properties = NULL; 614 base::DictionaryValue* properties = NULL;
614 if (!stub_devices_.GetDictionaryWithoutPathExpansion( 615 if (!stub_devices_.GetDictionaryWithoutPathExpansion(
615 device_path, &properties)) { 616 device_path, &properties)) {
616 properties = new base::DictionaryValue; 617 properties = stub_devices_.SetDictionaryWithoutPathExpansion(
617 stub_devices_.SetWithoutPathExpansion(device_path, properties); 618 device_path, base::MakeUnique<base::DictionaryValue>());
618 } 619 }
619 return properties; 620 return properties;
620 } 621 }
621 622
622 FakeShillDeviceClient::PropertyObserverList& 623 FakeShillDeviceClient::PropertyObserverList&
623 FakeShillDeviceClient::GetObserverList(const dbus::ObjectPath& device_path) { 624 FakeShillDeviceClient::GetObserverList(const dbus::ObjectPath& device_path) {
624 auto iter = observer_list_.find(device_path); 625 auto iter = observer_list_.find(device_path);
625 if (iter != observer_list_.end()) 626 if (iter != observer_list_.end())
626 return *(iter->second); 627 return *(iter->second);
627 PropertyObserverList* observer_list = new PropertyObserverList(); 628 PropertyObserverList* observer_list = new PropertyObserverList();
628 observer_list_[device_path] = base::WrapUnique(observer_list); 629 observer_list_[device_path] = base::WrapUnique(observer_list);
629 return *observer_list; 630 return *observer_list;
630 } 631 }
631 632
632 } // namespace chromeos 633 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/fake_shill_ipconfig_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698