Anton Muhin | 5975552 | 2014-11-05 21:30:12 +0400 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "buffet/commands/cloud_command_proxy.h" |
| 6 | |
| 7 | #include "buffet/commands/command_instance.h" |
| 8 | #include "buffet/commands/prop_constraints.h" |
| 9 | #include "buffet/commands/prop_types.h" |
| 10 | #include "buffet/device_registration_info.h" |
| 11 | |
| 12 | namespace buffet { |
| 13 | |
| 14 | CloudCommandProxy::CloudCommandProxy( |
| 15 | CommandInstance* command_instance, |
| 16 | DeviceRegistrationInfo* device_registration_info) |
| 17 | : command_instance_(command_instance), |
| 18 | device_registration_info_(device_registration_info) { |
| 19 | } |
| 20 | |
Anton Muhin | cfde869 | 2014-11-25 03:36:59 +0400 | [diff] [blame] | 21 | void CloudCommandProxy::OnResultsChanged(const native_types::Object& results) { |
| 22 | base::DictionaryValue patch; |
| 23 | patch.Set("results", TypedValueToJson(results, nullptr).get()); |
| 24 | device_registration_info_->UpdateCommand(command_instance_->GetID(), patch); |
| 25 | } |
| 26 | |
Anton Muhin | 5975552 | 2014-11-05 21:30:12 +0400 | [diff] [blame] | 27 | void CloudCommandProxy::OnStatusChanged(const std::string& status) { |
| 28 | base::DictionaryValue patch; |
| 29 | // TODO(antonm): Change status to state. |
| 30 | patch.SetString("state", status); |
| 31 | device_registration_info_->UpdateCommand(command_instance_->GetID(), patch); |
| 32 | } |
| 33 | |
| 34 | void CloudCommandProxy::OnProgressChanged(int progress) { |
| 35 | base::DictionaryValue patch; |
| 36 | patch.SetInteger("progress", progress); |
| 37 | // TODO(antonm): Consider batching progress change updates. |
| 38 | device_registration_info_->UpdateCommand(command_instance_->GetID(), patch); |
| 39 | } |
| 40 | |
| 41 | } // namespace buffet |