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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 DCHECK(object_proxy_); | 130 DCHECK(object_proxy_); |
131 object_proxy_->CallMethod(&method_call, | 131 object_proxy_->CallMethod(&method_call, |
132 ObjectProxy::TIMEOUT_USE_DEFAULT, | 132 ObjectProxy::TIMEOUT_USE_DEFAULT, |
133 base::Bind(&PropertySet::OnGetAll, | 133 base::Bind(&PropertySet::OnGetAll, |
134 weak_ptr_factory_.GetWeakPtr())); | 134 weak_ptr_factory_.GetWeakPtr())); |
135 } | 135 } |
136 | 136 |
137 void PropertySet::OnGetAll(Response* response) { | 137 void PropertySet::OnGetAll(Response* response) { |
138 if (!response) { | 138 if (!response) { |
139 LOG(WARNING) << "GetAll request failed."; | 139 LOG(WARNING) << "GetAll request failed for: " << interface_; |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 MessageReader reader(response); | 143 MessageReader reader(response); |
144 if (!UpdatePropertiesFromReader(&reader)) { | 144 if (!UpdatePropertiesFromReader(&reader)) { |
145 LOG(WARNING) << "GetAll response has wrong parameters: " | 145 LOG(WARNING) << "GetAll response has wrong parameters: " |
146 << "expected dictionary: " << response->ToString(); | 146 << "expected dictionary: " << response->ToString(); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void PropertySet::Set(PropertyBase* property, SetCallback callback) { | 150 void PropertySet::Set(PropertyBase* property, SetCallback callback) { |
151 MethodCall method_call(kPropertiesInterface, kPropertiesSet); | 151 MethodCall method_call(kPropertiesInterface, kPropertiesSet); |
152 MessageWriter writer(&method_call); | 152 MessageWriter writer(&method_call); |
153 writer.AppendString(interface()); | 153 writer.AppendString(interface()); |
154 writer.AppendString(property->name()); | 154 writer.AppendString(property->name()); |
155 property->AppendSetValueToWriter(&writer); | 155 property->AppendSetValueToWriter(&writer); |
156 | 156 |
157 DCHECK(object_proxy_); | 157 DCHECK(object_proxy_); |
158 object_proxy_->CallMethod(&method_call, | 158 object_proxy_->CallMethod(&method_call, |
159 ObjectProxy::TIMEOUT_USE_DEFAULT, | 159 ObjectProxy::TIMEOUT_USE_DEFAULT, |
160 base::Bind(&PropertySet::OnSet, | 160 base::Bind(&PropertySet::OnSet, |
161 GetWeakPtr(), | 161 GetWeakPtr(), |
162 property, | 162 property, |
163 callback)); | 163 callback)); |
164 } | 164 } |
165 | 165 |
166 void PropertySet::OnSet(PropertyBase* property, SetCallback callback, | 166 void PropertySet::OnSet(PropertyBase* property, |
| 167 SetCallback callback, |
167 Response* response) { | 168 Response* response) { |
168 LOG_IF(WARNING, !response) << property->name() << ": Set: failed."; | 169 LOG_IF(WARNING, !response) << property->name() << ": Set: failed."; |
169 if (!callback.is_null()) | 170 if (!callback.is_null()) |
170 callback.Run(response); | 171 callback.Run(response); |
171 } | 172 } |
172 | 173 |
173 bool PropertySet::UpdatePropertiesFromReader(MessageReader* reader) { | 174 bool PropertySet::UpdatePropertiesFromReader(MessageReader* reader) { |
174 DCHECK(reader); | 175 DCHECK(reader); |
175 MessageReader array_reader(NULL); | 176 MessageReader array_reader(NULL); |
176 if (!reader->PopArray(&array_reader)) | 177 if (!reader->PopArray(&array_reader)) |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 template <> | 472 template <> |
472 void Property<std::vector<uint8> >::AppendSetValueToWriter( | 473 void Property<std::vector<uint8> >::AppendSetValueToWriter( |
473 MessageWriter* writer) { | 474 MessageWriter* writer) { |
474 MessageWriter variant_writer(NULL); | 475 MessageWriter variant_writer(NULL); |
475 writer->OpenVariant("ay", &variant_writer); | 476 writer->OpenVariant("ay", &variant_writer); |
476 variant_writer.AppendArrayOfBytes(set_value_.data(), set_value_.size()); | 477 variant_writer.AppendArrayOfBytes(set_value_.data(), set_value_.size()); |
477 writer->CloseContainer(&variant_writer); | 478 writer->CloseContainer(&variant_writer); |
478 } | 479 } |
479 | 480 |
480 } // namespace dbus | 481 } // namespace dbus |
OLD | NEW |