OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/shill_ipconfig_client_stub.h" | 5 #include "chromeos/dbus/shill_ipconfig_client_stub.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path, | 37 void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path, |
38 const VoidDBusMethodCallback& callback) { | 38 const VoidDBusMethodCallback& callback) { |
39 } | 39 } |
40 | 40 |
41 void ShillIPConfigClientStub::GetProperties( | 41 void ShillIPConfigClientStub::GetProperties( |
42 const dbus::ObjectPath& ipconfig_path, | 42 const dbus::ObjectPath& ipconfig_path, |
43 const DictionaryValueCallback& callback) { | 43 const DictionaryValueCallback& callback) { |
44 if (callback.is_null()) | 44 if (callback.is_null()) |
45 return; | 45 return; |
46 const base::DictionaryValue* dict = NULL; | |
47 if (!stub_ipconfig_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), | |
48 &dict)) | |
49 return; | |
46 MessageLoop::current()->PostTask( | 50 MessageLoop::current()->PostTask( |
47 FROM_HERE, base::Bind(&ShillIPConfigClientStub::PassProperties, | 51 FROM_HERE, base::Bind(&ShillIPConfigClientStub::PassProperties, |
48 weak_ptr_factory_.GetWeakPtr(), | 52 weak_ptr_factory_.GetWeakPtr(), |
49 callback)); | 53 dict, |
54 callback)); | |
50 } | 55 } |
51 | 56 |
52 base::DictionaryValue* ShillIPConfigClientStub::CallGetPropertiesAndBlock( | 57 base::DictionaryValue* ShillIPConfigClientStub::CallGetPropertiesAndBlock( |
53 const dbus::ObjectPath& ipconfig_path) { | 58 const dbus::ObjectPath& ipconfig_path) { |
54 return new base::DictionaryValue; | 59 return new base::DictionaryValue; |
55 } | 60 } |
56 | 61 |
57 void ShillIPConfigClientStub::SetProperty( | 62 void ShillIPConfigClientStub::SetProperty( |
58 const dbus::ObjectPath& ipconfig_path, | 63 const dbus::ObjectPath& ipconfig_path, |
59 const std::string& name, | 64 const std::string& name, |
60 const base::Value& value, | 65 const base::Value& value, |
61 const VoidDBusMethodCallback& callback) { | 66 const VoidDBusMethodCallback& callback) { |
62 if (callback.is_null()) | 67 if (callback.is_null()) |
63 return; | 68 return; |
69 base::DictionaryValue* dict = NULL; | |
70 if (!stub_ipconfig_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), | |
pneubeck (no reviews)
2013/03/28 10:37:54
swap cases.
gauravsh
2013/03/28 18:48:54
Curious, Why?
stevenjb
2013/03/28 19:27:13
Usually the positive test should proceed the negat
gauravsh
2013/03/28 19:54:23
Done.
| |
71 &dict)) { | |
72 // Create a new stub ipconfig object, and update its properties. | |
73 DictionaryValue* dvalue = new DictionaryValue; | |
74 dvalue->SetWithoutPathExpansion(name, value.DeepCopy()); | |
75 stub_ipconfig_.SetWithoutPathExpansion(ipconfig_path.value(), | |
76 dvalue); | |
77 } else { | |
78 // Update existing ip config stub object's properties. | |
79 dict->SetWithoutPathExpansion(name, value.DeepCopy()); | |
80 } | |
64 MessageLoop::current()->PostTask( | 81 MessageLoop::current()->PostTask( |
65 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); | 82 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
66 } | 83 } |
67 | 84 |
68 void ShillIPConfigClientStub::ClearProperty( | 85 void ShillIPConfigClientStub::ClearProperty( |
69 const dbus::ObjectPath& ipconfig_path, | 86 const dbus::ObjectPath& ipconfig_path, |
70 const std::string& name, | 87 const std::string& name, |
71 const VoidDBusMethodCallback& callback) { | 88 const VoidDBusMethodCallback& callback) { |
72 if (callback.is_null()) | 89 if (callback.is_null()) |
73 return; | 90 return; |
74 MessageLoop::current()->PostTask( | 91 MessageLoop::current()->PostTask( |
75 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); | 92 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
76 } | 93 } |
77 | 94 |
78 void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path, | 95 void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path, |
79 const VoidDBusMethodCallback& callback) { | 96 const VoidDBusMethodCallback& callback) { |
80 if (callback.is_null()) | 97 if (callback.is_null()) |
81 return; | 98 return; |
82 MessageLoop::current()->PostTask( | 99 MessageLoop::current()->PostTask( |
83 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); | 100 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
84 } | 101 } |
85 | 102 |
86 void ShillIPConfigClientStub::PassProperties( | 103 void ShillIPConfigClientStub::PassProperties( |
104 const base::DictionaryValue* values, | |
87 const DictionaryValueCallback& callback) const { | 105 const DictionaryValueCallback& callback) const { |
88 callback.Run(DBUS_METHOD_CALL_SUCCESS, properties_); | 106 callback.Run(DBUS_METHOD_CALL_SUCCESS, *values); |
89 } | 107 } |
90 | 108 |
91 } // namespace chromeos | 109 } // namespace chromeos |
OLD | NEW |