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

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

Issue 1028243007: Call Device.SetCarrier when the ONC Carrier property is specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onc_clang
Patch Set: . Created 5 years, 9 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
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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 16 matching lines...) Expand all
27 27
28 std::string kSimPin = "1111"; 28 std::string kSimPin = "1111";
29 29
30 void ErrorFunction(const std::string& device_path, 30 void ErrorFunction(const std::string& device_path,
31 const std::string& error_name, 31 const std::string& error_name,
32 const std::string& error_message) { 32 const std::string& error_message) {
33 LOG(ERROR) << "Shill Error for: " << device_path 33 LOG(ERROR) << "Shill Error for: " << device_path
34 << ": " << error_name << " : " << error_message; 34 << ": " << error_name << " : " << error_message;
35 } 35 }
36 36
37 void PostNotFoundError( 37 void PostError(const std::string& error,
38 const ShillDeviceClient::ErrorCallback& error_callback) { 38 const ShillDeviceClient::ErrorCallback& error_callback) {
39 std::string error_message("Failed");
40 base::MessageLoop::current()->PostTask( 39 base::MessageLoop::current()->PostTask(
41 FROM_HERE, 40 FROM_HERE, base::Bind(error_callback, error, "Failed"));
pneubeck (no reviews) 2015/03/27 18:26:46 I don't feel particularly confident in Bind + cons
stevenjb 2015/03/27 23:18:04 I'm pretty sure it will get converted to a string,
42 base::Bind(error_callback, shill::kErrorResultNotFound, error_message)); 41 }
42
43 void PostNotFoundError(const ShillDeviceClient::ErrorCallback& error_callback) {
44 PostError(shill::kErrorResultNotFound, error_callback);
45 }
46
47 bool IsReadOnlyProperty(const std::string& name) {
48 if (name == shill::kCarrierProperty)
49 return true;
50 return false;
43 } 51 }
44 52
45 } // namespace 53 } // namespace
46 54
47 FakeShillDeviceClient::FakeShillDeviceClient() 55 FakeShillDeviceClient::FakeShillDeviceClient()
48 : initial_tdls_busy_count_(0), 56 : initial_tdls_busy_count_(0),
49 tdls_busy_count_(0), 57 tdls_busy_count_(0),
50 weak_ptr_factory_(this) { 58 weak_ptr_factory_(this) {
51 } 59 }
52 60
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const dbus::ObjectPath& device_path, 93 const dbus::ObjectPath& device_path,
86 const VoidDBusMethodCallback& callback) { 94 const VoidDBusMethodCallback& callback) {
87 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); 95 PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
88 } 96 }
89 97
90 void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path, 98 void FakeShillDeviceClient::SetProperty(const dbus::ObjectPath& device_path,
91 const std::string& name, 99 const std::string& name,
92 const base::Value& value, 100 const base::Value& value,
93 const base::Closure& callback, 101 const base::Closure& callback,
94 const ErrorCallback& error_callback) { 102 const ErrorCallback& error_callback) {
103 if (IsReadOnlyProperty(name))
104 PostError(shill::kErrorResultInvalidArguments, error_callback);
105 AlwaysSetProperty(device_path, name, value, callback, error_callback);
106 }
107
108 void FakeShillDeviceClient::AlwaysSetProperty(
109 const dbus::ObjectPath& device_path,
110 const std::string& name,
111 const base::Value& value,
112 const base::Closure& callback,
113 const ErrorCallback& error_callback) {
95 base::DictionaryValue* device_properties = NULL; 114 base::DictionaryValue* device_properties = NULL;
96 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), 115 if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(),
97 &device_properties)) { 116 &device_properties)) {
98 PostNotFoundError(error_callback); 117 PostNotFoundError(error_callback);
99 return; 118 return;
100 } 119 }
101 device_properties->SetWithoutPathExpansion(name, value.DeepCopy()); 120 device_properties->SetWithoutPathExpansion(name, value.DeepCopy());
102 base::MessageLoop::current()->PostTask( 121 base::MessageLoop::current()->PostTask(
103 FROM_HERE, 122 FROM_HERE,
104 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged, 123 base::Bind(&FakeShillDeviceClient::NotifyObserversPropertyChanged,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 PostNotFoundError(error_callback); 237 PostNotFoundError(error_callback);
219 return; 238 return;
220 } 239 }
221 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 240 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
222 } 241 }
223 242
224 void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path, 243 void FakeShillDeviceClient::SetCarrier(const dbus::ObjectPath& device_path,
225 const std::string& carrier, 244 const std::string& carrier,
226 const base::Closure& callback, 245 const base::Closure& callback,
227 const ErrorCallback& error_callback) { 246 const ErrorCallback& error_callback) {
228 if (!stub_devices_.HasKey(device_path.value())) { 247 AlwaysSetProperty(device_path, shill::kCarrierProperty,
229 PostNotFoundError(error_callback); 248 base::StringValue(carrier), callback, error_callback);
230 return;
231 }
232 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
233 } 249 }
234 250
235 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, 251 void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
236 const base::Closure& callback, 252 const base::Closure& callback,
237 const ErrorCallback& error_callback) { 253 const ErrorCallback& error_callback) {
238 if (!stub_devices_.HasKey(device_path.value())) { 254 if (!stub_devices_.HasKey(device_path.value())) {
239 PostNotFoundError(error_callback); 255 PostNotFoundError(error_callback);
240 return; 256 return;
241 } 257 }
242 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 258 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 488 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
473 observer_list_.find(device_path); 489 observer_list_.find(device_path);
474 if (iter != observer_list_.end()) 490 if (iter != observer_list_.end())
475 return *(iter->second); 491 return *(iter->second);
476 PropertyObserverList* observer_list = new PropertyObserverList(); 492 PropertyObserverList* observer_list = new PropertyObserverList();
477 observer_list_[device_path] = observer_list; 493 observer_list_[device_path] = observer_list;
478 return *observer_list; 494 return *observer_list;
479 } 495 }
480 496
481 } // namespace chromeos 497 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698