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 "dbus/property.h" | 5 #include "dbus/property.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 DCHECK(object_proxy_); | 168 DCHECK(object_proxy_); |
169 object_proxy_->CallMethod(&method_call, | 169 object_proxy_->CallMethod(&method_call, |
170 ObjectProxy::TIMEOUT_USE_DEFAULT, | 170 ObjectProxy::TIMEOUT_USE_DEFAULT, |
171 base::Bind(&PropertySet::OnSet, | 171 base::Bind(&PropertySet::OnSet, |
172 GetWeakPtr(), | 172 GetWeakPtr(), |
173 property, | 173 property, |
174 callback)); | 174 callback)); |
175 } | 175 } |
176 | 176 |
| 177 bool PropertySet::SetAndBlock(PropertyBase* property) { |
| 178 MethodCall method_call(kPropertiesInterface, kPropertiesSet); |
| 179 MessageWriter writer(&method_call); |
| 180 writer.AppendString(interface()); |
| 181 writer.AppendString(property->name()); |
| 182 property->AppendSetValueToWriter(&writer); |
| 183 |
| 184 DCHECK(object_proxy_); |
| 185 scoped_ptr<dbus::Response> response( |
| 186 object_proxy_->CallMethodAndBlock(&method_call, |
| 187 ObjectProxy::TIMEOUT_USE_DEFAULT)); |
| 188 if (response.get()) |
| 189 return true; |
| 190 return false; |
| 191 } |
| 192 |
177 void PropertySet::OnSet(PropertyBase* property, | 193 void PropertySet::OnSet(PropertyBase* property, |
178 SetCallback callback, | 194 SetCallback callback, |
179 Response* response) { | 195 Response* response) { |
180 LOG_IF(WARNING, !response) << property->name() << ": Set: failed."; | 196 LOG_IF(WARNING, !response) << property->name() << ": Set: failed."; |
181 if (!callback.is_null()) | 197 if (!callback.is_null()) |
182 callback.Run(response); | 198 callback.Run(response); |
183 } | 199 } |
184 | 200 |
185 bool PropertySet::UpdatePropertiesFromReader(MessageReader* reader) { | 201 bool PropertySet::UpdatePropertiesFromReader(MessageReader* reader) { |
186 DCHECK(reader); | 202 DCHECK(reader); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 template class Property<double>; | 642 template class Property<double>; |
627 template class Property<std::string>; | 643 template class Property<std::string>; |
628 template class Property<ObjectPath>; | 644 template class Property<ObjectPath>; |
629 template class Property<std::vector<std::string> >; | 645 template class Property<std::vector<std::string> >; |
630 template class Property<std::vector<ObjectPath> >; | 646 template class Property<std::vector<ObjectPath> >; |
631 template class Property<std::vector<uint8> >; | 647 template class Property<std::vector<uint8> >; |
632 template class Property<std::map<std::string, std::string>>; | 648 template class Property<std::map<std::string, std::string>>; |
633 template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; | 649 template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; |
634 | 650 |
635 } // namespace dbus | 651 } // namespace dbus |
OLD | NEW |